Skip to main content
By default, KavachOS allows unlimited concurrent sessions per user. The multi-session module adds a cap, a configurable overflow strategy, and endpoints for listing and revoking sessions, useful for building an “active devices” settings page.

Setup

lib/kavach.ts

Overflow strategies

List sessions

GET /auth/sessions Returns all active sessions for the authenticated user. Useful for building an “active devices” UI.
List sessions (client)
Response shape
Device information is parsed from the User-Agent header at sign-in time. IP addresses are stored as-is, apply your own masking if required.

Revoke a session

DELETE /auth/sessions/:id Revokes a specific session. Users can revoke any of their own sessions, including the current one.
Revoke session (client)

Revoke all other sessions

DELETE /auth/sessions Revokes all sessions for the user except the current one. Useful for “sign out everywhere else” buttons.
Sign out all other devices (client)

Configuration reference

number
default:"0 (unlimited)"
Maximum concurrent sessions per user. Set to 0 for unlimited.
'evict-oldest' | 'reject'
default:"'evict-oldest'"
What to do when a new sign-in would exceed maxSessions.
boolean
default:"true"
Parse and store browser/OS information from the User-Agent header.
boolean
default:"true"
Store the IP address of the sign-in request.
Last modified on April 18, 2026