Class: SignIn::AccessTokenJwtEncoder
- Inherits:
-
Object
- Object
- SignIn::AccessTokenJwtEncoder
- Defined in:
- app/services/sign_in/access_token_jwt_encoder.rb
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
Instance Method Summary collapse
-
#initialize(access_token:) ⇒ AccessTokenJwtEncoder
constructor
A new instance of AccessTokenJwtEncoder.
- #jwt_encode_access_token ⇒ Object private
- #payload ⇒ Object private
- #perform ⇒ Object
- #private_key ⇒ Object private
Constructor Details
#initialize(access_token:) ⇒ AccessTokenJwtEncoder
Returns a new instance of AccessTokenJwtEncoder.
7 8 9 |
# File 'app/services/sign_in/access_token_jwt_encoder.rb', line 7 def initialize(access_token:) @access_token = access_token end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
5 6 7 |
# File 'app/services/sign_in/access_token_jwt_encoder.rb', line 5 def access_token @access_token end |
Instance Method Details
#jwt_encode_access_token ⇒ Object (private)
37 38 39 |
# File 'app/services/sign_in/access_token_jwt_encoder.rb', line 37 def jwt_encode_access_token JWT.encode(payload, private_key, Constants::AccessToken::JWT_ENCODE_ALGORITHM) end |
#payload ⇒ Object (private)
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/sign_in/access_token_jwt_encoder.rb', line 17 def payload { iss: Constants::AccessToken::ISSUER, aud: access_token.audience, client_id: access_token.client_id, jti: access_token.uuid, sub: access_token.user_uuid, exp: access_token.expiration_time.to_i, iat: access_token.created_time.to_i, session_handle: access_token.session_handle, refresh_token_hash: access_token.refresh_token_hash, device_secret_hash: access_token.device_secret_hash, parent_refresh_token_hash: access_token.parent_refresh_token_hash, anti_csrf_token: access_token.anti_csrf_token, last_regeneration_time: access_token.last_regeneration_time.to_i, version: access_token.version, user_attributes: access_token.user_attributes } end |
#perform ⇒ Object
11 12 13 |
# File 'app/services/sign_in/access_token_jwt_encoder.rb', line 11 def perform jwt_encode_access_token end |
#private_key ⇒ Object (private)
41 42 43 |
# File 'app/services/sign_in/access_token_jwt_encoder.rb', line 41 def private_key OpenSSL::PKey::RSA.new(File.read(Settings.sign_in.jwt_encode_key)) end |