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
cf6a35f0
Commit
cf6a35f0
authored
Sep 20, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve JwtController implementation
parent
0672c5a9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
8 deletions
+11
-8
app/controllers/jwt_controller.rb
app/controllers/jwt_controller.rb
+3
-3
app/services/auth/container_registry_authentication_service.rb
...ervices/auth/container_registry_authentication_service.rb
+1
-1
lib/ci/mask_secret.rb
lib/ci/mask_secret.rb
+2
-1
spec/lib/ci/mask_secret_spec.rb
spec/lib/ci/mask_secret_spec.rb
+5
-3
No files found.
app/controllers/jwt_controller.rb
View file @
cf6a35f0
...
...
@@ -11,10 +11,8 @@ class JwtController < ApplicationController
service
=
SERVICES
[
params
[
:service
]]
return
head
:not_found
unless
service
@authentication_result
||=
Gitlab
::
Auth
::
Result
.
new
result
=
service
.
new
(
@authentication_result
.
project
,
@authentication_result
.
actor
,
auth_params
).
execute
(
authentication_abilities:
@authentication_result
.
authentication_abilities
)
execute
(
authentication_abilities:
@authentication_result
.
authentication_abilities
||
[]
)
render
json:
result
,
status:
result
[
:http_status
]
end
...
...
@@ -22,6 +20,8 @@ class JwtController < ApplicationController
private
def
authenticate_project_or_user
@authentication_result
=
Gitlab
::
Auth
::
Result
.
new
authenticate_with_http_basic
do
|
login
,
password
|
@authentication_result
=
Gitlab
::
Auth
.
find_for_git_client
(
login
,
password
,
project:
nil
,
ip:
request
.
ip
)
...
...
app/services/auth/container_registry_authentication_service.rb
View file @
cf6a35f0
...
...
@@ -5,7 +5,7 @@ module Auth
AUDIENCE
=
'container_registry'
def
execute
(
authentication_abilities
:)
@authentication_abilities
=
authentication_abilities
||
[]
@authentication_abilities
=
authentication_abilities
return
error
(
'not found'
,
404
)
unless
registry
.
enabled
...
...
lib/ci/mask_secret.rb
View file @
cf6a35f0
module
Ci::MaskSecret
class
<<
self
def
mask!
(
value
,
token
)
return
unless
value
.
present?
&&
token
.
present?
return
value
unless
value
.
present?
&&
token
.
present?
value
.
gsub!
(
token
,
'x'
*
token
.
length
)
value
end
end
end
spec/lib/ci/mask_secret_spec.rb
View file @
cf6a35f0
...
...
@@ -16,10 +16,12 @@ describe Ci::MaskSecret, lib: true do
expect
(
mask
(
'token'
,
'not'
)).
to
eq
(
'token'
)
end
it
'does support null token'
do
expect
(
mask
(
'token'
,
nil
)).
to
eq
(
'token'
)
end
def
mask
(
value
,
token
)
value
=
value
.
dup
subject
.
mask!
(
value
,
token
)
value
subject
.
mask!
(
value
.
dup
,
token
)
end
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