Class: Code0::Identities::IdentityProvider

Inherits:
Object
  • Object
show all
Defined in:
lib/code0/identities/identity_provider.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeIdentityProvider

Returns a new instance of IdentityProvider.



8
9
10
# File 'lib/code0/identities/identity_provider.rb', line 8

def initialize
  @providers = {}
end

Instance Attribute Details

#providersObject (readonly)

Returns the value of attribute providers.



6
7
8
# File 'lib/code0/identities/identity_provider.rb', line 6

def providers
  @providers
end

Instance Method Details

#add_named_provider(provider_id, provider_type, config) ⇒ Object



16
17
18
19
# File 'lib/code0/identities/identity_provider.rb', line 16

def add_named_provider(provider_id, provider_type, config)
  provider = Identities::Provider.const_get(provider_type.capitalize).new(config)
  providers[provider_id] = provider
end

#add_provider(provider_type, config) ⇒ Object



12
13
14
# File 'lib/code0/identities/identity_provider.rb', line 12

def add_provider(provider_type, config)
  add_named_provider provider_type, provider_type, config
end

#load_identity(provider_id, params) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/code0/identities/identity_provider.rb', line 21

def load_identity(provider_id, params)
  provider = providers[provider_id]
  if provider.nil?
    raise Error, "Provider with id '#{provider_id}' is not configured, did you forget to use add_provider"
  end

  provider.load_identity(params)
end