lua-resty-session
lua-resty-session copied to clipboard
Revoke cookie sessions by application-supplied key
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:
- 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 existingrevocationstorage,hash_storage_keyandrevocation_fail_mode. - Add
session.revoke(key, ttl, configuration)to write a mark for an arbitrary key without an open session. - 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 asubrevocation is not locked out.
First consumer would be a Back-Channel Logout receiver in lua-resty-openidc (zmartzone/lua-resty-openidc#572).