Skip to content

Commit

Permalink
Add docu
Browse files Browse the repository at this point in the history
  • Loading branch information
p53 committed Feb 12, 2025
1 parent 8c03145 commit 0d49e18
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions pkg/proxy/middleware/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,23 +148,25 @@ func AuthenticationMiddleware(
return
}

var stdRefreshClaims *jwt.Claims
stdRefreshClaims, err = utils.ParseRefreshToken(refresh)
if err != nil {
lLog.Error(
apperrors.ErrParseRefreshToken.Error(),
zap.Error(err),
)
accessForbidden(wrt, req)
return
}
if user.ID != stdRefreshClaims.Subject {
lLog.Error(
apperrors.ErrAccRefreshTokenMismatch.Error(),
zap.Error(err),
)
accessForbidden(wrt, req)
return
if encryptionKey != "" {
var stdRefreshClaims *jwt.Claims
stdRefreshClaims, err = utils.ParseRefreshToken(refresh)
if err != nil {
lLog.Error(
apperrors.ErrParseRefreshToken.Error(),
zap.Error(err),
)
accessForbidden(wrt, req)
return
}
if user.ID != stdRefreshClaims.Subject {
lLog.Error(
apperrors.ErrAccRefreshTokenMismatch.Error(),
zap.Error(err),
)
accessForbidden(wrt, req)
return
}
}

scope.Identity = user
Expand All @@ -178,7 +180,6 @@ func AuthenticationMiddleware(
// exp: expiration of the access token
// expiresIn: expiration of the ID token
conf := newOAuth2Config(redirectionURL)

lLog.Debug(
"issuing refresh token request",
zap.String("current access token", user.RawToken),
Expand Down Expand Up @@ -327,6 +328,7 @@ func AuthenticationMiddleware(
tokenSource := oauth2.StaticTokenSource(
&oauth2.Token{AccessToken: scope.Identity.RawToken},
)

_, err := provider.UserInfo(oidcLibCtx, tokenSource)
if err != nil {
scope.Logger.Error(err.Error())
Expand Down

0 comments on commit 0d49e18

Please sign in to comment.