Skip to content

feat(*): revoke cookie sessions by application supplied key - #212

Open
janiussyafiq wants to merge 6 commits into
bungle:masterfrom
janiussyafiq:feat/revoke-by-key
Open

feat(*): revoke cookie sessions by application supplied key#212
janiussyafiq wants to merge 6 commits into
bungle:masterfrom
janiussyafiq:feat/revoke-by-key

Conversation

@janiussyafiq

Copy link
Copy Markdown

Closes #211.

Summary

  • session:set_revocation_keys(keys) / session:get_revocation_keys(): opaque keys carried per audience in the encrypted payload, e.g. an identity provider's sid and sub.
  • session.revoke(key, ttl, configuration): writes a unix-timestamp mark through the existing revocation storage, no open session needed.
  • session:open rejects a session carrying a key whose mark is at or after the session's creation time; sessions created later are unaffected. The 4.2.0 mark "1" still means revoked regardless of time and destroy keeps writing it.
  • Keys go through hash_storage_key; marks share one namespace per cookie_name, remember cookies included. session.revoke always returns write errors; revocation_fail_mode is unchanged for open/destroy.
  • Mass revocation (subject, audience, before-timestamp, from the feat(*): Revocation store for stateless cookie sessions #209 review) is expressible today by attaching those values as keys, and the key -> timestamp store format lets the library auto-derive them later.

Consumer: zmartzone/lua-resty-openidc#572 (Back-Channel Logout receiver), then apache/apisix.

Test plan

  • make unit in the CI image (155 tests), make lint
  • spec/06: key round-trip without subject, mark at/after creation revokes, mark before creation does not, legacy "1" mark, unrelated key, audience scoping, remember cookie, session.revoke then reopen, created after revoke
  • spec/07: session.revoke reports a failed write in open fail mode, not-enabled error

Sessions can carry revocation keys in the encrypted payload via
session:set_revocation_keys. On open, a key whose revocation mark is at
or after the session creation time rejects the session with
"session revoked". Marks are unix timestamps; the 4.2.0 mark "1" still
means revoked regardless of time.
Writes a unix timestamp mark for an application supplied key through
the configured revocation storage, so sessions carrying that key and
created at or before the mark are rejected on open. Intended for
identity provider initiated logout, where no cookie is available.
Check every audience's revocation keys when opening a remember cookie,
since restoration mints a fresh session cookie carrying all of them.
Reset the rejected cookie's meta on revocation so a re-login does not
inherit the revoked creation time.
Run the key check before a remember cookie's data is kept for an absent
audience, and leave a rejected remember cookie with empty metadata so
save, logout and destroy do not reload its creation time.
@janiussyafiq

Copy link
Copy Markdown
Author

@bungle need help reviewing this, to support backchannel logout this feature is needed, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Revoke cookie sessions by application-supplied key

1 participant