Skip to content

Commit

Permalink
Add
Browse files Browse the repository at this point in the history
  • Loading branch information
p53 committed Dec 2, 2023
1 parent 27149bc commit 25a9c12
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkg/keycloak/proxy/middleware.go
Original file line number Diff line number Diff line change
@@ -375,6 +375,15 @@ func (r *OauthProxy) authenticationMiddleware() func(http.Handler) http.Handler
// step: inject the refreshed access token
r.Cm.DropAccessTokenCookie(req.WithContext(ctx), wrt, accessToken, accessExpiresIn)

// update the with the new access token and inject into the context
newUser, err := ExtractIdentity(&newAccToken)
if err != nil {
lLog.Error(err.Error())
//nolint:contextcheck
next.ServeHTTP(wrt, req.WithContext(r.accessForbidden(wrt, req)))
return
}

// step: inject the renewed refresh token
if newRefreshToken != "" {
lLog.Debug(
@@ -414,15 +423,6 @@ func (r *OauthProxy) authenticationMiddleware() func(http.Handler) http.Handler
}
}

// update the with the new access token and inject into the context
newUser, err := ExtractIdentity(&newAccToken)
if err != nil {
lLog.Error(err.Error())
//nolint:contextcheck
next.ServeHTTP(wrt, req.WithContext(r.accessForbidden(wrt, req)))
return
}

// IMPORTANT: on this rely other middlewares, must be refreshed
// with new identity!
newUser.RawToken = newRawAccToken

0 comments on commit 25a9c12

Please sign in to comment.