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.
8 9 10 11 12 13 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 8 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.now end |
Instance Attribute Details
#nonce ⇒ Object (readonly)
Returns the value of attribute nonce.
6 7 8 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 6 def nonce @nonce end |
Instance Method Details
#as_json(*_) ⇒ Object
27 28 29 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 27 def as_json(*_) claims.reject { |_, value| value.nil? || value == '' } end |
#as_jws_token ⇒ Object
31 32 33 34 35 36 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 31 def as_jws_token JSON::JWT.new(as_json).sign( Doorkeeper::OpenidConnect.signing_key, Doorkeeper::OpenidConnect.signing_algorithm ).to_s end |
#claims ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/doorkeeper/openid_connect/id_token.rb', line 15 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 |