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
3e0738ce
Commit
3e0738ce
authored
Jan 06, 2022
by
Manoj M J
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return 401 when using invalid tokens in oauth/token/info
Changelog: fixed
parent
d0a9bffc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
13 deletions
+13
-13
app/controllers/oauth/token_info_controller.rb
app/controllers/oauth/token_info_controller.rb
+1
-1
spec/controllers/oauth/token_info_controller_spec.rb
spec/controllers/oauth/token_info_controller_spec.rb
+12
-12
No files found.
app/controllers/oauth/token_info_controller.rb
View file @
3e0738ce
...
@@ -13,7 +13,7 @@ class Oauth::TokenInfoController < Doorkeeper::TokenInfoController
...
@@ -13,7 +13,7 @@ class Oauth::TokenInfoController < Doorkeeper::TokenInfoController
'expires_in_seconds'
=>
token_json
[
:expires_in
]
'expires_in_seconds'
=>
token_json
[
:expires_in
]
),
status: :ok
),
status: :ok
else
else
error
=
Doorkeeper
::
OAuth
::
ErrorResponse
.
new
(
name: :invalid_request
)
error
=
Doorkeeper
::
OAuth
::
InvalidTokenResponse
.
new
response
.
headers
.
merge!
(
error
.
headers
)
response
.
headers
.
merge!
(
error
.
headers
)
render
json:
error
.
body
,
status:
error
.
status
render
json:
error
.
body
,
status:
error
.
status
end
end
...
...
spec/controllers/oauth/token_info_controller_spec.rb
View file @
3e0738ce
...
@@ -5,11 +5,11 @@ require 'spec_helper'
...
@@ -5,11 +5,11 @@ require 'spec_helper'
RSpec
.
describe
Oauth
::
TokenInfoController
do
RSpec
.
describe
Oauth
::
TokenInfoController
do
describe
'#show'
do
describe
'#show'
do
context
'when the user is not authenticated'
do
context
'when the user is not authenticated'
do
it
'responds with a 40
0
'
do
it
'responds with a 40
1
'
do
get
:show
get
:show
expect
(
response
).
to
have_gitlab_http_status
(
:
bad_request
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
expect
(
Gitlab
::
Json
.
parse
(
response
.
body
)).
to
include
(
'error'
=>
'invalid_
request
'
)
expect
(
Gitlab
::
Json
.
parse
(
response
.
body
)).
to
include
(
'error'
=>
'invalid_
token
'
)
end
end
end
end
...
@@ -36,11 +36,11 @@ RSpec.describe Oauth::TokenInfoController do
...
@@ -36,11 +36,11 @@ RSpec.describe Oauth::TokenInfoController do
end
end
context
'when the doorkeeper_token is not recognised'
do
context
'when the doorkeeper_token is not recognised'
do
it
'responds with a 40
0
'
do
it
'responds with a 40
1
'
do
get
:show
,
params:
{
access_token:
'unknown_token'
}
get
:show
,
params:
{
access_token:
'unknown_token'
}
expect
(
response
).
to
have_gitlab_http_status
(
:
bad_request
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
expect
(
Gitlab
::
Json
.
parse
(
response
.
body
)).
to
include
(
'error'
=>
'invalid_
request
'
)
expect
(
Gitlab
::
Json
.
parse
(
response
.
body
)).
to
include
(
'error'
=>
'invalid_
token
'
)
end
end
end
end
...
@@ -49,22 +49,22 @@ RSpec.describe Oauth::TokenInfoController do
...
@@ -49,22 +49,22 @@ RSpec.describe Oauth::TokenInfoController do
create
(
:oauth_access_token
,
created_at:
2
.
days
.
ago
,
expires_in:
10
.
minutes
)
create
(
:oauth_access_token
,
created_at:
2
.
days
.
ago
,
expires_in:
10
.
minutes
)
end
end
it
'responds with a 40
0
'
do
it
'responds with a 40
1
'
do
get
:show
,
params:
{
access_token:
access_token
.
token
}
get
:show
,
params:
{
access_token:
access_token
.
token
}
expect
(
response
).
to
have_gitlab_http_status
(
:
bad_request
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
expect
(
Gitlab
::
Json
.
parse
(
response
.
body
)).
to
include
(
'error'
=>
'invalid_
request
'
)
expect
(
Gitlab
::
Json
.
parse
(
response
.
body
)).
to
include
(
'error'
=>
'invalid_
token
'
)
end
end
end
end
context
'when the token is revoked'
do
context
'when the token is revoked'
do
let
(
:access_token
)
{
create
(
:oauth_access_token
,
revoked_at:
2
.
days
.
ago
)
}
let
(
:access_token
)
{
create
(
:oauth_access_token
,
revoked_at:
2
.
days
.
ago
)
}
it
'responds with a 40
0
'
do
it
'responds with a 40
1
'
do
get
:show
,
params:
{
access_token:
access_token
.
token
}
get
:show
,
params:
{
access_token:
access_token
.
token
}
expect
(
response
).
to
have_gitlab_http_status
(
:
bad_request
)
expect
(
response
).
to
have_gitlab_http_status
(
:
unauthorized
)
expect
(
Gitlab
::
Json
.
parse
(
response
.
body
)).
to
include
(
'error'
=>
'invalid_
request
'
)
expect
(
Gitlab
::
Json
.
parse
(
response
.
body
)).
to
include
(
'error'
=>
'invalid_
token
'
)
end
end
end
end
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