Class: Himari::IdToken
Instance Attribute Summary collapse
-
#nonce ⇒ Object
readonly
Returns the value of attribute nonce.
Attributes inherited from JwtToken
#claims, #client_id, #issuer, #signing_key
Class Method Summary collapse
Instance Method Summary collapse
- #at_hash ⇒ Object
- #final_claims ⇒ Object
-
#initialize(nonce:, access_token: nil, **kwargs) ⇒ IdToken
constructor
A new instance of IdToken.
Methods inherited from JwtToken
#jwt_header, #standard_claims, #to_jwt
Constructor Details
#initialize(nonce:, access_token: nil, **kwargs) ⇒ IdToken
Returns a new instance of IdToken.
23 24 25 26 27 |
# File 'lib/himari/id_token.rb', line 23 def initialize(nonce:, access_token: nil, **kwargs) super(**kwargs) @nonce = nonce @access_token = access_token end |
Instance Attribute Details
#nonce ⇒ Object (readonly)
Returns the value of attribute nonce.
29 30 31 |
# File 'lib/himari/id_token.rb', line 29 def nonce @nonce end |
Class Method Details
.from_authz(authz, **kwargs) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/himari/id_token.rb', line 13 def self.from_authz(authz, **kwargs) new( claims: authz.claims, client_id: authz.client_id, nonce: authz.nonce, lifetime: authz.lifetime.is_a?(Integer) ? authz.lifetime : authz.lifetime.id_token, # compat **kwargs, ) end |
Instance Method Details
#at_hash ⇒ Object
40 41 42 43 44 45 |
# File 'lib/himari/id_token.rb', line 40 def at_hash return unless @access_token dgst = signing_key.hash_function.digest(@access_token) Base64.urlsafe_encode64(dgst[0, dgst.size / 2], padding: false) end |
#final_claims ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/himari/id_token.rb', line 31 def final_claims # https://openid.net/specs/openid-connect-core-1_0.html#IDToken standard_claims.merge( @nonce ? {nonce: @nonce} : {}, ).merge( @access_token ? {at_hash: at_hash} : {}, ) end |