Class: SignIn::AccessToken
- Inherits:
-
Object
- Object
- SignIn::AccessToken
- Includes:
- ActiveModel::Validations
- Defined in:
- app/models/sign_in/access_token.rb
Instance Attribute Summary collapse
-
#anti_csrf_token ⇒ Object
readonly
Returns the value of attribute anti_csrf_token.
-
#audience ⇒ Object
readonly
Returns the value of attribute audience.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#created_time ⇒ Object
readonly
Returns the value of attribute created_time.
-
#device_secret_hash ⇒ Object
readonly
Returns the value of attribute device_secret_hash.
-
#expiration_time ⇒ Object
readonly
Returns the value of attribute expiration_time.
-
#last_regeneration_time ⇒ Object
readonly
Returns the value of attribute last_regeneration_time.
-
#parent_refresh_token_hash ⇒ Object
readonly
Returns the value of attribute parent_refresh_token_hash.
-
#refresh_token_hash ⇒ Object
readonly
Returns the value of attribute refresh_token_hash.
-
#session_handle ⇒ Object
readonly
Returns the value of attribute session_handle.
-
#user_attributes ⇒ Object
readonly
Returns the value of attribute user_attributes.
-
#user_uuid ⇒ Object
readonly
Returns the value of attribute user_uuid.
-
#uuid ⇒ Object
readonly
Returns the value of attribute uuid.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #client_config ⇒ Object private
- #create_uuid ⇒ Object private
- #filter_user_attributes(user_attributes:) ⇒ Object private
-
#initialize(session_handle:, client_id:, user_uuid:, audience:, refresh_token_hash:, anti_csrf_token:, last_regeneration_time:, uuid: nil, parent_refresh_token_hash: nil, version: nil, expiration_time: nil, created_time: nil, user_attributes: nil, device_secret_hash: nil) ⇒ AccessToken
constructor
rubocop:disable Metrics/ParameterLists.
-
#persisted? ⇒ Boolean
rubocop:enable Metrics/ParameterLists.
- #set_created_time ⇒ Object private
- #set_expiration_time ⇒ Object private
- #to_s ⇒ Object
- #validity_length ⇒ Object private
Constructor Details
#initialize(session_handle:, client_id:, user_uuid:, audience:, refresh_token_hash:, anti_csrf_token:, last_regeneration_time:, uuid: nil, parent_refresh_token_hash: nil, version: nil, expiration_time: nil, created_time: nil, user_attributes: nil, device_secret_hash: nil) ⇒ AccessToken
rubocop:disable Metrics/ParameterLists
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'app/models/sign_in/access_token.rb', line 42 def initialize(session_handle:, client_id:, user_uuid:, audience:, refresh_token_hash:, anti_csrf_token:, last_regeneration_time:, uuid: nil, parent_refresh_token_hash: nil, version: nil, expiration_time: nil, created_time: nil, user_attributes: nil, device_secret_hash: nil) @uuid = uuid || create_uuid @session_handle = session_handle @client_id = client_id @user_uuid = user_uuid @audience = audience @refresh_token_hash = refresh_token_hash @anti_csrf_token = anti_csrf_token @last_regeneration_time = last_regeneration_time @parent_refresh_token_hash = parent_refresh_token_hash @version = version || Constants::AccessToken::CURRENT_VERSION @expiration_time = expiration_time || set_expiration_time @created_time = created_time || set_created_time @user_attributes = filter_user_attributes(user_attributes:) @device_secret_hash = device_secret_hash validate! end |
Instance Attribute Details
#anti_csrf_token ⇒ Object (readonly)
Returns the value of attribute anti_csrf_token.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def anti_csrf_token @anti_csrf_token end |
#audience ⇒ Object (readonly)
Returns the value of attribute audience.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def audience @audience end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def client_id @client_id end |
#created_time ⇒ Object (readonly)
Returns the value of attribute created_time.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def created_time @created_time end |
#device_secret_hash ⇒ Object (readonly)
Returns the value of attribute device_secret_hash.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def device_secret_hash @device_secret_hash end |
#expiration_time ⇒ Object (readonly)
Returns the value of attribute expiration_time.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def expiration_time @expiration_time end |
#last_regeneration_time ⇒ Object (readonly)
Returns the value of attribute last_regeneration_time.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def last_regeneration_time @last_regeneration_time end |
#parent_refresh_token_hash ⇒ Object (readonly)
Returns the value of attribute parent_refresh_token_hash.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def parent_refresh_token_hash @parent_refresh_token_hash end |
#refresh_token_hash ⇒ Object (readonly)
Returns the value of attribute refresh_token_hash.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def refresh_token_hash @refresh_token_hash end |
#session_handle ⇒ Object (readonly)
Returns the value of attribute session_handle.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def session_handle @session_handle end |
#user_attributes ⇒ Object (readonly)
Returns the value of attribute user_attributes.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def user_attributes @user_attributes end |
#user_uuid ⇒ Object (readonly)
Returns the value of attribute user_uuid.
7 8 9 |
# File 'app/models/sign_in/access_token.rb', line 7 def user_uuid @user_uuid end |
#uuid ⇒ Object (readonly)
Returns the value of attribute uuid.
7 8 9 |
# File 'app/models/sign_in/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/access_token.rb', line 7 def version @version end |
Instance Method Details
#client_config ⇒ Object (private)
117 118 119 |
# File 'app/models/sign_in/access_token.rb', line 117 def client_config @client_config ||= ClientConfig.find_by(client_id:) end |
#create_uuid ⇒ Object (private)
95 96 97 |
# File 'app/models/sign_in/access_token.rb', line 95 def create_uuid SecureRandom.uuid end |
#filter_user_attributes(user_attributes:) ⇒ Object (private)
111 112 113 114 115 |
# File 'app/models/sign_in/access_token.rb', line 111 def filter_user_attributes(user_attributes:) return nil unless user_attributes.presence user_attributes.with_indifferent_access.select { |key| client_config&.access_token_attributes&.include?(key) } end |
#persisted? ⇒ Boolean
rubocop:enable Metrics/ParameterLists
75 76 77 |
# File 'app/models/sign_in/access_token.rb', line 75 def persisted? false end |
#set_created_time ⇒ Object (private)
103 104 105 |
# File 'app/models/sign_in/access_token.rb', line 103 def set_created_time Time.zone.now end |
#set_expiration_time ⇒ Object (private)
99 100 101 |
# File 'app/models/sign_in/access_token.rb', line 99 def set_expiration_time Time.zone.now + validity_length end |
#to_s ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/models/sign_in/access_token.rb', line 79 def to_s { uuid:, user_uuid:, session_handle:, client_id:, audience:, version:, last_regeneration_time: last_regeneration_time.to_i, created_time: created_time.to_i, expiration_time: expiration_time.to_i } end |
#validity_length ⇒ Object (private)
107 108 109 |
# File 'app/models/sign_in/access_token.rb', line 107 def validity_length client_config.access_token_duration end |