Class: OpenIDConnect::Discovery::Provider::Config::Response
- Inherits:
-
Object
- Object
- OpenIDConnect::Discovery::Provider::Config::Response
- Includes:
- ActiveModel::Validations, AttrOptional, AttrRequired
- Defined in:
- lib/openid_connect/discovery/provider/config/response.rb
Instance Attribute Summary collapse
-
#expected_issuer ⇒ Object
Returns the value of attribute expected_issuer.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(hash) ⇒ Response
constructor
A new instance of Response.
- #jwks ⇒ Object
- #public_keys ⇒ Object
- #validate!(expected_issuer = nil) ⇒ Object
Constructor Details
#initialize(hash) ⇒ Response
Returns a new instance of Response.
62 63 64 65 66 67 |
# File 'lib/openid_connect/discovery/provider/config/response.rb', line 62 def initialize(hash) (required_attributes + optional_attributes).each do |key| self.send "#{key}=", hash[key] end @raw = hash end |
Instance Attribute Details
#expected_issuer ⇒ Object
Returns the value of attribute expected_issuer.
10 11 12 |
# File 'lib/openid_connect/discovery/provider/config/response.rb', line 10 def expected_issuer @expected_issuer end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
9 10 11 |
# File 'lib/openid_connect/discovery/provider/config/response.rb', line 9 def raw @raw end |
Instance Method Details
#as_json(options = {}) ⇒ Object
69 70 71 72 73 74 75 76 |
# File 'lib/openid_connect/discovery/provider/config/response.rb', line 69 def as_json( = {}) validate! (required_attributes + optional_attributes).inject({}) do |hash, _attr_| value = self.send _attr_ hash.merge! _attr_ => value unless value.nil? hash end end |
#jwks ⇒ Object
82 83 84 85 86 87 |
# File 'lib/openid_connect/discovery/provider/config/response.rb', line 82 def jwks @jwks ||= JSON.parse( OpenIDConnect.http_client.get_content(jwks_uri) ).with_indifferent_access JSON::JWK::Set.new @jwks[:keys] end |
#public_keys ⇒ Object
89 90 91 |
# File 'lib/openid_connect/discovery/provider/config/response.rb', line 89 def public_keys @public_keys ||= jwks.collect(&:to_key) end |
#validate!(expected_issuer = nil) ⇒ Object
78 79 80 |
# File 'lib/openid_connect/discovery/provider/config/response.rb', line 78 def validate!(expected_issuer = nil) valid? or raise ValidationFailed.new(self) end |