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
74d37438
Commit
74d37438
authored
Oct 08, 2017
by
Vratislav Kalenda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue JWT token with registry:catalog:* scope when requested by GitLab admin
parent
91f1d652
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
0 deletions
+55
-0
app/services/auth/container_registry_authentication_service.rb
...ervices/auth/container_registry_authentication_service.rb
+5
-0
changelogs/unreleased/26763-grant-registry-auth-scope-to-admins.yml
.../unreleased/26763-grant-registry-auth-scope-to-admins.yml
+5
-0
spec/services/auth/container_registry_authentication_service_spec.rb
...es/auth/container_registry_authentication_service_spec.rb
+45
-0
No files found.
app/services/auth/container_registry_authentication_service.rb
View file @
74d37438
...
...
@@ -58,6 +58,11 @@ module Auth
actions
=
actions
.
split
(
','
)
path
=
ContainerRegistry
::
Path
.
new
(
name
)
if
type
==
'registry'
&&
name
==
'catalog'
&&
current_user
&&
current_user
.
admin?
return
{
type:
type
,
name:
name
,
actions:
[
'*'
]
}
end
return
unless
type
==
'repository'
process_repository_access
(
type
,
path
,
actions
)
...
...
changelogs/unreleased/26763-grant-registry-auth-scope-to-admins.yml
0 → 100644
View file @
74d37438
---
title
:
Issue JWT token with registry:catalog:* scope when requested by GitLab admin
merge_request
:
author
:
type
:
added
spec/services/auth/container_registry_authentication_service_spec.rb
View file @
74d37438
...
...
@@ -42,6 +42,19 @@ describe Auth::ContainerRegistryAuthenticationService do
end
end
end
shared_examples
'a browsable'
do
let
(
:access
)
do
[{
'type'
=>
'registry'
,
'name'
=>
'catalog'
,
'actions'
=>
[
'*'
]
}]
end
it_behaves_like
'a valid token'
it_behaves_like
'not a container repository factory'
it
{
expect
(
payload
).
to
include
(
'access'
=>
access
)
}
end
shared_examples
'an accessible'
do
let
(
:access
)
do
...
...
@@ -117,6 +130,19 @@ describe Auth::ContainerRegistryAuthenticationService do
context
'user authorization'
do
let
(
:current_user
)
{
create
(
:user
)
}
context
'for registry catalog'
do
let
(
:current_params
)
do
{
scope:
"registry:catalog:*"
}
end
context
'disallow browsing for users without Gitlab admin rights'
do
it_behaves_like
'an inaccessible'
it_behaves_like
'not a container repository factory'
end
end
context
'for private project'
do
let
(
:project
)
{
create
(
:project
)
}
...
...
@@ -490,6 +516,16 @@ describe Auth::ContainerRegistryAuthenticationService do
end
end
context
'registry catalog browsing authorized as admin'
do
let
(
:current_user
)
{
create
(
:user
,
:admin
)
}
let
(
:current_params
)
do
{
scope:
"registry:catalog:*"
}
end
it_behaves_like
'a browsable'
end
context
'unauthorized'
do
context
'disallow to use scope-less authentication'
do
it_behaves_like
'a forbidden'
...
...
@@ -536,5 +572,14 @@ describe Auth::ContainerRegistryAuthenticationService do
it_behaves_like
'not a container repository factory'
end
end
context
'for registry catalog'
do
let
(
:current_params
)
do
{
scope:
"registry:catalog:*"
}
end
it_behaves_like
'a forbidden'
it_behaves_like
'not a container repository factory'
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