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
Jérome Perrin
gitlab-ce
Commits
fea591e5
Commit
fea591e5
authored
Jun 02, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename finder to find_in_gitlab_or_ldap
parent
8299fc27
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
13 additions
and
13 deletions
+13
-13
config/initializers/doorkeeper.rb
config/initializers/doorkeeper.rb
+1
-1
lib/api/session.rb
lib/api/session.rb
+1
-1
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+2
-2
lib/gitlab/backend/grack_auth.rb
lib/gitlab/backend/grack_auth.rb
+1
-1
spec/lib/gitlab/auth_spec.rb
spec/lib/gitlab/auth_spec.rb
+8
-8
No files found.
config/initializers/doorkeeper.rb
View file @
fea591e5
...
...
@@ -12,7 +12,7 @@ Doorkeeper.configure do
end
resource_owner_from_credentials
do
|
routes
|
Gitlab
::
Auth
.
find_
by_master
_or_ldap
(
params
[
:username
],
params
[
:password
])
Gitlab
::
Auth
.
find_
in_gitlab
_or_ldap
(
params
[
:username
],
params
[
:password
])
end
# If you want to restrict access to the web interface for adding oauth authorized applications, you need to declare the block below.
...
...
lib/api/session.rb
View file @
fea591e5
...
...
@@ -11,7 +11,7 @@ module API
# Example Request:
# POST /session
post
"/session"
do
user
=
Gitlab
::
Auth
.
find_
by_master
_or_ldap
(
params
[
:email
]
||
params
[
:login
],
params
[
:password
])
user
=
Gitlab
::
Auth
.
find_
in_gitlab
_or_ldap
(
params
[
:email
]
||
params
[
:login
],
params
[
:password
])
return
unauthorized!
unless
user
present
user
,
with:
Entities
::
UserLogin
...
...
lib/gitlab/auth.rb
View file @
fea591e5
...
...
@@ -9,7 +9,7 @@ module Gitlab
if
valid_ci_request?
(
login
,
password
,
project
)
type
=
:ci
elsif
user
=
find_
by_master
_or_ldap
(
login
,
password
)
elsif
user
=
find_
in_gitlab
_or_ldap
(
login
,
password
)
type
=
:master_or_ldap
elsif
user
=
oauth_access_token_check
(
login
,
password
)
type
=
:oauth
...
...
@@ -19,7 +19,7 @@ module Gitlab
[
user
,
type
]
end
def
find_
by_master
_or_ldap
(
login
,
password
)
def
find_
in_gitlab
_or_ldap
(
login
,
password
)
user
=
User
.
by_login
(
login
)
# If no user is found, or it's an LDAP server, try LDAP.
...
...
lib/gitlab/backend/grack_auth.rb
View file @
fea591e5
...
...
@@ -95,7 +95,7 @@ module Grack
end
def
authenticate_user
(
login
,
password
)
user
=
Gitlab
::
Auth
.
new
.
find_
by_master
_or_ldap
(
login
,
password
)
user
=
Gitlab
::
Auth
.
new
.
find_
in_gitlab
_or_ldap
(
login
,
password
)
unless
user
user
=
oauth_access_token_check
(
login
,
password
)
...
...
spec/lib/gitlab/auth_spec.rb
View file @
fea591e5
...
...
@@ -41,7 +41,7 @@ describe Gitlab::Auth, lib: true do
end
end
describe
'find_
by_master
_or_ldap'
do
describe
'find_
in_gitlab
_or_ldap'
do
let!
(
:user
)
do
create
(
:user
,
username:
username
,
...
...
@@ -52,25 +52,25 @@ describe Gitlab::Auth, lib: true do
let
(
:password
)
{
'my-secret'
}
it
"should find user by valid login/password"
do
expect
(
gl_auth
.
find_
by_master
_or_ldap
(
username
,
password
)
).
to
eql
user
expect
(
gl_auth
.
find_
in_gitlab
_or_ldap
(
username
,
password
)
).
to
eql
user
end
it
'should find user by valid email/password with case-insensitive email'
do
expect
(
gl_auth
.
find_
by_master
_or_ldap
(
user
.
email
.
upcase
,
password
)).
to
eql
user
expect
(
gl_auth
.
find_
in_gitlab
_or_ldap
(
user
.
email
.
upcase
,
password
)).
to
eql
user
end
it
'should find user by valid username/password with case-insensitive username'
do
expect
(
gl_auth
.
find_
by_master
_or_ldap
(
username
.
upcase
,
password
)).
to
eql
user
expect
(
gl_auth
.
find_
in_gitlab
_or_ldap
(
username
.
upcase
,
password
)).
to
eql
user
end
it
"should not find user with invalid password"
do
password
=
'wrong'
expect
(
gl_auth
.
find_
by_master
_or_ldap
(
username
,
password
)
).
not_to
eql
user
expect
(
gl_auth
.
find_
in_gitlab
_or_ldap
(
username
,
password
)
).
not_to
eql
user
end
it
"should not find user with invalid login"
do
user
=
'wrong'
expect
(
gl_auth
.
find_
by_master
_or_ldap
(
username
,
password
)
).
not_to
eql
user
expect
(
gl_auth
.
find_
in_gitlab
_or_ldap
(
username
,
password
)
).
not_to
eql
user
end
context
"with ldap enabled"
do
...
...
@@ -81,13 +81,13 @@ describe Gitlab::Auth, lib: true do
it
"tries to autheticate with db before ldap"
do
expect
(
Gitlab
::
LDAP
::
Authentication
).
not_to
receive
(
:login
)
gl_auth
.
find_
by_master
_or_ldap
(
username
,
password
)
gl_auth
.
find_
in_gitlab
_or_ldap
(
username
,
password
)
end
it
"uses ldap as fallback to for authentication"
do
expect
(
Gitlab
::
LDAP
::
Authentication
).
to
receive
(
:login
)
gl_auth
.
find_
by_master
_or_ldap
(
'ldap_user'
,
'password'
)
gl_auth
.
find_
in_gitlab
_or_ldap
(
'ldap_user'
,
'password'
)
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