Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
e1cf9c15
Commit
e1cf9c15
authored
Oct 13, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Apply configuration changes for Multiple LDAP servers
parent
3cd5abf6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
16 deletions
+36
-16
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+16
-2
config/initializers/7_omniauth.rb
config/initializers/7_omniauth.rb
+4
-0
config/initializers/devise.rb
config/initializers/devise.rb
+16
-14
No files found.
config/initializers/1_settings.rb
View file @
e1cf9c15
...
@@ -56,9 +56,23 @@ end
...
@@ -56,9 +56,23 @@ end
# Default settings
# Default settings
Settings
[
'ldap'
]
||=
Settingslogic
.
new
({})
Settings
[
'ldap'
]
||=
Settingslogic
.
new
({})
Settings
.
ldap
[
'enabled'
]
=
false
if
Settings
.
ldap
[
'enabled'
].
nil?
Settings
.
ldap
[
'enabled'
]
=
false
if
Settings
.
ldap
[
'enabled'
].
nil?
Settings
.
ldap
[
'allow_username_or_email_login'
]
=
false
if
Settings
.
ldap
[
'allow_username_or_email_login'
].
nil?
Settings
.
ldap
[
'active_directory'
]
=
true
if
Settings
.
ldap
[
'active_directory'
].
nil?
# backwards compatibility, we only have one host
if
Settings
.
ldap
[
'enabled'
]
||
Rails
.
env
.
test?
if
Settings
.
ldap
[
'host'
].
present?
server
=
Settings
.
ldap
.
except
(
'sync_time'
)
server
[
'label'
]
=
'LDAP'
server
[
'provider_id'
]
=
''
Settings
.
ldap
[
'servers'
]
=
[
server
]
end
Settings
.
ldap
[
'servers'
].
each
do
|
server
|
server
[
'allow_username_or_email_login'
]
=
false
if
server
[
'allow_username_or_email_login'
].
nil?
server
[
'active_directory'
]
=
true
if
server
[
'active_directory'
].
nil?
server
[
'provider_name'
]
=
"ldap
#{
server
[
'provider_id'
]
}
"
.
downcase
server
[
'provider_class'
]
=
OmniAuth
::
Utils
.
camelize
(
server
[
'provider_name'
])
end
end
Settings
[
'omniauth'
]
||=
Settingslogic
.
new
({})
Settings
[
'omniauth'
]
||=
Settingslogic
.
new
({})
Settings
.
omniauth
[
'enabled'
]
=
false
if
Settings
.
omniauth
[
'enabled'
].
nil?
Settings
.
omniauth
[
'enabled'
]
=
false
if
Settings
.
omniauth
[
'enabled'
].
nil?
...
...
config/initializers/7_omniauth.rb
0 → 100644
View file @
e1cf9c15
module
OmniAuth::Strategies
server
=
Gitlab
.
config
.
ldap
.
servers
.
first
const_set
(
server
.
provider_class
,
Class
.
new
(
LDAP
))
end
config/initializers/devise.rb
View file @
e1cf9c15
...
@@ -205,21 +205,23 @@ Devise.setup do |config|
...
@@ -205,21 +205,23 @@ Devise.setup do |config|
# end
# end
if
Gitlab
.
config
.
ldap
.
enabled
if
Gitlab
.
config
.
ldap
.
enabled
if
Gitlab
.
config
.
ldap
.
allow_username_or_email_login
Gitlab
.
config
.
ldap
.
servers
.
each
do
|
server
|
email_stripping_proc
=
->
(
name
)
{
name
.
gsub
(
/@.*$/
,
''
)}
if
server
[
'allow_username_or_email_login'
]
else
email_stripping_proc
=
->
(
name
)
{
name
.
gsub
(
/@.*$/
,
''
)}
email_stripping_proc
=
->
(
name
)
{
name
}
else
email_stripping_proc
=
->
(
name
)
{
name
}
end
config
.
omniauth
server
.
provider_name
,
host:
server
[
'host'
],
base:
server
[
'base'
],
uid:
server
[
'uid'
],
port:
server
[
'port'
],
method:
server
[
'method'
],
bind_dn:
server
[
'bind_dn'
],
password:
server
[
'password'
],
name_proc:
email_stripping_proc
end
end
config
.
omniauth
:ldap
,
host:
Gitlab
.
config
.
ldap
[
'host'
],
base:
Gitlab
.
config
.
ldap
[
'base'
],
uid:
Gitlab
.
config
.
ldap
[
'uid'
],
port:
Gitlab
.
config
.
ldap
[
'port'
],
method:
Gitlab
.
config
.
ldap
[
'method'
],
bind_dn:
Gitlab
.
config
.
ldap
[
'bind_dn'
],
password:
Gitlab
.
config
.
ldap
[
'password'
],
name_proc:
email_stripping_proc
end
end
Gitlab
.
config
.
omniauth
.
providers
.
each
do
|
provider
|
Gitlab
.
config
.
omniauth
.
providers
.
each
do
|
provider
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment