Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
ccb6b0fc
Commit
ccb6b0fc
authored
Mar 30, 2021
by
Thong Kuah
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix HTTP status code for agent tokens that are invalid or missing
parent
a853e5ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
10 deletions
+10
-10
ee/spec/requests/api/internal/kubernetes_spec.rb
ee/spec/requests/api/internal/kubernetes_spec.rb
+4
-4
lib/api/internal/kubernetes.rb
lib/api/internal/kubernetes.rb
+2
-2
spec/requests/api/internal/kubernetes_spec.rb
spec/requests/api/internal/kubernetes_spec.rb
+4
-4
No files found.
ee/spec/requests/api/internal/kubernetes_spec.rb
View file @
ccb6b0fc
...
...
@@ -38,16 +38,16 @@ RSpec.describe API::Internal::Kubernetes do
end
shared_examples
'agent authentication'
do
it
'returns 40
3
if Authorization header not sent'
do
it
'returns 40
1
if Authorization header not sent'
do
send_request
expect
(
response
).
to
have_gitlab_http_status
(
:
forbidden
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
it
'returns 40
3
if Authorization is for non-existent agent'
do
it
'returns 40
1
if Authorization is for non-existent agent'
do
send_request
(
headers:
{
'Authorization'
=>
'Bearer NONEXISTENT'
})
expect
(
response
).
to
have_gitlab_http_status
(
:
forbidden
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
end
...
...
lib/api/internal/kubernetes.rb
View file @
ccb6b0fc
...
...
@@ -13,7 +13,7 @@ module API
helpers
do
def
authenticate_gitlab_kas_request!
unauthorized!
unless
Gitlab
::
Kas
.
verify_api_request
(
headers
)
render_api_error!
(
'KAS JWT authentication invalid'
,
401
)
unless
Gitlab
::
Kas
.
verify_api_request
(
headers
)
end
def
agent_token
...
...
@@ -51,7 +51,7 @@ module API
end
def
check_agent_token
forbidden
!
unless
agent_token
unauthorized
!
unless
agent_token
forbidden!
unless
Gitlab
::
Kas
.
included_in_gitlab_com_rollout?
(
agent
.
project
)
...
...
spec/requests/api/internal/kubernetes_spec.rb
View file @
ccb6b0fc
...
...
@@ -38,16 +38,16 @@ RSpec.describe API::Internal::Kubernetes do
end
shared_examples
'agent authentication'
do
it
'returns 40
3
if Authorization header not sent'
do
it
'returns 40
1
if Authorization header not sent'
do
send_request
expect
(
response
).
to
have_gitlab_http_status
(
:
forbidden
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
it
'returns 40
3
if Authorization is for non-existent agent'
do
it
'returns 40
1
if Authorization is for non-existent agent'
do
send_request
(
headers:
{
'Authorization'
=>
'Bearer NONEXISTENT'
})
expect
(
response
).
to
have_gitlab_http_status
(
:
forbidden
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment