Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
fea591e5
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fea591e5
编写于
6月 02, 2016
作者:
J
Jacob Vosmaer
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename finder to find_in_gitlab_or_ldap
上级
8299fc27
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
13 addition
and
13 deletion
+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
未找到文件。
config/initializers/doorkeeper.rb
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录