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
Léo-Paul Géneau
gitlab-ce
Commits
71abf704
Commit
71abf704
authored
Sep 02, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move ldap auth to LDAP::User. Removed unused code
parent
6bf117c6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
40 deletions
+28
-40
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+4
-15
lib/gitlab/backend/grack_ldap.rb
lib/gitlab/backend/grack_ldap.rb
+0
-24
lib/gitlab/ldap/user.rb
lib/gitlab/ldap/user.rb
+24
-1
No files found.
lib/gitlab/auth.rb
View file @
71abf704
...
@@ -66,23 +66,12 @@ module Gitlab
...
@@ -66,23 +66,12 @@ module Gitlab
Gitlab
::
AppLogger
Gitlab
::
AppLogger
end
end
def
ldap_auth
(
login
,
password
)
# Check user against LDAP backend if user is not authenticated
# Only check with valid login and password to prevent anonymous bind results
return
nil
unless
ldap_conf
.
enabled
&&
!
login
.
blank?
&&
!
password
.
blank?
ldap
=
OmniAuth
::
LDAP
::
Adaptor
.
new
(
ldap_conf
)
ldap_user
=
ldap
.
bind_as
(
filter:
Net
::
LDAP
::
Filter
.
eq
(
ldap
.
uid
,
login
),
size:
1
,
password:
password
)
User
.
find_by_extern_uid_and_provider
(
ldap_user
.
dn
,
'ldap'
)
if
ldap_user
end
def
ldap_conf
def
ldap_conf
@ldap_conf
||=
Gitlab
.
config
.
ldap
@ldap_conf
||=
Gitlab
.
config
.
ldap
end
end
def
ldap_auth
(
login
,
password
)
Gitlab
::
LDAP
::
User
.
auth
(
login
,
password
)
end
end
end
end
end
lib/gitlab/backend/grack_ldap.rb
deleted
100644 → 0
View file @
6bf117c6
require
'omniauth-ldap'
module
Grack
module
LDAP
def
ldap_auth
(
login
,
password
)
# Check user against LDAP backend if user is not authenticated
# Only check with valid login and password to prevent anonymous bind results
return
nil
unless
ldap_conf
.
enabled
&&
!
login
.
blank?
&&
!
password
.
blank?
ldap
=
OmniAuth
::
LDAP
::
Adaptor
.
new
(
ldap_conf
)
ldap_user
=
ldap
.
bind_as
(
filter:
Net
::
LDAP
::
Filter
.
eq
(
ldap
.
uid
,
login
),
size:
1
,
password:
password
)
User
.
find_by_extern_uid_and_provider
(
ldap_user
.
dn
,
'ldap'
)
if
ldap_user
end
def
ldap_conf
@ldap_conf
||=
Gitlab
.
config
.
ldap
end
end
end
lib/gitlab/ldap/user.rb
View file @
71abf704
...
@@ -9,7 +9,7 @@ module Gitlab
...
@@ -9,7 +9,7 @@ module Gitlab
class
<<
self
class
<<
self
def
find
(
uid
,
email
)
def
find
(
uid
,
email
)
# Look for user with ldap provider and same uid
# Look for user with ldap provider and same uid
user
=
model
.
ldap
.
where
(
extern_uid:
uid
).
last
user
=
find_by_uid
(
uid
)
return
user
if
user
return
user
if
user
# Look for user with same emails
# Look for user with same emails
...
@@ -61,6 +61,25 @@ module Gitlab
...
@@ -61,6 +61,25 @@ module Gitlab
user
user
end
end
def
find_by_uid
(
uid
)
model
.
ldap
.
where
(
extern_uid:
uid
).
last
end
def
auth
(
login
,
password
)
# Check user against LDAP backend if user is not authenticated
# Only check with valid login and password to prevent anonymous bind results
return
nil
unless
ldap_conf
.
enabled
&&
login
.
present?
&&
password
.
present?
ldap
=
OmniAuth
::
LDAP
::
Adaptor
.
new
(
ldap_conf
)
ldap_user
=
ldap
.
bind_as
(
filter:
Net
::
LDAP
::
Filter
.
eq
(
ldap
.
uid
,
login
),
size:
1
,
password:
password
)
find_by_uid
(
ldap_user
.
dn
)
if
ldap_user
end
private
private
def
uid
(
auth
)
def
uid
(
auth
)
...
@@ -86,6 +105,10 @@ module Gitlab
...
@@ -86,6 +105,10 @@ module Gitlab
def
model
def
model
::
User
::
User
end
end
def
ldap_conf
Gitlab
.
config
.
ldap
end
end
end
end
end
end
end
...
...
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