Skip to content
代码片段 群组 项目
未验证 提交 9fc8d303 编辑于 作者: Piotr Skorupa's avatar Piotr Skorupa 提交者: GitLab
浏览文件

Merge branch '521696-authenticate-header' into 'master'

Maven virtual registry: add the authenticate header in the unauthorized response

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/182919



Merged-by: default avatarPiotr Skorupa <pskorupa@gitlab.com>
Approved-by: default avatarMoaz Khalifa <mkhalifa@gitlab.com>
Approved-by: default avatarPiotr Skorupa <pskorupa@gitlab.com>
Reviewed-by: default avatarMoaz Khalifa <mkhalifa@gitlab.com>
Co-authored-by: default avatarDavid Fernandez <dfernandez@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -12,6 +12,9 @@ class Endpoints < ::API::Base ...@@ -12,6 +12,9 @@ class Endpoints < ::API::Base
feature_category :virtual_registry feature_category :virtual_registry
urgency :low urgency :low
AUTHENTICATE_REALM_HEADER = 'WWW-Authenticate'
AUTHENTICATE_REALM_NAME = 'Basic realm="GitLab Virtual Registry"'
SHA1_CHECKSUM_HEADER = 'x-checksum-sha1' SHA1_CHECKSUM_HEADER = 'x-checksum-sha1'
MD5_CHECKSUM_HEADER = 'x-checksum-md5' MD5_CHECKSUM_HEADER = 'x-checksum-md5'
...@@ -50,6 +53,12 @@ def download_file_extra_response_headers(action_params:) ...@@ -50,6 +53,12 @@ def download_file_extra_response_headers(action_params:)
} }
end end
# override from api helpers unauthorized! function
def unauthorized!(reason = nil)
header(AUTHENTICATE_REALM_HEADER, AUTHENTICATE_REALM_NAME)
super
end
params :id_and_path do params :id_and_path do
requires :id, requires :id,
type: Integer, type: Integer,
......
...@@ -199,6 +199,18 @@ ...@@ -199,6 +199,18 @@
it_behaves_like 'maven virtual registry disabled dependency proxy' it_behaves_like 'maven virtual registry disabled dependency proxy'
end end
context 'with no user' do
let(:headers) { {} }
it 'returns unauthorized with the www-authenticate header' do
request
expect(response).to have_gitlab_http_status(:unauthorized)
expect(response.headers[described_class::AUTHENTICATE_REALM_HEADER])
.to eq(described_class::AUTHENTICATE_REALM_NAME)
end
end
it_behaves_like 'maven virtual registry not authenticated user' it_behaves_like 'maven virtual registry not authenticated user'
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册