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
6ce65a3e
Commit
6ce65a3e
authored
Oct 14, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Hash syntax for LDAP server declaration
parent
9bf7bfda
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
29 deletions
+29
-29
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+1
-1
app/views/devise/sessions/new.html.haml
app/views/devise/sessions/new.html.haml
+3
-3
config/gitlab.yml.example
config/gitlab.yml.example
+10
-12
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+6
-4
config/initializers/7_omniauth.rb
config/initializers/7_omniauth.rb
+4
-4
config/initializers/devise.rb
config/initializers/devise.rb
+2
-2
lib/gitlab/ldap/config.rb
lib/gitlab/ldap/config.rb
+3
-3
No files found.
app/controllers/sessions_controller.rb
View file @
6ce65a3e
...
...
@@ -19,7 +19,7 @@ class SessionsController < Devise::SessionsController
end
if
Gitlab
.
config
.
ldap
.
enabled
@ldap_servers
=
Gitlab
.
config
.
ldap
.
servers
@ldap_servers
=
Gitlab
::
LDAP
::
Config
.
servers
end
super
...
...
app/views/devise/sessions/new.html.haml
View file @
6ce65a3e
...
...
@@ -6,13 +6,13 @@
%ul
.nav.nav-tabs
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
%li
{
class:
(
:active
if
i
==
0
)}
=
link_to
server
[
'label'
],
"#tab-
#{
server
.
provider_name
}
"
,
'data-toggle'
=>
'tab'
=
link_to
server
[
'label'
],
"#tab-
#{
server
[
'provider_name'
]
}
"
,
'data-toggle'
=>
'tab'
%li
=
link_to
'Standard'
,
'#tab-signin'
,
'data-toggle'
=>
'tab'
.tab-content
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
%div
.tab-pane
{
id:
"tab-#{server
.provider_name
}"
,
class:
(
:active
if
i
==
0
)}
=
render
'devise/sessions/new_ldap'
,
provider:
server
.
provider_name
%div
.tab-pane
{
id:
"tab-#{server
['provider_name']
}"
,
class:
(
:active
if
i
==
0
)}
=
render
'devise/sessions/new_ldap'
,
provider:
server
[
'provider_name'
]
%div
#tab-signin
.tab-pane
=
render
'devise/sessions/new_base'
...
...
config/gitlab.yml.example
View file @
6ce65a3e
...
...
@@ -135,18 +135,16 @@ production: &base
ldap:
enabled: false
servers:
-
## provider_id
#
# This identifier is used by GitLab to keep track of which LDAP server each
# GitLab user belongs to. Each LDAP server known to GitLab should have a unique
# provider_id. This identifier cannot be changed once users from the LDAP server
# have started logging in to GitLab.
#
# Format: one word, using a-z (lower case) and 0-9
# Example: 'paris' or 'uswest2'
provider_id: main
## provider id
#
# This identifier is used by GitLab to keep track of which LDAP server each
# GitLab user belongs to. Each LDAP server known to GitLab should have a unique
# provider id. This identifier cannot be changed once users from the LDAP server
# have started logging in to GitLab.
#
# Format: one word, using a-z (lower case) and 0-9
# Example: 'paris' or 'uswest2'
main:
## label
#
...
...
config/initializers/1_settings.rb
View file @
6ce65a3e
...
...
@@ -62,14 +62,16 @@ 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
]
server
[
'provider_name'
]
=
'ldap'
Settings
.
ldap
[
'servers'
]
=
{
'ldap'
=>
server
}
end
Settings
.
ldap
[
'servers'
].
each
do
|
server
|
Settings
.
ldap
[
'servers'
].
each
do
|
key
,
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_name'
]
||=
"ldap
#{
key
}
"
.
downcase
server
[
'provider_class'
]
=
OmniAuth
::
Utils
.
camelize
(
server
[
'provider_name'
])
end
end
...
...
config/initializers/7_omniauth.rb
View file @
6ce65a3e
module
OmniAuth::Strategies
server
=
Gitlab
.
config
.
ldap
.
servers
.
first
const_set
(
server
.
provider_class
,
Class
.
new
(
LDAP
))
server
=
Gitlab
.
config
.
ldap
.
servers
.
values
.
first
const_set
(
server
[
'provider_class'
]
,
Class
.
new
(
LDAP
))
end
OmniauthCallbacksController
.
class_eval
do
server
=
Gitlab
.
config
.
ldap
.
servers
.
first
alias_method
server
.
provider_name
,
:ldap
server
=
Gitlab
.
config
.
ldap
.
servers
.
values
.
first
alias_method
server
[
'provider_name'
]
,
:ldap
end
\ No newline at end of file
config/initializers/devise.rb
View file @
6ce65a3e
...
...
@@ -205,14 +205,14 @@ Devise.setup do |config|
# end
if
Gitlab
.
config
.
ldap
.
enabled
Gitlab
.
config
.
ldap
.
servers
.
each
do
|
server
|
Gitlab
.
config
.
ldap
.
servers
.
values
.
each
do
|
server
|
if
server
[
'allow_username_or_email_login'
]
email_stripping_proc
=
->
(
name
)
{
name
.
gsub
(
/@.*$/
,
''
)}
else
email_stripping_proc
=
->
(
name
)
{
name
}
end
config
.
omniauth
server
.
provider_name
,
config
.
omniauth
server
[
'provider_name'
]
,
host:
server
[
'host'
],
base:
server
[
'base'
],
uid:
server
[
'uid'
],
...
...
lib/gitlab/ldap/config.rb
View file @
6ce65a3e
...
...
@@ -9,11 +9,11 @@ module Gitlab
end
def
self
.
servers
Gitlab
.
config
.
ldap
.
servers
Gitlab
.
config
.
ldap
.
servers
.
values
end
def
self
.
providers
servers
.
map
&
:provider_name
servers
.
map
{
|
server
|
server
[
'provider_name'
]
}
end
def
initialize
(
provider
)
...
...
@@ -75,7 +75,7 @@ module Gitlab
end
def
config_for
(
provider
)
base_config
.
servers
.
find
{
|
server
|
server
.
provider_name
==
provider
}
base_config
.
servers
.
values
.
find
{
|
server
|
server
[
'provider_name'
]
==
provider
}
end
def
encryption
...
...
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