Skip to content

Commit

Permalink
fix: do not store refresh token, if empty.
Browse files Browse the repository at this point in the history
Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Nov 12, 2024
1 parent ca56ed3 commit 231a407
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions internal/oauth2/refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ func (p *Provider) RefreshClientAuth(logger *slog.Logger, client connection.Clie
logger.Info("successful authenticate via refresh token")

refreshToken, err = p.Provider.GetRefreshToken(tokens)
if err != nil {
if errors.Is(err, types.ErrNoRefreshToken) {
logMessage := logger.WarnContext
if client.SessionState == "AuthenticatedEmptyUser" || client.SessionState == "Authenticated" {
logMessage = logger.DebugContext
}

logMessage(ctx, fmt.Errorf("oauth2.refresh is enabled, but %w", err).Error())
} else {
logger.WarnContext(ctx, fmt.Errorf("oauth2.refresh is enabled, but %w", err).Error())
switch {
case errors.Is(err, types.ErrNoRefreshToken):
logMessage := logger.WarnContext
if client.SessionState == "AuthenticatedEmptyUser" || client.SessionState == "Authenticated" {
logMessage = logger.DebugContext
}
} else {

logMessage(ctx, fmt.Errorf("oauth2.refresh is enabled, but %w", err).Error())
case err != nil:
logger.WarnContext(ctx, fmt.Errorf("oauth2.refresh is enabled, but %w", err).Error())
default:
logger.DebugContext(ctx, "store new refresh token into token store")

if err = p.storage.Set(id, refreshToken); err != nil {
Expand Down

0 comments on commit 231a407

Please sign in to comment.