From 674b62bb8937e5ece7a54cfdf2c30eddf39a6c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=C5=BE=20Jerman?= Date: Tue, 10 May 2022 11:01:19 +0200 Subject: [PATCH] Fix auth refresh token configuration Prior version didn't push refresh exparation forward so an expired refresh token could be issued. --- auth/oauth2/corteza_token_store.go | 4 ---- auth/oauth2/oauth2.go | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/auth/oauth2/corteza_token_store.go b/auth/oauth2/corteza_token_store.go index d2a662219..828053cfd 100644 --- a/auth/oauth2/corteza_token_store.go +++ b/auth/oauth2/corteza_token_store.go @@ -136,10 +136,6 @@ func (c tokenStore) GetByRefresh(ctx context.Context, refresh string) (oauth2.To return nil, fmt.Errorf("failed to get refresh token: %w", err) } - if t.ExpiresAt.Before(*now()) { - //return nil, oauth2errors.ErrExpiredRefreshToken - } - return internal, t.Data.Unmarshal(internal) } diff --git a/auth/oauth2/oauth2.go b/auth/oauth2/oauth2.go index 400e4a472..e73b77408 100644 --- a/auth/oauth2/oauth2.go +++ b/auth/oauth2/oauth2.go @@ -34,6 +34,13 @@ func NewManager(opt options.AuthOpt, log *zap.Logger, cs oauth2.ClientStore, ts // token store manager.MapTokenStorage(ts) manager.MapClientStorage(cs) + // Change the default config for it to update refresh token timestamps + // else the refresh token timestamp remains the same + // + // @note do this so we don't change the default `manage` package var + rcfg := *manage.DefaultRefreshTokenCfg + rcfg.IsResetRefreshTime = true + manager.SetRefreshTokenCfg(&rcfg) manager.SetValidateURIHandler(func(baseURI, redirectURI string) (err error) { if baseURI == "" {