AuthN: Fix signout redirect url (#87631)
* Add missing return * Use sign out redirect url from auth config if configured * remove option from auth.jwt that is not used
This commit is contained in:
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/infra/tracing"
|
||||
"github.com/grafana/grafana/pkg/infra/usagestats"
|
||||
"github.com/grafana/grafana/pkg/services/auth"
|
||||
"github.com/grafana/grafana/pkg/services/auth/identity"
|
||||
"github.com/grafana/grafana/pkg/services/authn"
|
||||
"github.com/grafana/grafana/pkg/services/authn/clients"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
@@ -265,15 +264,17 @@ func (s *Service) Logout(ctx context.Context, user authn.Requester, sessionToken
|
||||
defer span.End()
|
||||
|
||||
redirect := &authn.Redirect{URL: s.cfg.AppSubURL + "/login"}
|
||||
if s.cfg.SignoutRedirectUrl != "" {
|
||||
redirect.URL = s.cfg.SignoutRedirectUrl
|
||||
}
|
||||
|
||||
namespace, id := user.GetNamespacedID()
|
||||
if namespace != authn.NamespaceUser {
|
||||
if !user.GetID().IsNamespace(authn.NamespaceUser) {
|
||||
return redirect, nil
|
||||
}
|
||||
|
||||
userID, err := identity.IntIdentifier(namespace, id)
|
||||
id, err := user.GetID().ParseInt()
|
||||
if err != nil {
|
||||
s.log.FromContext(ctx).Debug("Invalid user id", "id", userID, "err", err)
|
||||
s.log.FromContext(ctx).Debug("Invalid user id", "id", id, "err", err)
|
||||
return redirect, nil
|
||||
}
|
||||
|
||||
@@ -301,7 +302,7 @@ func (s *Service) Logout(ctx context.Context, user authn.Requester, sessionToken
|
||||
}
|
||||
|
||||
Default:
|
||||
if err = s.sessionService.RevokeToken(ctx, sessionToken, false); err != nil {
|
||||
if err = s.sessionService.RevokeToken(ctx, sessionToken, false); err != nil && !errors.Is(err, auth.ErrUserTokenNotFound) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user