From bd3a4840329160a64c0cac25ed6c1d3b22f5bdb4 Mon Sep 17 00:00:00 2001 From: Imre Farkas Date: Sat, 24 Nov 2018 13:39:16 +0100 Subject: Add config to disable impersonation Adds gitlab.impersonation_enabled config option defaulting to true to keep the current default behaviour. Only the act of impersonation is modified, impersonation token management is not affected. --- app/services/access_token_validation_service.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/services/access_token_validation_service.rb') diff --git a/app/services/access_token_validation_service.rb b/app/services/access_token_validation_service.rb index 2a337918d21..40aa9250885 100644 --- a/app/services/access_token_validation_service.rb +++ b/app/services/access_token_validation_service.rb @@ -6,6 +6,7 @@ class AccessTokenValidationService EXPIRED = :expired REVOKED = :revoked INSUFFICIENT_SCOPE = :insufficient_scope + IMPERSONATION_DISABLED = :impersonation_disabled attr_reader :token, :request @@ -24,6 +25,11 @@ class AccessTokenValidationService elsif !self.include_any_scope?(scopes) return INSUFFICIENT_SCOPE + elsif token.respond_to?(:impersonation) && + token.impersonation && + !Gitlab.config.gitlab.impersonation_enabled + return IMPERSONATION_DISABLED + else return VALID end -- cgit v1.2.1