Skip to content

Commit

Permalink
feat: revoke Kratos session asynchronously (#3936)
Browse files Browse the repository at this point in the history
This change makes the session revocation in Kratos async to improve
observed latency.
  • Loading branch information
alnr authored Feb 20, 2025
1 parent b746e41 commit a0e7ee2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions consent/strategy_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,11 +1015,13 @@ func (s *DefaultStrategy) performBackChannelLogoutAndDeleteSession(r *http.Reque
} else if err != nil {
return err
} else {
innerErr := s.r.Kratos().DisableSession(ctx, session.IdentityProviderSessionID.String())
if innerErr != nil {
s.r.Logger().WithError(innerErr).WithField("sid", sid).Error("Unable to revoke session in ORY Kratos.")
}
// We don't return the error here because we don't want to break the logout flow if Kratos is down.
// revoke Kratos session asynchronously
go func(ctx context.Context, kratosSessionID string) {
innerErr := s.r.Kratos().DisableSession(ctx, kratosSessionID)
if innerErr != nil {
s.r.Logger().WithError(innerErr).WithField("sid", sid).WithField("kratos-sid", kratosSessionID).Error("Unable to revoke session in Ory Kratos.")
}
}(context.WithoutCancel(ctx), session.IdentityProviderSessionID.String())
}

return nil
Expand Down

0 comments on commit a0e7ee2

Please sign in to comment.