summaryrefslogtreecommitdiff
path: root/app/services/auth
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-30 15:24:46 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-03-30 15:24:46 +0200
commit7d3d1ec5a7b3ee13397af587c6ecb3a3fc297006 (patch)
tree9b05a3320cf773196afde017688ef333962add3e /app/services/auth
parent236c9c170374190bcb6dc54a1ca3dddda2d3dcb2 (diff)
downloadgitlab-ce-7d3d1ec5a7b3ee13397af587c6ecb3a3fc297006.tar.gz
Create container repository on successful push auth
Because we do not have yet two way communication between container registry and GitLab, we need to eagerly create a new container repository objects in database. We now do that after user/build successfully authenticates a push action using auth service.
Diffstat (limited to 'app/services/auth')
-rw-r--r--app/services/auth/container_registry_authentication_service.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/app/services/auth/container_registry_authentication_service.rb b/app/services/auth/container_registry_authentication_service.rb
index b050f1dd51b..839f514ad58 100644
--- a/app/services/auth/container_registry_authentication_service.rb
+++ b/app/services/auth/container_registry_authentication_service.rb
@@ -74,9 +74,25 @@ module Auth
return unless actions.present?
+ # At this point user/build is already authenticated.
+ #
+ ensure_container_repository!(path, actions)
+
{ type: type, name: path.to_s, actions: actions }
end
+ ##
+ # Because we do not have two way communication with registry yet,
+ # we create a container repository image resource when push to the
+ # registry is successfuly authorized.
+ #
+ def ensure_container_repository!(path, actions)
+ return if path.has_repository?
+ return unless actions.include?('push')
+
+ ContainerRepository.create_from_path(path)
+ end
+
def can_access?(requested_project, requested_action)
return false unless requested_project.container_registry_enabled?