summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-05-31 13:48:05 +0200
committerKamil Trzcinski <ayufan@ayufan.eu>2016-05-31 13:48:05 +0200
commit7b0e2bbc803f1dff96941875a541e80675931828 (patch)
tree78db08f8948b21d2017f5b27423dc4f20c7cb570
parent041b0215071b4211400dfebb38fe24bc2718dda3 (diff)
downloadgitlab-ce-7b0e2bbc803f1dff96941875a541e80675931828.tar.gz
Fix the use of CurrentSettings in ContainerRegistryAuthenticationService
-rw-r--r--app/services/auth/container_registry_authentication_service.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/app/services/auth/container_registry_authentication_service.rb b/app/services/auth/container_registry_authentication_service.rb
index 56e567c9eed..e57b95f21ec 100644
--- a/app/services/auth/container_registry_authentication_service.rb
+++ b/app/services/auth/container_registry_authentication_service.rb
@@ -1,6 +1,6 @@
module Auth
class ContainerRegistryAuthenticationService < BaseService
- include CurrentSettings
+ include Gitlab::CurrentSettings
AUDIENCE = 'container_registry'
@@ -19,7 +19,7 @@ module Auth
token = JSONWebToken::RSAToken.new(registry.key)
token.issuer = registry.issuer
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|
{ type: 'repository', name: name, actions: %w(*) }
end
@@ -33,6 +33,7 @@ module Auth
token.issuer = registry.issuer
token.audience = params[:service]
token.subject = current_user.try(:username)
+ token.expire_time = ContainerRegistryAuthenticationService.token_expire_at
token[:access] = accesses.compact
token
end
@@ -78,5 +79,9 @@ module Auth
def registry
Gitlab.config.registry
end
+
+ def self.token_expire_at
+ Time.now + current_application_settings.container_registry_token_expire_delay.minutes
+ end
end
end