Skip to content
Snippets Groups Projects
Commit 7b0e2bbc authored by Kamil Trzcinski's avatar Kamil Trzcinski
Browse files

Fix the use of CurrentSettings in ContainerRegistryAuthenticationService

parent 041b0215
No related branches found
No related tags found
1 merge request!4364Add Application Setting to configure Container Registry token expire delay (default 5min)
module Auth module Auth
class ContainerRegistryAuthenticationService < BaseService class ContainerRegistryAuthenticationService < BaseService
include CurrentSettings include Gitlab::CurrentSettings
   
AUDIENCE = 'container_registry' AUDIENCE = 'container_registry'
   
Loading
@@ -19,7 +19,7 @@ module Auth
Loading
@@ -19,7 +19,7 @@ module Auth
token = JSONWebToken::RSAToken.new(registry.key) token = JSONWebToken::RSAToken.new(registry.key)
token.issuer = registry.issuer token.issuer = registry.issuer
token.audience = AUDIENCE token.audience = AUDIENCE
token.expire_time = token.issued_at + current_application_settings.container_registry_token_expire_delay.minutes token.expire_time = token_expire_at
token[:access] = names.map do |name| token[:access] = names.map do |name|
{ type: 'repository', name: name, actions: %w(*) } { type: 'repository', name: name, actions: %w(*) }
end end
Loading
@@ -33,6 +33,7 @@ module Auth
Loading
@@ -33,6 +33,7 @@ module Auth
token.issuer = registry.issuer token.issuer = registry.issuer
token.audience = params[:service] token.audience = params[:service]
token.subject = current_user.try(:username) token.subject = current_user.try(:username)
token.expire_time = ContainerRegistryAuthenticationService.token_expire_at
token[:access] = accesses.compact token[:access] = accesses.compact
token token
end end
Loading
@@ -78,5 +79,9 @@ module Auth
Loading
@@ -78,5 +79,9 @@ module Auth
def registry def registry
Gitlab.config.registry Gitlab.config.registry
end end
def self.token_expire_at
Time.now + current_application_settings.container_registry_token_expire_delay.minutes
end
end end
end end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment