Class: Knock::Oauth2CodeVerifier::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/knock/oauth2_code_verifier/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



10
11
12
# File 'lib/knock/oauth2_code_verifier/configuration.rb', line 10

def initialize
  @providers = {}
end

Instance Attribute Details

#providersObject

Returns the value of attribute providers.



8
9
10
# File 'lib/knock/oauth2_code_verifier/configuration.rb', line 8

def providers
  @providers
end

Instance Method Details

#add_provider(provider, client_id, client_secret, urls) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/knock/oauth2_code_verifier/configuration.rb', line 14

def add_provider(provider, client_id, client_secret, urls)
  raise "provider is required" unless provider
  raise "client ID for provider is required" unless client_id
  raise "client secret for provider is required" unless client_secret
  raise "URL for token is required" unless urls[:token_url]
  raise "URL for user info is required" unless urls[:userinfo_url]

  @providers[provider] = {
    client_id: client_id,
    client_secret: client_secret,
    token_url: urls[:token_url],
    userinfo_url: urls[:userinfo_url],
  }
end

#for_provider(provider) ⇒ Object



29
30
31
# File 'lib/knock/oauth2_code_verifier/configuration.rb', line 29

def for_provider(provider)
  OpenStruct.new(@providers[provider.to_sym])
end