Commit aac6449c authored by Thong Kuah's avatar Thong Kuah

Combine constants into CI_JOB_USER

There is no advantage to two constants. The registry login also uses
find_for_git_client (via JwtController), and the registry login also
uses the job token as the passsword. So just use CI_JOB_USERNAME for
user and job token for password in all cases.
parent 222d2a9c
......@@ -535,7 +535,7 @@ module Ci
.append(key: 'CI_JOB_TOKEN', value: token.to_s, public: false, masked: true)
.append(key: 'CI_BUILD_ID', value: id.to_s)
.append(key: 'CI_BUILD_TOKEN', value: token.to_s, public: false, masked: true)
.append(key: 'CI_REGISTRY_USER', value: ::Gitlab::Auth::CI_REGISTRY_USER)
.append(key: 'CI_REGISTRY_USER', value: ::Gitlab::Auth::CI_JOB_USER)
.append(key: 'CI_REGISTRY_PASSWORD', value: token.to_s, public: false, masked: true)
.append(key: 'CI_REPOSITORY_URL', value: repo_url.to_s, public: false)
.concat(deploy_token_variables)
......
......@@ -27,7 +27,6 @@ module Gitlab
DEFAULT_SCOPES = [:api].freeze
CI_JOB_USER = 'gitlab-ci-token'
CI_REGISTRY_USER = 'gitlab-ci-token'
class << self
prepend_if_ee('EE::Gitlab::Auth') # rubocop: disable Cop/InjectEnterpriseEditionModule
......@@ -129,7 +128,7 @@ module Gitlab
# rubocop:enable Gitlab/RailsLogger
def skip_rate_limit?(login:)
CI_REGISTRY_USER == login
CI_JOB_USER == login
end
def look_to_limit_user(actor)
......
......@@ -82,7 +82,7 @@ module Gitlab
login, password = user_name_and_password(current_request)
return unless login.present? && password.present?
return unless ::Gitlab::Auth::CI_REGISTRY_USER == login
return unless ::Gitlab::Auth::CI_JOB_USER == login
job = ::Ci::Build.find_by_token(password)
raise UnauthorizedError unless job
......
......@@ -554,7 +554,7 @@ RSpec.describe Gitlab::Auth::AuthFinders do
end
context 'with CI username' do
let(:username) { ::Gitlab::Auth::CI_REGISTRY_USER }
let(:username) { ::Gitlab::Auth::CI_JOB_USER }
let(:user) { create(:user) }
let(:build) { create(:ci_build, user: user) }
......@@ -727,7 +727,7 @@ RSpec.describe Gitlab::Auth::AuthFinders do
context 'when the job token is provided via basic auth' do
let(:route_authentication_setting) { { job_token_allowed: :basic_auth } }
let(:username) { ::Gitlab::Auth::CI_REGISTRY_USER }
let(:username) { ::Gitlab::Auth::CI_JOB_USER }
let(:token) { job.token }
before do
......
......@@ -8,7 +8,7 @@ module HttpBasicAuthHelpers
end
def job_basic_auth_header(job)
basic_auth_header(::Gitlab::Auth::CI_REGISTRY_USER, job.token)
basic_auth_header(::Gitlab::Auth::CI_JOB_USER, job.token)
end
def client_basic_auth_header(client)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment