Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dex
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hdacloud
dex
Commits
38d0de20
Commit
38d0de20
authored
7 years ago
by
Eric Chiang
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #1056 from ericchiang/fix-api-panic
server: fix panic caused by deleting refresh token twice through api
parents
e10fddee
f234e370
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/api.go
+18
-3
18 additions, 3 deletions
server/api.go
server/api_test.go
+15
-1
15 additions, 1 deletion
server/api_test.go
with
33 additions
and
4 deletions
server/api.go
+
18
−
3
View file @
38d0de20
...
...
@@ -266,12 +266,20 @@ func (d dexAPI) RevokeRefresh(ctx context.Context, req *api.RevokeRefreshReq) (*
return
nil
,
err
}
var
refreshID
string
var
(
refreshID
string
notFound
bool
)
updater
:=
func
(
old
storage
.
OfflineSessions
)
(
storage
.
OfflineSessions
,
error
)
{
if
refreshID
=
old
.
Refresh
[
req
.
ClientId
]
.
ID
;
refreshID
==
""
{
return
old
,
fmt
.
Errorf
(
"user does not have a refresh token for the client = %s"
,
req
.
ClientId
)
refreshRef
:=
old
.
Refresh
[
req
.
ClientId
]
if
refreshRef
==
nil
||
refreshRef
.
ID
==
""
{
d
.
logger
.
Errorf
(
"api: refresh token issued to client %q for user %q not found for deletion"
,
req
.
ClientId
,
id
.
UserId
)
notFound
=
true
return
old
,
storage
.
ErrNotFound
}
refreshID
=
refreshRef
.
ID
// Remove entry from Refresh list of the OfflineSession object.
delete
(
old
.
Refresh
,
req
.
ClientId
)
...
...
@@ -286,7 +294,14 @@ func (d dexAPI) RevokeRefresh(ctx context.Context, req *api.RevokeRefreshReq) (*
return
nil
,
err
}
if
notFound
{
return
&
api
.
RevokeRefreshResp
{
NotFound
:
true
},
nil
}
// Delete the refresh token from the storage
//
// TODO(ericchiang): we don't have any good recourse if this call fails.
// Consider garbage collection of refresh tokens with no associated ref.
if
err
:=
d
.
s
.
DeleteRefresh
(
refreshID
);
err
!=
nil
{
d
.
logger
.
Errorf
(
"failed to delete refresh token: %v"
,
err
)
return
nil
,
err
...
...
This diff is collapsed.
Click to expand it.
server/api_test.go
+
15
−
1
View file @
38d0de20
...
...
@@ -267,9 +267,23 @@ func TestRefreshToken(t *testing.T) {
}
resp
,
err
:=
client
.
RevokeRefresh
(
ctx
,
&
revokeReq
)
if
err
!=
nil
||
resp
.
NotFound
{
if
err
!=
nil
{
t
.
Fatalf
(
"Unable to revoke refresh tokens for user: %v"
,
err
)
}
if
resp
.
NotFound
{
t
.
Errorf
(
"refresh token session wasn't found"
)
}
// Try to delete again.
//
// See https://github.com/coreos/dex/issues/1055
resp
,
err
=
client
.
RevokeRefresh
(
ctx
,
&
revokeReq
)
if
err
!=
nil
{
t
.
Fatalf
(
"Unable to revoke refresh tokens for user: %v"
,
err
)
}
if
!
resp
.
NotFound
{
t
.
Errorf
(
"refresh token session was found"
)
}
if
resp
,
_
:=
client
.
ListRefresh
(
ctx
,
&
listReq
);
len
(
resp
.
RefreshTokens
)
!=
0
{
t
.
Fatalf
(
"Refresh token returned inspite of revoking it."
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment