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
4af27e6d
Commit
4af27e6d
authored
Sep 03, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
00d0ad06
4e4fcf79
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
9 deletions
+24
-9
app/services/auth/container_registry_authentication_service.rb
...ervices/auth/container_registry_authentication_service.rb
+9
-1
changelogs/unreleased/40096-allow-ci-token-to-delete-from-registry.yml
...released/40096-allow-ci-token-to-delete-from-registry.yml
+5
-0
lib/gitlab/auth.rb
lib/gitlab/auth.rb
+2
-1
spec/lib/gitlab/auth_spec.rb
spec/lib/gitlab/auth_spec.rb
+2
-1
spec/services/auth/container_registry_authentication_service_spec.rb
...es/auth/container_registry_authentication_service_spec.rb
+6
-6
No files found.
app/services/auth/container_registry_authentication_service.rb
View file @
4af27e6d
...
...
@@ -124,13 +124,21 @@ module Auth
build_can_pull?
(
requested_project
)
||
user_can_pull?
(
requested_project
)
||
deploy_token_can_pull?
(
requested_project
)
when
'push'
build_can_push?
(
requested_project
)
||
user_can_push?
(
requested_project
)
when
'*'
,
'delete'
when
'delete'
build_can_delete?
(
requested_project
)
||
user_can_admin?
(
requested_project
)
when
'*'
user_can_admin?
(
requested_project
)
else
false
end
end
def
build_can_delete?
(
requested_project
)
# Build can delete only from the project from which it originates
has_authentication_ability?
(
:build_destroy_container_image
)
&&
requested_project
==
project
end
def
registry
Gitlab
.
config
.
registry
end
...
...
changelogs/unreleased/40096-allow-ci-token-to-delete-from-registry.yml
0 → 100644
View file @
4af27e6d
---
title
:
Allow $CI_REGISTRY_USER to delete tags
merge_request
:
31796
author
:
type
:
added
lib/gitlab/auth.rb
View file @
4af27e6d
...
...
@@ -267,7 +267,8 @@ module Gitlab
:read_project
,
:build_download_code
,
:build_read_container_image
,
:build_create_container_image
:build_create_container_image
,
:build_destroy_container_image
]
end
...
...
spec/lib/gitlab/auth_spec.rb
View file @
4af27e6d
...
...
@@ -587,7 +587,8 @@ describe Gitlab::Auth do
:read_project
,
:build_download_code
,
:build_read_container_image
,
:build_create_container_image
:build_create_container_image
,
:build_destroy_container_image
]
end
...
...
spec/services/auth/container_registry_authentication_service_spec.rb
View file @
4af27e6d
...
...
@@ -476,7 +476,7 @@ describe Auth::ContainerRegistryAuthenticationService do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:authentication_abilities
)
do
[
:build_read_container_image
,
:build_create_container_image
]
[
:build_read_container_image
,
:build_create_container_image
,
:build_destroy_container_image
]
end
before
do
...
...
@@ -507,19 +507,19 @@ describe Auth::ContainerRegistryAuthenticationService do
end
end
context
'
disallow to delete images
'
do
context
'
allow to delete images since registry 2.7
'
do
let
(
:current_params
)
do
{
scopes:
[
"repository:
#{
current_project
.
full_path
}
:
*
"
]
}
{
scopes:
[
"repository:
#{
current_project
.
full_path
}
:
delete
"
]
}
end
it_behaves_like
'a
n inaccessible
'
do
it_behaves_like
'a
deletable since registry 2.7
'
do
let
(
:project
)
{
current_project
}
end
end
context
'disallow to delete images
since registry 2.7
'
do
context
'disallow to delete images'
do
let
(
:current_params
)
do
{
scopes:
[
"repository:
#{
current_project
.
full_path
}
:
delete
"
]
}
{
scopes:
[
"repository:
#{
current_project
.
full_path
}
:
*
"
]
}
end
it_behaves_like
'an inaccessible'
do
...
...
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