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
559e83d3
Commit
559e83d3
authored
Jul 16, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add LDAP support to /api/session
parent
a6cfb54c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
20 deletions
+23
-20
session.rb
lib/api/session.rb
+9
-8
auth.rb
lib/gitlab/auth.rb
+13
-0
grack_auth.rb
lib/gitlab/backend/grack_auth.rb
+1
-12
No files found.
lib/api/session.rb
View file @
559e83d3
...
...
@@ -3,18 +3,19 @@ module API
class
Session
<
Grape
::
API
# Login to get token
#
# Parameters:
# login (*required) - user login
# email (*required) - user email
# password (required) - user password
#
# Example Request:
# POST /session
post
"/session"
do
resource
=
User
.
find_for_database_authentication
(
email:
params
[
:email
])
return
unauthorized!
unless
resource
auth
=
Gitlab
::
Auth
.
new
user
=
auth
.
find
(
params
[
:email
]
||
params
[
:login
],
params
[
:password
])
if
resource
.
valid_password?
(
params
[
:password
])
present
resource
,
with:
Entities
::
UserLogin
else
unauthorized!
end
return
unauthorized!
unless
user
present
user
,
with:
Entities
::
UserLogin
end
end
end
lib/gitlab/auth.rb
View file @
559e83d3
module
Gitlab
class
Auth
def
find
(
login
,
password
)
user
=
User
.
find_by_email
(
login
)
||
User
.
find_by_username
(
login
)
if
user
.
nil?
||
user
.
ldap_user?
# Second chance - try LDAP authentication
return
nil
unless
ldap_conf
.
enabled
ldap_auth
(
login
,
password
)
else
user
if
user
.
valid_password?
(
password
)
end
end
def
find_for_ldap_auth
(
auth
,
signed_in_resource
=
nil
)
uid
=
auth
.
info
.
uid
provider
=
auth
.
provider
...
...
lib/gitlab/backend/grack_auth.rb
View file @
559e83d3
...
...
@@ -64,19 +64,8 @@ module Grack
end
def
authenticate_user
(
login
,
password
)
user
=
User
.
find_by_email
(
login
)
||
User
.
find_by_username
(
login
)
# If the provided login was not a known email or username
# then user is nil
if
user
.
nil?
||
user
.
ldap_user?
# Second chance - try LDAP authentication
return
nil
unless
ldap_conf
.
enabled
auth
=
Gitlab
::
Auth
.
new
auth
.
ldap_auth
(
login
,
password
)
else
return
user
if
user
.
valid_password?
(
password
)
end
auth
.
find
(
login
,
password
)
end
def
authorize_request
(
service
)
...
...
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