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
Boxiang Sun
gitlab-ce
Commits
f1896575
Commit
f1896575
authored
Nov 10, 2017
by
Francisco Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added some more comments
parent
2d5397d9
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
15 deletions
+14
-15
lib/api/api_guard.rb
lib/api/api_guard.rb
+8
-7
lib/gitlab/auth/request_authenticator.rb
lib/gitlab/auth/request_authenticator.rb
+1
-1
lib/gitlab/auth/user_auth_finders.rb
lib/gitlab/auth/user_auth_finders.rb
+4
-6
spec/lib/gitlab/auth/request_authenticator_spec.rb
spec/lib/gitlab/auth/request_authenticator_spec.rb
+1
-1
No files found.
lib/api/api_guard.rb
View file @
f1896575
...
...
@@ -139,13 +139,14 @@ module API
# Exceptions
#
MissingTokenError
=
Class
.
new
(
StandardError
)
TokenNotFoundError
=
Class
.
new
(
StandardError
)
ExpiredError
=
Class
.
new
(
StandardError
)
RevokedError
=
Class
.
new
(
StandardError
)
UnauthorizedError
=
Class
.
new
(
StandardError
)
class
InsufficientScopeError
<
StandardError
AuthenticationException
=
Class
.
new
(
StandardError
)
MissingTokenError
=
Class
.
new
(
AuthenticationException
)
TokenNotFoundError
=
Class
.
new
(
AuthenticationException
)
ExpiredError
=
Class
.
new
(
AuthenticationException
)
RevokedError
=
Class
.
new
(
AuthenticationException
)
UnauthorizedError
=
Class
.
new
(
AuthenticationException
)
class
InsufficientScopeError
<
AuthenticationException
attr_reader
:scopes
def
initialize
(
scopes
)
@scopes
=
scopes
.
map
{
|
s
|
s
.
try
(
:name
)
||
s
}
...
...
lib/gitlab/auth/request_authenticator.rb
View file @
f1896575
...
...
@@ -17,7 +17,7 @@ module Gitlab
def
find_sessionless_user
find_user_from_access_token
||
find_user_from_rss_token
rescue
StandardError
rescue
API
::
APIGuard
::
AuthenticationException
nil
end
end
...
...
lib/gitlab/auth/user_auth_finders.rb
View file @
f1896575
...
...
@@ -47,13 +47,11 @@ module Gitlab
@access_token
=
find_oauth_access_token
||
find_personal_access_token
end
def
private_token
def
find_personal_access_token
token
=
current_request
.
params
[
PRIVATE_TOKEN_PARAM
].
presence
||
current_request
.
env
[
PRIVATE_TOKEN_HEADER
].
presence
end
def
find_personal_access_token
token
=
private_token
return
unless
token
# Expiration, revocation and scopes are verified in `validate_access_token!`
...
...
@@ -66,7 +64,7 @@ module Gitlab
# Expiration, revocation and scopes are verified in `validate_access_token!`
oauth_token
=
OauthAccessToken
.
by_token
(
token
)
raise
(
API
::
APIGuard
::
UnauthorizedError
)
unless
oauth_token
raise
API
::
APIGuard
::
UnauthorizedError
unless
oauth_token
oauth_token
.
revoke_previous_refresh_token!
oauth_token
...
...
spec/lib/gitlab/auth/request_authenticator_spec.rb
View file @
f1896575
...
...
@@ -58,7 +58,7 @@ describe Gitlab::Auth::RequestAuthenticator do
expect
(
subject
.
find_sessionless_user
).
to
be_blank
end
it
'rescue
StandardError
exceptions'
do
it
'rescue
API::APIGuard::AuthenticationException
exceptions'
do
allow_any_instance_of
(
described_class
).
to
receive
(
:find_user_from_access_token
).
and_raise
(
API
::
APIGuard
::
UnauthorizedError
)
expect
(
subject
.
find_sessionless_user
).
to
be_blank
...
...
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