Class: WardenOpenidAuth::OpenidMetadata
- Inherits:
-
Object
- Object
- WardenOpenidAuth::OpenidMetadata
- Includes:
- ERB::Util
- Defined in:
- lib/warden_openid_auth/openid_metadata.rb
Overview
Representation of the OpenID config document.
Instance Attribute Summary collapse
-
#cache ⇒ Object
readonly
Returns the value of attribute cache.
-
#cache_options ⇒ Object
readonly
Returns the value of attribute cache_options.
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#metadata_url ⇒ Object
readonly
Returns the value of attribute metadata_url.
Instance Method Summary collapse
-
#authorization_url(redirect_uri:, state:, scope: 'openid profile email') ⇒ String
The full URL for authorization including parameters.
-
#initialize(config: WardenOpenidAuth.config) ⇒ OpenidMetadata
constructor
A new instance of OpenidMetadata.
-
#method_missing(name) ⇒ Object
Check if the method asked for is a key in the config_document.
-
#respond_to_missing?(name) ⇒ Boolean
if the the object does not respond to the method passed to respond_to? Check if the method called is a key on config_document, if it is respond with true indicating that the object does respond to that method.
-
#to_h ⇒ Hash
A hash representation of the OpenID configuration document.
Constructor Details
#initialize(config: WardenOpenidAuth.config) ⇒ OpenidMetadata
Returns a new instance of OpenidMetadata.
16 17 18 19 20 21 |
# File 'lib/warden_openid_auth/openid_metadata.rb', line 16 def initialize(config: WardenOpenidAuth.config) @metadata_url = config. @cache = config.cache @cache_options = config. @client_id = config.client_id end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name) ⇒ Object
Check if the method asked for is a key in the config_document. If it is return it. Otherwise call parent which will throw a NoMethodError error.
38 39 40 |
# File 'lib/warden_openid_auth/openid_metadata.rb', line 38 def method_missing(name) config_document.fetch(name.to_s) { super } end |
Instance Attribute Details
#cache ⇒ Object (readonly)
Returns the value of attribute cache.
13 14 15 |
# File 'lib/warden_openid_auth/openid_metadata.rb', line 13 def cache @cache end |
#cache_options ⇒ Object (readonly)
Returns the value of attribute cache_options.
13 14 15 |
# File 'lib/warden_openid_auth/openid_metadata.rb', line 13 def @cache_options end |
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
13 14 15 |
# File 'lib/warden_openid_auth/openid_metadata.rb', line 13 def client_id @client_id end |
#metadata_url ⇒ Object (readonly)
Returns the value of attribute metadata_url.
13 14 15 |
# File 'lib/warden_openid_auth/openid_metadata.rb', line 13 def @metadata_url end |
Instance Method Details
#authorization_url(redirect_uri:, state:, scope: 'openid profile email') ⇒ String
Returns the full URL for authorization including parameters.
24 25 26 27 28 29 |
# File 'lib/warden_openid_auth/openid_metadata.rb', line 24 def (redirect_uri:, state:, scope: 'openid profile email') uri = URI(config_document['authorization_endpoint']) uri.query = "client_id=#{url_encode(client_id)}&redirect_uri=#{url_encode(redirect_uri)}" \ "&scope=#{url_encode(scope)}&state=#{url_encode(state)}&response_mode=query&response_type=code" uri.to_s end |
#respond_to_missing?(name) ⇒ Boolean
if the the object does not respond to the method passed to respond_to? Check if the method called is a key on config_document, if it is respond with true indicating that the object does respond to that method.
45 46 47 48 49 |
# File 'lib/warden_openid_auth/openid_metadata.rb', line 45 def respond_to_missing?(name) return true if config_document.include?(name.to_s) super end |
#to_h ⇒ Hash
Returns a hash representation of the OpenID configuration document.
32 33 34 |
# File 'lib/warden_openid_auth/openid_metadata.rb', line 32 def to_h config_document end |