Refactoring auth
This commit is contained in:
parent
621affecb5
commit
486de8c3f4
7 changed files with 91 additions and 69 deletions
|
@ -120,8 +120,16 @@ class Settings < Settingslogic
|
|||
app['backup_keep_time'] || 0
|
||||
end
|
||||
|
||||
def ldap_enabled?
|
||||
ldap['enabled']
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
def omniauth_enabled?
|
||||
omniauth['enabled'] || false
|
||||
omniauth && omniauth['enabled']
|
||||
rescue
|
||||
false
|
||||
end
|
||||
|
||||
def omniauth_providers
|
||||
|
|
|
@ -204,4 +204,21 @@ Devise.setup do |config|
|
|||
# manager.intercept_401 = false
|
||||
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
||||
# end
|
||||
|
||||
gl = Gitlab.config
|
||||
|
||||
if gl.ldap_enabled?
|
||||
config.omniauth :ldap,
|
||||
:host => gl.ldap['host'],
|
||||
:base => gl.ldap['base'],
|
||||
:uid => gl.ldap['uid'],
|
||||
:port => gl.ldap['port'],
|
||||
:method => gl.ldap['method'],
|
||||
:bind_dn => gl.ldap['bind_dn'],
|
||||
:password => gl.ldap['password']
|
||||
end
|
||||
|
||||
gl.omniauth_providers.each do |gl_provider|
|
||||
config.omniauth gl_provider['name'].to_sym, gl_provider['app_id'], gl_provider['app_secret']
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
# Copy this file to 'omniauth.rb' and configure it as necessary.
|
||||
# The wiki has further details on configuring each provider.
|
||||
|
||||
Devise.setup do |config|
|
||||
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
||||
|
||||
# config.omniauth :ldap,
|
||||
# :host => 'YOUR_LDAP_SERVER',
|
||||
# :base => 'THE_BASE_WHERE_YOU_SEARCH_FOR_USERS',
|
||||
# :uid => 'sAMAccountName',
|
||||
# :port => 389,
|
||||
# :method => :plain,
|
||||
# :bind_dn => 'THE_FULL_DN_OF_THE_USER_YOU_WILL_BIND_WITH',
|
||||
# :password => 'THE_PASSWORD_OF_THE_BIND_USER'
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue