Skip to content

Commit

Permalink
Web: Fix not being able to logout from session invalidation error (#4…
Browse files Browse the repository at this point in the history
  • Loading branch information
kimlisa authored Jun 11, 2024
1 parent 47014f6 commit b0de5fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
12 changes: 11 additions & 1 deletion lib/web/apiserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -2054,7 +2054,17 @@ func (h *Handler) deleteWebSession(w http.ResponseWriter, r *http.Request, _ htt

func (h *Handler) logout(ctx context.Context, w http.ResponseWriter, sctx *SessionContext) error {
if err := sctx.Invalidate(ctx); err != nil {
return trace.Wrap(err)
h.log.
WithError(err).
WithField("user", sctx.GetUser()).
Warn("Failed to invalidate sessions")
}

if err := h.auth.releaseResources(sctx.GetUser(), sctx.GetSessionID()); err != nil {
h.log.
WithError(err).
WithField("session_id", sctx.GetSessionID()).
Debug("sessionCache: Failed to release web session")
}
ClearSession(w)

Expand Down
4 changes: 1 addition & 3 deletions lib/web/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -863,9 +863,7 @@ func (s *sessionCache) invalidateSession(ctx context.Context, sctx *SessionConte
if err := clt.DeleteUserAppSessions(ctx, &proto.DeleteUserAppSessionsRequest{Username: sctx.GetUser()}); err != nil {
return trace.Wrap(err)
}
if err := s.releaseResources(sctx.GetUser(), sctx.GetSessionID()); err != nil {
return trace.Wrap(err)
}

return nil
}

Expand Down

0 comments on commit b0de5fa

Please sign in to comment.