class OpenIDConnect::Discovery::Provider::Config::Response
Attributes
expected_issuer[RW]
raw[R]
Public Class Methods
new(hash)
click to toggle source
# File lib/openid_connect/discovery/provider/config/response.rb, line 63 def initialize(hash) (required_attributes + optional_attributes).each do |key| self.send "#{key}=", hash[key] end @raw = hash end
Public Instance Methods
as_json(options = {})
click to toggle source
# File lib/openid_connect/discovery/provider/config/response.rb, line 70 def as_json(options = {}) validate! (required_attributes + optional_attributes).inject({}) do |hash, _attr_| value = self.send _attr_ hash.merge! _attr_ => value unless value.nil? hash end end
jwk(kid)
click to toggle source
# File lib/openid_connect/discovery/provider/config/response.rb, line 88 def jwk(kid) @jwks ||= {} @jwks[kid] ||= JSON::JWK::Set::Fetcher.fetch(jwks_uri, kid: kid) end
jwks()
click to toggle source
# File lib/openid_connect/discovery/provider/config/response.rb, line 83 def jwks @jwks ||= OpenIDConnect.http_client.get(jwks_uri).body.with_indifferent_access JSON::JWK::Set.new @jwks[:keys] end
public_keys()
click to toggle source
# File lib/openid_connect/discovery/provider/config/response.rb, line 93 def public_keys @public_keys ||= jwks.collect(&:to_key) end
validate!()
click to toggle source
# File lib/openid_connect/discovery/provider/config/response.rb, line 79 def validate! valid? or raise ValidationFailed.new(self) end
Private Instance Methods
validate_issuer_matching()
click to toggle source
# File lib/openid_connect/discovery/provider/config/response.rb, line 99 def validate_issuer_matching if expected_issuer.present? && issuer != expected_issuer if OpenIDConnect.validate_discovery_issuer errors.add :issuer, 'mismatch' else OpenIDConnect.logger.warn 'ignoring issuer mismach.' end end end