Class: Authinator::Configuration
- Inherits:
-
Object
- Object
- Authinator::Configuration
- Defined in:
- lib/authinator/configuration.rb
Overview
Configuration class
Instance Attribute Summary collapse
-
#providers ⇒ Object
readonly
Returns the value of attribute providers.
-
#valid_applications ⇒ Object
Returns the value of attribute valid_applications.
Instance Method Summary collapse
- #add_provider(provider_name, options = {}) ⇒ Object
- #add_secrets(provider_name, options = {}) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#provider_for(provider_name) ⇒ Object
A more abstracted way of accessing the providers.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/authinator/configuration.rb', line 28 def initialize @providers = {} add_provider( :stub, client_id: 'cl_id', client_secret: 'cl_sec', site: 'https://example.org', token_url: '/extoken', api_key: 'api_key', user_info_url: 'http://example.org/info', ) add_provider( :google, site: 'https://accounts.google.com', token_url: '/o/oauth2/token', user_info_url: 'https://www.googleapis.com/plus/v1/people/me/openIdConnect', ) end |
Instance Attribute Details
#providers ⇒ Object (readonly)
Returns the value of attribute providers.
25 26 27 |
# File 'lib/authinator/configuration.rb', line 25 def providers @providers end |
#valid_applications ⇒ Object
Returns the value of attribute valid_applications.
26 27 28 |
# File 'lib/authinator/configuration.rb', line 26 def valid_applications @valid_applications end |
Instance Method Details
#add_provider(provider_name, options = {}) ⇒ Object
51 52 53 |
# File 'lib/authinator/configuration.rb', line 51 def add_provider(provider_name, = {}) @providers[provider_name] = Provider.new(provider_name, ) end |
#add_secrets(provider_name, options = {}) ⇒ Object
55 56 57 58 59 60 61 62 63 64 |
# File 'lib/authinator/configuration.rb', line 55 def add_secrets(provider_name, = {}) fail( ArgumentError, "#{provider_name} is not a configured provider.\n" \ "Valid Providers:\n" << providers.to_s, ) if @providers[provider_name].blank? @providers[provider_name].add_secrets() end |
#provider_for(provider_name) ⇒ Object
A more abstracted way of accessing the providers
67 68 69 |
# File 'lib/authinator/configuration.rb', line 67 def provider_for(provider_name) @providers[provider_name] end |