BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
1ec106b8
Unverified
Commit
1ec106b8
authored
Mar 14, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ldap_connections'
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
Conflicts: CHANGELOG
parents
bce8edbb
48e90540
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
17 deletions
+48
-17
CHANGELOG
CHANGELOG
+1
-0
application_controller.rb
app/controllers/application_controller.rb
+11
-9
access.rb
lib/gitlab/ldap/access.rb
+13
-1
adapter.rb
lib/gitlab/ldap/adapter.rb
+17
-3
person.rb
lib/gitlab/ldap/person.rb
+6
-4
No files found.
CHANGELOG
View file @
1ec106b8
...
...
@@ -18,6 +18,7 @@ v 6.7.0
- Add webhook when a new tag is pushed (Jeroen van Baarsen)
- Add button for toggling inline comments in diff view
- Add retry feature for repository import
- Reuse the GitLab LDAP connection within each request
v 6.6.2
- Fix 500 error on branch/tag create or remove via UI
...
...
app/controllers/application_controller.rb
View file @
1ec106b8
...
...
@@ -182,13 +182,15 @@ class ApplicationController < ActionController::Base
def
ldap_security_check
if
current_user
&&
current_user
.
requires_ldap_check?
if
gitlab_ldap_access
.
allowed?
(
current_user
)
current_user
.
last_credential_check_at
=
Time
.
now
current_user
.
save
else
sign_out
current_user
flash
[
:alert
]
=
"Access denied for your LDAP account."
redirect_to
new_user_session_path
gitlab_ldap_access
do
|
access
|
if
access
.
allowed?
(
current_user
)
current_user
.
last_credential_check_at
=
Time
.
now
current_user
.
save
else
sign_out
current_user
flash
[
:alert
]
=
"Access denied for your LDAP account."
redirect_to
new_user_session_path
end
end
end
end
...
...
@@ -198,8 +200,8 @@ class ApplicationController < ActionController::Base
@event_filter
||=
EventFilter
.
new
(
filters
)
end
def
gitlab_ldap_access
Gitlab
::
LDAP
::
Access
.
new
def
gitlab_ldap_access
(
&
block
)
Gitlab
::
LDAP
::
Access
.
open
{
|
access
|
block
.
call
(
access
)
}
end
# JSON for infinite scroll via Pager object
...
...
lib/gitlab/ldap/access.rb
View file @
1ec106b8
module
Gitlab
module
LDAP
class
Access
attr_reader
:adapter
def
self
.
open
(
&
block
)
Gitlab
::
LDAP
::
Adapter
.
open
do
|
adapter
|
block
.
call
(
self
.
new
(
adapter
))
end
end
def
initialize
(
adapter
=
nil
)
@adapter
=
adapter
end
def
allowed?
(
user
)
!!
Gitlab
::
LDAP
::
Person
.
find_by_dn
(
user
.
extern_uid
)
!!
Gitlab
::
LDAP
::
Person
.
find_by_dn
(
user
.
extern_uid
,
adapter
)
rescue
false
end
...
...
lib/gitlab/ldap/adapter.rb
View file @
1ec106b8
...
...
@@ -3,7 +3,17 @@ module Gitlab
class
Adapter
attr_reader
:ldap
def
initialize
def
self
.
open
(
&
block
)
Net
::
LDAP
.
open
(
adapter_options
)
do
|
ldap
|
block
.
call
(
self
.
new
(
ldap
))
end
end
def
self
.
config
Gitlab
.
config
.
ldap
end
def
self
.
adapter_options
encryption
=
config
[
'method'
].
to_s
==
'ssl'
?
:
simple_tls
:
nil
options
=
{
...
...
@@ -23,8 +33,12 @@ module Gitlab
if
config
[
'password'
]
||
config
[
'bind_dn'
]
options
.
merge!
(
auth_options
)
end
options
end
@ldap
=
Net
::
LDAP
.
new
(
options
)
def
initialize
(
ldap
=
nil
)
@ldap
=
ldap
||
Net
::
LDAP
.
new
(
self
.
class
.
adapter_options
)
end
def
users
(
field
,
value
)
...
...
@@ -65,7 +79,7 @@ module Gitlab
private
def
config
@config
||=
Gitlab
.
config
.
ldap
@config
||=
self
.
class
.
config
end
end
end
...
...
lib/gitlab/ldap/person.rb
View file @
1ec106b8
module
Gitlab
module
LDAP
class
Person
def
self
.
find_by_uid
(
uid
)
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
config
.
uid
,
uid
)
def
self
.
find_by_uid
(
uid
,
adapter
=
nil
)
adapter
||=
Gitlab
::
LDAP
::
Adapter
.
new
adapter
.
user
(
config
.
uid
,
uid
)
end
def
self
.
find_by_dn
(
dn
)
Gitlab
::
LDAP
::
Adapter
.
new
.
user
(
'dn'
,
dn
)
def
self
.
find_by_dn
(
dn
,
adapter
=
nil
)
adapter
||=
Gitlab
::
LDAP
::
Adapter
.
new
adapter
.
user
(
'dn'
,
dn
)
end
def
initialize
(
entry
)
...
...
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