Class: Doorkeeper::OpenidConnect::IdToken
- Inherits:
-
Object
- Object
- Doorkeeper::OpenidConnect::IdToken
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/doorkeeper/openid_connect/id_token.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#nonce ⇒ Object
readonly
Returns the value of attribute nonce.
Instance Method Summary collapse
- #as_json(*_) ⇒ Object
- #as_jws_token ⇒ Object
- #claims ⇒ Object
-
#initialize(access_token, nonce = nil) ⇒ IdToken
constructor
A new instance of IdToken.
Constructor Details
#initialize(access_token, nonce = nil) ⇒ IdToken
Returns a new instance of IdToken.
10 11 12 13 14 15 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 10 def initialize(access_token, nonce = nil) @access_token = access_token @nonce = nonce @resource_owner = Doorkeeper::OpenidConnect.configuration.resource_owner_from_access_token.call(access_token) @issued_at = Time.zone.now end |
Instance Attribute Details
#nonce ⇒ Object (readonly)
Returns the value of attribute nonce.
8 9 10 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 8 def nonce @nonce end |
Instance Method Details
#as_json(*_) ⇒ Object
29 30 31 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 29 def as_json(*_) claims.reject { |_, value| value.nil? || value == '' } end |
#as_jws_token ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 33 def as_jws_token JWT.encode(as_json, Doorkeeper::OpenidConnect.signing_key.keypair, Doorkeeper::OpenidConnect.signing_algorithm.to_s, { kid: Doorkeeper::OpenidConnect.signing_key.kid } ).to_s end |
#claims ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 17 def claims { iss: issuer, sub: subject, aud: audience, exp: expiration, iat: issued_at, nonce: nonce, auth_time: auth_time }.merge ClaimsBuilder.generate(@access_token, :id_token) end |