[v9.3.x] Auth: Remove the session cookie only if it's invalid or revoked (#68796)

Auth: Remove the session cookie only if it's invalid or revoked (#65984)

Remove the cookie if it's invalid or revoked

(cherry picked from commit 4cac95d1c2)
This commit is contained in:
Misi
2023-05-22 14:16:59 +02:00
committed by GitHub
parent 9a87d5dea5
commit 782c73b694
@@ -451,8 +451,8 @@ func (h *ContextHandler) initContextWithToken(reqContext *models.ReqContext, org
token, err := h.AuthTokenService.LookupToken(ctx, rawToken)
if err != nil {
reqContext.Logger.Warn("failed to look up session from cookie", "error", err)
if errors.Is(err, models.ErrUserTokenNotFound) || errors.Is(err, models.ErrInvalidSessionToken) {
// Burn the cookie in case of invalid, expired or missing token
if errors.Is(err, models.ErrInvalidSessionToken) {
// Burn the cookie in case of invalid or revoked token
reqContext.Resp.Before(h.deleteInvalidCookieEndOfRequestFunc(reqContext))
}