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
03d1719c
Commit
03d1719c
authored
Nov 06, 2018
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Return error when token owner could not be found
parent
5d4f78ab
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
3 deletions
+28
-3
ee/app/services/oauth2/logout_token_validation_service.rb
ee/app/services/oauth2/logout_token_validation_service.rb
+7
-2
ee/spec/services/oauth2/logout_token_validation_service_spec.rb
...c/services/oauth2/logout_token_validation_service_spec.rb
+21
-1
No files found.
ee/app/services/oauth2/logout_token_validation_service.rb
View file @
03d1719c
...
...
@@ -10,13 +10,18 @@ module Oauth2
end
def
execute
return
error
(
'Access token
not
found'
)
unless
access_token
.
present?
return
error
(
'Access token
could not be
found'
)
unless
access_token
.
present?
status
=
AccessTokenValidationService
.
new
(
access_token
).
validate
return
error
(
status
)
unless
status
==
AccessTokenValidationService
::
VALID
user
=
User
.
find
(
access_token
.
resource_owner_id
)
success
(
return_to:
user_return_to
)
if
user
==
current_user
if
user
&&
user
==
current_user
success
(
return_to:
user_return_to
)
else
error
(
'User could not be found'
)
end
end
private
...
...
ee/spec/services/oauth2/logout_token_validation_service_spec.rb
View file @
03d1719c
...
...
@@ -27,7 +27,7 @@ describe Oauth2::LogoutTokenValidationService do
expect
(
result
[
:status
]).
to
eq
(
:error
)
end
it
'returns error when incorrect encoding'
do
it
'returns error when
token has
incorrect encoding'
do
allow_any_instance_of
(
Gitlab
::
Geo
::
OauthSession
)
.
to
receive
(
:extract_logout_token
)
.
and_return
(
"
\xD8
00
\xD8
01
\xD8
02"
)
...
...
@@ -37,6 +37,26 @@ describe Oauth2::LogoutTokenValidationService do
expect
(
result
[
:status
]).
to
eq
(
:error
)
end
it
'returns error when current user is nil'
do
result
=
described_class
.
new
(
nil
,
state:
logout_state
).
execute
expect
(
result
).
to
eq
(
status: :error
,
message:
'User could not be found'
)
end
it
'returns error when token owner could not be found'
do
allow
(
User
).
to
receive
(
:find
).
with
(
user
.
id
).
and_return
(
nil
)
result
=
described_class
.
new
(
user
,
state:
logout_state
).
execute
expect
(
result
).
to
eq
(
status: :error
,
message:
'User could not be found'
)
end
it
'returns error when token does not belong to the current user'
do
result
=
described_class
.
new
(
create
(
:user
),
state:
logout_state
).
execute
expect
(
result
).
to
eq
(
status: :error
,
message:
'User could not be found'
)
end
context
'when token is valid'
do
it
'returns success'
do
result
=
described_class
.
new
(
user
,
state:
logout_state
).
execute
...
...
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