Class: Kadmin::Auth::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/kadmin/auth/configuration.rb

Defined Under Namespace

Classes: OAuthCredentials

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



15
16
17
18
19
20
21
# File 'lib/kadmin/auth/configuration.rb', line 15

def initialize
  @oauth_credentials = nil
  @user_class = Kadmin::Auth::User
  @user_store_class = Kadmin::Auth::UserStore
  @enabled = false
  @__omniauth_appended = false
end

Instance Attribute Details

#oauth_credentialsKadmin::Auth::Configuration::OAuthCredentials

Returns credentials for OAuth2 authentication; if absent, fallback to :developer provider.

Returns:



7
8
9
# File 'lib/kadmin/auth/configuration.rb', line 7

def oauth_credentials
  @oauth_credentials
end

#user_classClass<Kadmin::Auth::User>

Returns class to use for authenticated users (mostly for resource authorization).

Returns:

  • (Class<Kadmin::Auth::User>)

    class to use for authenticated users (mostly for resource authorization)



10
11
12
# File 'lib/kadmin/auth/configuration.rb', line 10

def user_class
  @user_class
end

#user_store_classClass<Kadmin::Auth::UserStore>

Returns class for user lookup/registration.

Returns:



13
14
15
# File 'lib/kadmin/auth/configuration.rb', line 13

def user_store_class
  @user_store_class
end

Instance Method Details

#disable!Object

Disables authentication and removes OmniAuth middlewares



37
38
39
# File 'lib/kadmin/auth/configuration.rb', line 37

def disable!
  @enabled = false
end

#enable!Object

Enables authentication and adds OmniAuth middlewares



29
30
31
32
33
34
# File 'lib/kadmin/auth/configuration.rb', line 29

def enable!
  unless @enabled
    append_omniauth_middleware
    @enabled = true
  end
end

#enabled?Boolean

Returns true if enabled, false otherwise.

Returns:

  • (Boolean)

    true if enabled, false otherwise



24
25
26
# File 'lib/kadmin/auth/configuration.rb', line 24

def enabled?
  return @enabled
end