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
4e73f39f
Commit
4e73f39f
authored
4 years ago
by
m.nabokikh
Browse files
Options
Downloads
Patches
Plain Diff
Do not refresh id token claims if refresh token is allowed to reuse
Signed-off-by:
m.nabokikh
<
maksim.nabokikh@flant.com
>
parent
0c75ed12
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/refreshhandlers.go
+9
-2
9 additions, 2 deletions
server/refreshhandlers.go
with
9 additions
and
2 deletions
server/refreshhandlers.go
+
9
−
2
View file @
4e73f39f
...
@@ -91,6 +91,7 @@ func (s *Server) getRefreshTokenFromStorage(clientID string, token *internal.Ref
...
@@ -91,6 +91,7 @@ func (s *Server) getRefreshTokenFromStorage(clientID string, token *internal.Ref
s
.
logger
.
Errorf
(
"refresh token with id %s expired"
,
refresh
.
ID
)
s
.
logger
.
Errorf
(
"refresh token with id %s expired"
,
refresh
.
ID
)
return
storage
.
RefreshToken
{},
&
rerr
return
storage
.
RefreshToken
{},
&
rerr
}
}
if
s
.
refreshTokenPolicy
.
ExpiredBecauseUnused
(
refresh
.
LastUsed
)
{
if
s
.
refreshTokenPolicy
.
ExpiredBecauseUnused
(
refresh
.
LastUsed
)
{
s
.
logger
.
Errorf
(
"refresh token with id %s expired because being unused"
,
refresh
.
ID
)
s
.
logger
.
Errorf
(
"refresh token with id %s expired because being unused"
,
refresh
.
ID
)
return
storage
.
RefreshToken
{},
&
rerr
return
storage
.
RefreshToken
{},
&
rerr
...
@@ -131,7 +132,7 @@ func (s *Server) getRefreshScopes(r *http.Request, refresh *storage.RefreshToken
...
@@ -131,7 +132,7 @@ func (s *Server) getRefreshScopes(r *http.Request, refresh *storage.RefreshToken
return
requestedScopes
,
nil
return
requestedScopes
,
nil
}
}
func
(
s
*
Server
)
refreshWithConnector
(
ctx
context
.
Context
,
refresh
*
storage
.
RefreshToken
,
scopes
[]
string
)
(
connector
.
Identity
,
*
refreshError
)
{
func
(
s
*
Server
)
refreshWithConnector
(
ctx
context
.
Context
,
token
*
internal
.
RefreshToken
,
refresh
*
storage
.
RefreshToken
,
scopes
[]
string
)
(
connector
.
Identity
,
*
refreshError
)
{
var
connectorData
[]
byte
var
connectorData
[]
byte
rerr
:=
refreshError
{
msg
:
errInvalidRequest
,
desc
:
""
,
code
:
http
.
StatusInternalServerError
}
rerr
:=
refreshError
{
msg
:
errInvalidRequest
,
desc
:
""
,
code
:
http
.
StatusInternalServerError
}
...
@@ -166,6 +167,12 @@ func (s *Server) refreshWithConnector(ctx context.Context, refresh *storage.Refr
...
@@ -166,6 +167,12 @@ func (s *Server) refreshWithConnector(ctx context.Context, refresh *storage.Refr
ConnectorData
:
connectorData
,
ConnectorData
:
connectorData
,
}
}
// user's token was previously updated by a connector and is allowed to reuse
// it is excessive to refresh identity in upstream
if
s
.
refreshTokenPolicy
.
AllowedToReuse
(
refresh
.
LastUsed
)
&&
token
.
Token
==
refresh
.
ObsoleteToken
{
return
ident
,
nil
}
// Can the connector refresh the identity? If so, attempt to refresh the data
// Can the connector refresh the identity? If so, attempt to refresh the data
// in the connector.
// in the connector.
//
//
...
@@ -272,7 +279,7 @@ func (s *Server) handleRefreshToken(w http.ResponseWriter, r *http.Request, clie
...
@@ -272,7 +279,7 @@ func (s *Server) handleRefreshToken(w http.ResponseWriter, r *http.Request, clie
return
return
}
}
ident
,
rerr
:=
s
.
refreshWithConnector
(
r
.
Context
(),
&
refresh
,
scopes
)
ident
,
rerr
:=
s
.
refreshWithConnector
(
r
.
Context
(),
token
,
&
refresh
,
scopes
)
if
rerr
!=
nil
{
if
rerr
!=
nil
{
s
.
refreshTokenErrHelper
(
w
,
rerr
)
s
.
refreshTokenErrHelper
(
w
,
rerr
)
return
return
...
...
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