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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
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
Show 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
...
@@ -19,7 +19,7 @@ class SessionsController < Devise::SessionsController
end
end
if
Gitlab
.
config
.
ldap
.
enabled
if
Gitlab
.
config
.
ldap
.
enabled
@ldap_servers
=
Gitlab
.
config
.
ldap
.
servers
@ldap_servers
=
Gitlab
::
LDAP
::
Config
.
servers
end
end
super
super
...
...
app/views/devise/sessions/new.html.haml
View file @
6ce65a3e
...
@@ -6,13 +6,13 @@
...
@@ -6,13 +6,13 @@
%ul
.nav.nav-tabs
%ul
.nav.nav-tabs
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
%li
{
class:
(
:active
if
i
==
0
)}
%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
%li
=
link_to
'Standard'
,
'#tab-signin'
,
'data-toggle'
=>
'tab'
=
link_to
'Standard'
,
'#tab-signin'
,
'data-toggle'
=>
'tab'
.tab-content
.tab-content
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
-
@ldap_servers
.
each_with_index
do
|
server
,
i
|
%div
.tab-pane
{
id:
"tab-#{server
.provider_name
}"
,
class:
(
:active
if
i
==
0
)}
%div
.tab-pane
{
id:
"tab-#{server
['provider_name']
}"
,
class:
(
:active
if
i
==
0
)}
=
render
'devise/sessions/new_ldap'
,
provider:
server
.
provider_name
=
render
'devise/sessions/new_ldap'
,
provider:
server
[
'provider_name'
]
%div
#tab-signin
.tab-pane
%div
#tab-signin
.tab-pane
=
render
'devise/sessions/new_base'
=
render
'devise/sessions/new_base'
...
...
config/gitlab.yml.example
View file @
6ce65a3e
...
@@ -135,18 +135,16 @@ production: &base
...
@@ -135,18 +135,16 @@ production: &base
ldap:
ldap:
enabled: false
enabled: false
servers:
servers:
-
## provider id
## provider_id
#
#
# This identifier is used by GitLab to keep track of which LDAP server each
# 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
# 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
# provider
id. This identifier cannot be changed once users from the LDAP server
# have started logging in to GitLab.
# have started logging in to GitLab.
#
#
# Format: one word, using a-z (lower case) and 0-9
# Format: one word, using a-z (lower case) and 0-9
# Example: 'paris' or 'uswest2'
# Example: 'paris' or 'uswest2'
main:
provider_id: main
## label
## label
#
#
...
...
config/initializers/1_settings.rb
View file @
6ce65a3e
...
@@ -62,14 +62,16 @@ if Settings.ldap['enabled'] || Rails.env.test?
...
@@ -62,14 +62,16 @@ if Settings.ldap['enabled'] || Rails.env.test?
if
Settings
.
ldap
[
'host'
].
present?
if
Settings
.
ldap
[
'host'
].
present?
server
=
Settings
.
ldap
.
except
(
'sync_time'
)
server
=
Settings
.
ldap
.
except
(
'sync_time'
)
server
[
'label'
]
=
'LDAP'
server
[
'label'
]
=
'LDAP'
server
[
'provider_id'
]
=
''
server
[
'provider_name'
]
=
'ldap'
Settings
.
ldap
[
'servers'
]
=
[
server
]
Settings
.
ldap
[
'servers'
]
=
{
'ldap'
=>
server
}
end
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
[
'allow_username_or_email_login'
]
=
false
if
server
[
'allow_username_or_email_login'
].
nil?
server
[
'active_directory'
]
=
true
if
server
[
'active_directory'
].
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'
])
server
[
'provider_class'
]
=
OmniAuth
::
Utils
.
camelize
(
server
[
'provider_name'
])
end
end
end
end
...
...
config/initializers/7_omniauth.rb
View file @
6ce65a3e
module
OmniAuth::Strategies
module
OmniAuth::Strategies
server
=
Gitlab
.
config
.
ldap
.
servers
.
first
server
=
Gitlab
.
config
.
ldap
.
servers
.
values
.
first
const_set
(
server
.
provider_class
,
Class
.
new
(
LDAP
))
const_set
(
server
[
'provider_class'
]
,
Class
.
new
(
LDAP
))
end
end
OmniauthCallbacksController
.
class_eval
do
OmniauthCallbacksController
.
class_eval
do
server
=
Gitlab
.
config
.
ldap
.
servers
.
first
server
=
Gitlab
.
config
.
ldap
.
servers
.
values
.
first
alias_method
server
.
provider_name
,
:ldap
alias_method
server
[
'provider_name'
]
,
:ldap
end
end
\ No newline at end of file
config/initializers/devise.rb
View file @
6ce65a3e
...
@@ -205,14 +205,14 @@ Devise.setup do |config|
...
@@ -205,14 +205,14 @@ Devise.setup do |config|
# end
# end
if
Gitlab
.
config
.
ldap
.
enabled
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'
]
if
server
[
'allow_username_or_email_login'
]
email_stripping_proc
=
->
(
name
)
{
name
.
gsub
(
/@.*$/
,
''
)}
email_stripping_proc
=
->
(
name
)
{
name
.
gsub
(
/@.*$/
,
''
)}
else
else
email_stripping_proc
=
->
(
name
)
{
name
}
email_stripping_proc
=
->
(
name
)
{
name
}
end
end
config
.
omniauth
server
.
provider_name
,
config
.
omniauth
server
[
'provider_name'
]
,
host:
server
[
'host'
],
host:
server
[
'host'
],
base:
server
[
'base'
],
base:
server
[
'base'
],
uid:
server
[
'uid'
],
uid:
server
[
'uid'
],
...
...
lib/gitlab/ldap/config.rb
View file @
6ce65a3e
...
@@ -9,11 +9,11 @@ module Gitlab
...
@@ -9,11 +9,11 @@ module Gitlab
end
end
def
self
.
servers
def
self
.
servers
Gitlab
.
config
.
ldap
.
servers
Gitlab
.
config
.
ldap
.
servers
.
values
end
end
def
self
.
providers
def
self
.
providers
servers
.
map
&
:provider_name
servers
.
map
{
|
server
|
server
[
'provider_name'
]
}
end
end
def
initialize
(
provider
)
def
initialize
(
provider
)
...
@@ -75,7 +75,7 @@ module Gitlab
...
@@ -75,7 +75,7 @@ module Gitlab
end
end
def
config_for
(
provider
)
def
config_for
(
provider
)
base_config
.
servers
.
find
{
|
server
|
server
.
provider_name
==
provider
}
base_config
.
servers
.
values
.
find
{
|
server
|
server
[
'provider_name'
]
==
provider
}
end
end
def
encryption
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