lua-resty-session icon indicating copy to clipboard operation
lua-resty-session copied to clipboard

Revoke cookie sessions by application-supplied key

Open janiussyafiq opened this issue 2 months ago • 0 comments

4.2.0 (#209) added a revocation denylist for cookie sessions. It is keyed by the session id and only written from session:destroy(), so it covers logouts that go through this library.

It does not cover logouts initiated by an identity provider. With OpenID Connect Back-Channel Logout the OP POSTs a logout token to the RP with no cookie. The token identifies the session by OIDC sid or the user by sub. There is no session to open and no way to map those claims to a session id. #147 is the same problem for SAML logout requests.

Proposal:

  1. Let a session carry application-defined revocation keys in the cookie payload, e.g. session:set_revocation_keys({ "sid:<iss>#<sid>", "sub:<iss>#<sub>" }). open() checks the session id plus each key, through the existing revocation storage, hash_storage_key and revocation_fail_mode.
  2. Add session.revoke(key, ttl, configuration) to write a mark for an arbitrary key without an open session.
  3. Store the revocation time as the mark value instead of the fixed "1". A key mark then revokes only sessions created at or before that time, so a user who logs in again after a sub revocation is not locked out.

First consumer would be a Back-Channel Logout receiver in lua-resty-openidc (zmartzone/lua-resty-openidc#572).

janiussyafiq avatar Sep 08 '26 03:09 janiussyafiq