Skip to content
Snippets Groups Projects
Commit b2acb3c7 authored by Vratislav Kalenda's avatar Vratislav Kalenda
Browse files

refactor access handling

parent 3b95f588
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -56,15 +56,22 @@ module Auth
def process_scope(scope)
type, name, actions = scope.split(':', 3)
actions = actions.split(',')
path = ContainerRegistry::Path.new(name)
 
if type == 'registry' && name == 'catalog' && current_user && current_user.admin?
return { type: type, name: name, actions: ['*'] }
case type
when 'registry'
process_registry_access(type, name, actions)
when 'repository'
path = ContainerRegistry::Path.new(name)
process_repository_access(type, path, actions)
end
end
 
return unless type == 'repository'
def process_registry_access(type, name, actions)
return unless current_user&.admin?
return unless name == 'catalog'
return unless actions == ['*']
 
process_repository_access(type, path, actions)
{ type: type, name: name, actions: ['*'] }
end
 
def process_repository_access(type, path, actions)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment