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