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
691084c0
Commit
691084c0
authored
Nov 21, 2019
by
Giorgenes Gelatti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor job token variable names
parent
b5261197
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
10 deletions
+12
-10
ee/lib/ee/api/helpers.rb
ee/lib/ee/api/helpers.rb
+5
-3
ee/lib/ee/gitlab/auth/user_auth_finders.rb
ee/lib/ee/gitlab/auth/user_auth_finders.rb
+7
-7
No files found.
ee/lib/ee/api/helpers.rb
View file @
691084c0
...
...
@@ -140,11 +140,13 @@ module EE
end
def
job_token_authentication?
initial_current_user
&&
@
job_token_authentication
# rubocop:disable Gitlab/ModuleWithInstanceVariables
initial_current_user
&&
@
current_authenticated_job
.
present?
# rubocop:disable Gitlab/ModuleWithInstanceVariables
end
def
current_ci_job
@job_token_authentication
# Returns the job associated with the token provided for
# authentication, if any
def
current_authenticated_job
@current_authenticated_job
end
def
warden
...
...
ee/lib/ee/gitlab/auth/user_auth_finders.rb
View file @
691084c0
...
...
@@ -21,9 +21,11 @@ module EE
token
=
(
params
[
JOB_TOKEN_PARAM
]
||
env
[
JOB_TOKEN_HEADER
]).
to_s
return
unless
token
.
present?
job
=
find_job_from
_token
(
token
)
job
=
::
Ci
::
Build
.
find_by
_token
(
token
)
raise
::
Gitlab
::
Auth
::
UnauthorizedError
unless
job
@current_authenticated_job
=
job
# rubocop:disable Gitlab/ModuleWithInstanceVariables
job
.
user
end
...
...
@@ -37,7 +39,7 @@ module EE
override
:validate_access_token!
def
validate_access_token!
(
scopes:
[])
# return early if we've already authenticated via a job token
@
job_token_authentication
.
present?
||
super
# rubocop:disable Gitlab/ModuleWithInstanceVariables
@
current_authenticated_job
.
present?
||
super
# rubocop:disable Gitlab/ModuleWithInstanceVariables
end
def
scim_request?
...
...
@@ -46,19 +48,17 @@ module EE
private
def
find_job_from_token
(
token
)
@job_token_authentication
||=
::
Ci
::
Build
.
find_by_token
(
token
)
end
def
find_user_from_job_bearer_token
return
unless
route_authentication_setting
[
:job_token_allowed
]
token
=
parsed_oauth_token
return
unless
token
job
=
find_job_from
_token
(
token
)
job
=
::
Ci
::
Build
.
find_by
_token
(
token
)
return
unless
job
@current_authenticated_job
=
job
# rubocop:disable Gitlab/ModuleWithInstanceVariables
job
.
user
end
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