Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/auth/auth_finders.rb')
-rw-r--r--lib/gitlab/auth/auth_finders.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/gitlab/auth/auth_finders.rb b/lib/gitlab/auth/auth_finders.rb
index a715f17ecd6..25465e73b95 100644
--- a/lib/gitlab/auth/auth_finders.rb
+++ b/lib/gitlab/auth/auth_finders.rb
@@ -32,6 +32,17 @@ module Gitlab
RUNNER_JOB_TOKEN_PARAM = :token
PATH_DEPENDENT_FEED_TOKEN_REGEX = /\A#{User::FEED_TOKEN_PREFIX}(\h{64})-(\d+)\z/
+ PARAM_TOKEN_KEYS = [
+ PRIVATE_TOKEN_PARAM,
+ JOB_TOKEN_PARAM,
+ RUNNER_JOB_TOKEN_PARAM
+ ].map(&:to_s).freeze
+ HEADER_TOKEN_KEYS = [
+ PRIVATE_TOKEN_HEADER,
+ JOB_TOKEN_HEADER,
+ DEPLOY_TOKEN_HEADER
+ ].freeze
+
# Check the Rails session for valid authentication details
def find_user_from_warden
current_request.env['warden']&.authenticate if verified_request?
@@ -204,6 +215,12 @@ module Gitlab
end
end
+ def authentication_token_present?
+ PARAM_TOKEN_KEYS.intersection(current_request.params.keys).any? ||
+ HEADER_TOKEN_KEYS.intersection(current_request.env.keys).any? ||
+ parsed_oauth_token.present?
+ end
+
private
def find_user_from_job_bearer_token