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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
173e17e5
Commit
173e17e5
authored
Feb 05, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce EE::API::APIGuard::HelperMethods
parent
8f4b6e2e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
ee/lib/ee/api/api_guard.rb
ee/lib/ee/api/api_guard.rb
+16
-0
lib/api/api_guard.rb
lib/api/api_guard.rb
+6
-1
No files found.
ee/lib/ee/api/api_guard.rb
0 → 100644
View file @
173e17e5
module
EE
module
API
module
APIGuard
module
HelperMethods
extend
::
Gitlab
::
Utils
::
Override
override
:find_user_from_sources
def
find_user_from_sources
find_user_from_access_token
||
find_user_from_job_token
||
find_user_from_warden
end
end
end
end
end
lib/api/api_guard.rb
View file @
173e17e5
...
...
@@ -39,10 +39,11 @@ module API
# Helper Methods for Grape Endpoint
module
HelperMethods
prepend
EE
::
API
::
APIGuard
::
HelperMethods
include
Gitlab
::
Auth
::
UserAuthFinders
def
find_current_user!
user
=
find_user_from_
access_token
||
find_user_from_job_token
||
find_user_from_warden
user
=
find_user_from_
sources
return
unless
user
forbidden!
(
'User is blocked'
)
unless
Gitlab
::
UserAccess
.
new
(
user
).
allowed?
&&
user
.
can?
(
:access_api
)
...
...
@@ -50,6 +51,10 @@ module API
user
end
def
find_user_from_sources
find_user_from_access_token
||
find_user_from_warden
end
private
# An array of scopes that were registered (using `allow_access_with_scope`)
...
...
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