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
Léo-Paul Géneau
gitlab-ce
Commits
7f031791
Commit
7f031791
authored
Nov 17, 2017
by
Francisco Lopez
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes after rebase
parent
b810f479
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
23 deletions
+6
-23
lib/api/api_guard.rb
lib/api/api_guard.rb
+1
-20
lib/gitlab/auth/user_auth_finders.rb
lib/gitlab/auth/user_auth_finders.rb
+5
-3
No files found.
lib/api/api_guard.rb
View file @
7f031791
...
@@ -39,7 +39,7 @@ module API
...
@@ -39,7 +39,7 @@ module API
# Helper Methods for Grape Endpoint
# Helper Methods for Grape Endpoint
module
HelperMethods
module
HelperMethods
include
Gitlab
::
Utils
::
StrongMemoize
include
Gitlab
::
Auth
::
UserAuthFinders
def
find_current_user!
def
find_current_user!
user
=
find_user_from_access_token
||
find_user_from_warden
user
=
find_user_from_access_token
||
find_user_from_warden
...
@@ -50,25 +50,6 @@ module API
...
@@ -50,25 +50,6 @@ module API
user
user
end
end
def
access_token
strong_memoize
(
:access_token
)
do
find_oauth_access_token
||
find_personal_access_token
end
end
def
validate_access_token!
(
scopes:
[])
return
unless
access_token
case
AccessTokenValidationService
.
new
(
access_token
,
request:
request
).
validate
(
scopes:
scopes
)
when
AccessTokenValidationService
::
INSUFFICIENT_SCOPE
raise
InsufficientScopeError
.
new
(
scopes
)
when
AccessTokenValidationService
::
EXPIRED
raise
ExpiredError
when
AccessTokenValidationService
::
REVOKED
raise
RevokedError
end
end
private
private
# An array of scopes that were registered (using `allow_access_with_scope`)
# An array of scopes that were registered (using `allow_access_with_scope`)
...
...
lib/gitlab/auth/user_auth_finders.rb
View file @
7f031791
...
@@ -19,6 +19,8 @@ module Gitlab
...
@@ -19,6 +19,8 @@ module Gitlab
end
end
module
UserAuthFinders
module
UserAuthFinders
include
Gitlab
::
Utils
::
StrongMemoize
PRIVATE_TOKEN_HEADER
=
'HTTP_PRIVATE_TOKEN'
.
freeze
PRIVATE_TOKEN_HEADER
=
'HTTP_PRIVATE_TOKEN'
.
freeze
PRIVATE_TOKEN_PARAM
=
:private_token
PRIVATE_TOKEN_PARAM
=
:private_token
...
@@ -60,9 +62,9 @@ module Gitlab
...
@@ -60,9 +62,9 @@ module Gitlab
private
private
def
access_token
def
access_token
return
@access_token
if
defined?
(
@access_token
)
strong_memoize
(
:access_token
)
do
find_oauth_access_token
||
find_personal_access_token
@access_token
=
find_oauth_access_token
||
find_personal_access_token
end
end
end
def
find_personal_access_token
def
find_personal_access_token
...
...
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