class Kadmin::Auth::Configuration
Constants
- OAuthCredentials
Attributes
oauth_credentials[RW]
@return [Kadmin::Auth::Configuration::OAuthCredentials] credentials for OAuth2 authentication; if absent, fallback to :developer provider
user_class[RW]
@return [Class<Kadmin::Auth::User>] class to use for authenticated users (mostly for resource authorization)
user_store_class[RW]
@return [Class<Kadmin::Auth::UserStore>] class for user lookup/registration
Public Class Methods
new()
click to toggle source
# 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
Public Instance Methods
disable!()
click to toggle source
Disables authentication and removes OmniAuth middlewares
# File lib/kadmin/auth/configuration.rb, line 37 def disable! @enabled = false end
enable!()
click to toggle source
Enables authentication and adds OmniAuth middlewares
# File lib/kadmin/auth/configuration.rb, line 29 def enable! unless @enabled append_omniauth_middleware @enabled = true end end
enabled?()
click to toggle source
@return [Boolean] true if enabled, false otherwise
# File lib/kadmin/auth/configuration.rb, line 24 def enabled? return @enabled end
Private Instance Methods
append_omniauth_middleware()
click to toggle source
# File lib/kadmin/auth/configuration.rb, line 41 def append_omniauth_middleware return if @__omniauth_appended @__omniauth_appended = true OmniAuth.config.logger = Kadmin.logger OmniAuth.config.path_prefix = File.join(Kadmin.config.mount_path, OmniAuth.config.path_prefix) provider_args = case Kadmin::Auth.omniauth_provider when :google_oauth2 [:google_oauth2, @oauth_credentials.id, @oauth_credentials.secret] else [:developer, fields: [:email]] end Rails.application.config.middleware.use OmniAuth::Builder do provider(*provider_args) end end