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
dc296854
Commit
dc296854
authored
Sep 19, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly support Gitlab::Auth::Result
parent
6d43c95b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
8 deletions
+8
-8
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+7
-7
lib/gitlab/auth/result.rb
lib/gitlab/auth/result.rb
+1
-1
No files found.
lib/gitlab/auth.rb
View file @
dc296854
...
...
@@ -12,7 +12,7 @@ module Gitlab
user_with_password_for_git
(
login
,
password
)
||
oauth_access_token_check
(
login
,
password
)
||
personal_access_token_check
(
login
,
password
)
||
Result
.
new
Gitlab
::
Auth
::
Result
.
new
rate_limit!
(
ip
,
success:
result
.
success?
,
login:
login
)
...
...
@@ -70,7 +70,7 @@ module Gitlab
service
=
project
.
public_send
(
"
#{
underscored_service
}
_service"
)
if
service
&&
service
.
activated?
&&
service
.
valid_token?
(
password
)
Result
.
new
(
nil
,
project
,
:ci
,
build_authentication_abilities
)
Gitlab
::
Auth
::
Result
.
new
(
nil
,
project
,
:ci
,
build_authentication_abilities
)
end
end
end
...
...
@@ -81,7 +81,7 @@ module Gitlab
raise
Gitlab
::
Auth
::
MissingPersonalTokenError
if
user
.
two_factor_enabled?
Result
.
new
(
user
,
nil
,
:gitlab_or_ldap
,
full_authentication_abilities
)
Gitlab
::
Auth
::
Result
.
new
(
user
,
nil
,
:gitlab_or_ldap
,
full_authentication_abilities
)
end
def
oauth_access_token_check
(
login
,
password
)
...
...
@@ -89,7 +89,7 @@ module Gitlab
token
=
Doorkeeper
::
AccessToken
.
by_token
(
password
)
if
token
&&
token
.
accessible?
user
=
User
.
find_by
(
id:
token
.
resource_owner_id
)
Result
.
new
(
user
,
nil
,
:oauth
,
read_authentication_abilities
)
Gitlab
::
Auth
::
Result
.
new
(
user
,
nil
,
:oauth
,
read_authentication_abilities
)
end
end
end
...
...
@@ -98,7 +98,7 @@ module Gitlab
if
login
&&
password
user
=
User
.
find_by_personal_access_token
(
password
)
validation
=
User
.
by_login
(
login
)
Result
.
new
(
user
,
nil
,
:personal_token
,
full_authentication_abilities
)
if
user
.
present?
&&
user
==
validation
Gitlab
::
Auth
::
Result
.
new
(
user
,
nil
,
:personal_token
,
full_authentication_abilities
)
if
user
.
present?
&&
user
==
validation
end
end
...
...
@@ -112,10 +112,10 @@ module Gitlab
if
build
.
user
# If user is assigned to build, use restricted credentials of user
Result
.
new
(
build
.
user
,
build
.
project
,
:build
,
build_authentication_abilities
)
Gitlab
::
Auth
::
Result
.
new
(
build
.
user
,
build
.
project
,
:build
,
build_authentication_abilities
)
else
# Otherwise use generic CI credentials (backward compatibility)
Result
.
new
(
nil
,
build
.
project
,
:ci
,
build_authentication_abilities
)
Gitlab
::
Auth
::
Result
.
new
(
nil
,
build
.
project
,
:ci
,
build_authentication_abilities
)
end
end
...
...
lib/gitlab/auth/result.rb
View file @
dc296854
module
Gitlab
module
Auth
Result
=
Struct
.
new
(
:actor
,
:project
,
:type
,
:authentication_abilities
)
do
class
Result
<
Struct
.
new
(
:actor
,
:project
,
:type
,
:authentication_abilities
)
def
ci?
type
==
:ci
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