Class: SignIn::ServiceAccountAccessToken
- Inherits:
-
Object
- Object
- SignIn::ServiceAccountAccessToken
- Includes:
- ActiveModel::Validations
- Defined in:
- app/models/sign_in/service_account_access_token.rb
Instance Attribute Summary collapse
-
#audience ⇒ Object
readonly
Returns the value of attribute audience.
-
#created_time ⇒ Object
readonly
Returns the value of attribute created_time.
-
#expiration_time ⇒ Object
readonly
Returns the value of attribute expiration_time.
-
#scopes ⇒ Object
readonly
Returns the value of attribute scopes.
-
#service_account_id ⇒ Object
readonly
Returns the value of attribute service_account_id.
-
#user_attributes ⇒ Object
readonly
Returns the value of attribute user_attributes.
-
#user_identifier ⇒ Object
readonly
Returns the value of attribute user_identifier.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #create_uuid ⇒ Object private
-
#initialize(service_account_id:, audience:, user_identifier:, scopes: [], user_attributes: {}, uuid: nil, version: nil, expiration_time: nil, created_time: nil) ⇒ ServiceAccountAccessToken
constructor
rubocop:disable Metrics/ParameterLists.
-
#persisted? ⇒ Boolean
rubocop:enable Metrics/ParameterLists.
- #service_account_config ⇒ Object private
- #set_created_time ⇒ Object private
- #set_expiration_time ⇒ Object private
- #to_s ⇒ Object
- #validity_length ⇒ Object private
Constructor Details
#initialize(service_account_id:, audience:, user_identifier:, scopes: [], user_attributes: {}, uuid: nil, version: nil, expiration_time: nil, created_time: nil) ⇒ ServiceAccountAccessToken
rubocop:disable Metrics/ParameterLists
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/sign_in/service_account_access_token.rb', line 33 def initialize(service_account_id:, audience:, user_identifier:, scopes: [], user_attributes: {}, uuid: nil, version: nil, expiration_time: nil, created_time: nil) @uuid = uuid || create_uuid @service_account_id = service_account_id @user_attributes = user_attributes @user_identifier = user_identifier @scopes = scopes @audience = audience @version = version || Constants::ServiceAccountAccessToken::CURRENT_VERSION @expiration_time = expiration_time || set_expiration_time @created_time = created_time || set_created_time validate! end |
Instance Attribute Details
#audience ⇒ Object (readonly)
Returns the value of attribute audience.
7 8 9 |
# File 'app/models/sign_in/service_account_access_token.rb', line 7 def audience @audience end |
#created_time ⇒ Object (readonly)
Returns the value of attribute created_time.
7 8 9 |
# File 'app/models/sign_in/service_account_access_token.rb', line 7 def created_time @created_time end |
#expiration_time ⇒ Object (readonly)
Returns the value of attribute expiration_time.
7 8 9 |
# File 'app/models/sign_in/service_account_access_token.rb', line 7 def expiration_time @expiration_time end |
#scopes ⇒ Object (readonly)
Returns the value of attribute scopes.
7 8 9 |
# File 'app/models/sign_in/service_account_access_token.rb', line 7 def scopes @scopes end |
#service_account_id ⇒ Object (readonly)
Returns the value of attribute service_account_id.
7 8 9 |
# File 'app/models/sign_in/service_account_access_token.rb', line 7 def service_account_id @service_account_id end |
#user_attributes ⇒ Object (readonly)
Returns the value of attribute user_attributes.
7 8 9 |
# File 'app/models/sign_in/service_account_access_token.rb', line 7 def user_attributes @user_attributes end |
#user_identifier ⇒ Object (readonly)
Returns the value of attribute user_identifier.
7 8 9 |
# File 'app/models/sign_in/service_account_access_token.rb', line 7 def user_identifier @user_identifier end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
7 8 9 |
# File 'app/models/sign_in/service_account_access_token.rb', line 7 def uuid @uuid end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
7 8 9 |
# File 'app/models/sign_in/service_account_access_token.rb', line 7 def version @version end |
Instance Method Details
#create_uuid ⇒ Object (private)
76 77 78 |
# File 'app/models/sign_in/service_account_access_token.rb', line 76 def create_uuid SecureRandom.uuid end |
#persisted? ⇒ Boolean
rubocop:enable Metrics/ParameterLists
56 57 58 |
# File 'app/models/sign_in/service_account_access_token.rb', line 56 def persisted? false end |
#service_account_config ⇒ Object (private)
92 93 94 |
# File 'app/models/sign_in/service_account_access_token.rb', line 92 def service_account_config @service_account_config ||= ServiceAccountConfig.find_by(service_account_id:) end |
#set_created_time ⇒ Object (private)
84 85 86 |
# File 'app/models/sign_in/service_account_access_token.rb', line 84 def set_created_time Time.zone.now end |
#set_expiration_time ⇒ Object (private)
80 81 82 |
# File 'app/models/sign_in/service_account_access_token.rb', line 80 def set_expiration_time Time.zone.now + validity_length end |
#to_s ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/sign_in/service_account_access_token.rb', line 60 def to_s { uuid:, service_account_id:, user_attributes:, user_identifier:, scopes:, audience:, version:, created_time: created_time.to_i, expiration_time: expiration_time.to_i } end |
#validity_length ⇒ Object (private)
88 89 90 |
# File 'app/models/sign_in/service_account_access_token.rb', line 88 def validity_length service_account_config.access_token_duration end |