Commit 3bfc05be authored by Grzegorz Bizon's avatar Grzegorz Bizon

Use container repository path inside auth service

parent 06bae003
......@@ -58,11 +58,4 @@ class ContainerRepository < ActiveRecord::Base
client.delete_repository_tag(self.path, digest)
end
end
# TODO, we will return a new ContainerRepository object here
#
def self.project_from_path(repository_path)
ContainerRegistry::Path.new(repository_path)
.repository_project
end
end
......@@ -56,13 +56,15 @@ module Auth
def process_scope(scope)
type, name, actions = scope.split(':', 3)
actions = actions.split(',')
path = ContainerRegistry::Path.new(name)
return unless type == 'repository'
process_repository_access(type, name, actions)
process_repository_access(type, path, actions)
end
def process_repository_access(type, name, actions)
requested_project = ContainerRepository.project_from_path(name)
def process_repository_access(type, path, actions)
requested_project = path.repository_project
return unless requested_project
......@@ -70,7 +72,9 @@ module Auth
can_access?(requested_project, action)
end
{ type: type, name: name, actions: actions } if actions.present?
return unless actions.present?
{ type: type, name: path.to_s, actions: actions }
end
def can_access?(requested_project, requested_action)
......
......@@ -9,8 +9,8 @@ describe ContainerRegistry::Path do
it 'return all project-like components in reverse order' do
expect(subject.components).to eq %w[path/to/some/project
path/to/some
path/to]
path/to/some
path/to]
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment