Overview
Proper logout implementation is critical for application security. Logout involves invalidating user sessions, revoking tokens, and clearing authentication state both on the client and server side.Logout Flow
A complete logout implementation requires several steps:- Revoke Tokens: Invalidate access and refresh tokens
- Clear Server Session: Remove session data from server-side storage
- Clear Client State: Remove cookies and client-side authentication data
- Optional IdP Logout: Redirect to Identity Provider logout (for SSO)
Revoke User Sessions
Scalekit provides session management endpoints to revoke active user sessions.Revoke Single Session
Revoke a specific user session by session ID:Revoke All User Sessions
Revoke all active sessions for a user (useful for security incidents):Clear Client-Side State
Remove all authentication data from the client:Identity Provider Logout (SSO)
For SSO users, you may want to log them out of their Identity Provider as well:Single Logout (SLO) URL
Redirect users to their IdP logout endpoint:Complete Logout Implementation
Here’s a complete logout handler that combines all best practices:Security Best Practices
Next Steps
Session Management
Learn about session validation and refresh
API Overview
Return to API documentation overview