Module: Ditty::Services::Authentication

Defined in:
lib/ditty/services/authentication.rb

Class Method Summary collapse

Class Method Details

.configObject



26
27
28
# File 'lib/ditty/services/authentication.rb', line 26

def config
  default.merge Ditty::Services::Settings.values(:authentication) || {}
end

.defaultObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/ditty/services/authentication.rb', line 34

def default
  {
    identity: {
      arguments: [
        {
          fields: [:username],
          callback_path: '/auth/identity/callback',
          model: Ditty::Identity,
          on_login: Ditty::Main,
          on_registration: Ditty::Main,
          locate_conditions: ->(req) { { username: req['username'] } }
        }
      ],
    }
  }
end

.providersObject



16
17
18
# File 'lib/ditty/services/authentication.rb', line 16

def providers
  config.keys
end

.provides?(provider) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ditty/services/authentication.rb', line 30

def provides?(provider)
  providers.include? provider.to_sym
end

.setupObject



20
21
22
23
24
# File 'lib/ditty/services/authentication.rb', line 20

def setup
  providers.each do |provider|
    require "omniauth/#{provider}"
  end
end