How would you approach session management after authentication state changes?
Answer
Start by mapping which events should invalidate an existing session, password changes, role changes, explicit logout-everywhere requests, and where that invalidation is actually enforced. Focus on session management after authentication state changes. Use explicit, server-side session invalidation as the oracle: a session must stop working the moment a security-sensitive event happens, not merely stop being offered in the UI. Cover the exact gap attackers exploit after a credential leak, an old session on another device continuing to work after the password changes elsewhere. Keep data and dependencies controlled enough to reproduce the two-device timing. Release only when logging in on two devices, changing the password or role on one, and confirming the other is logged out within one request is part of the regression suite.
Strong answer includes
- explicit risk and test oracle for session management
- tests server-side session invalidation, not UI-level logout
- covers the credential-leak two-device gap
- measurable evidence and residual-risk statement
Practical example
After a user changed their password, their old session on a second device stayed valid and could still place orders, which is exactly the kind of gap attackers exploit after a credential leak. The approach was to invalidate all other active sessions on password change and add a test that logs in on two devices, changes the password on one, and confirms the other is logged out within one request.