Changelog
View Source4.x
Breaking
Charon.SessionStore.RedisStore- Requires Redis >= 8.0.0 or Valkey >= 9.0.0 or another Redis-compatible key-value store with support for HSETEX and related Redis 8 commands.
- Simplified implementation that relies on expiring hash fields. This means a single datastructure (instead of 3) now holds a user's sessions, and only a single Redis function is needed instead of several.
- Added
Charon.SessionStore.RedisStore.Migrate.migrate_v3_to_v4!/1to facilitate the upgrade. The function should be called during a maintenance window to avoid losing sessions.
Charon.TokenFactory.Jwtdropped support for Blake3 (keyed hashing) signed JWTs, because the Elixir Blake3 lib is unmaintained. The factory now only support OTP:crypto-backed algorithms.Config option
:enforce_browser_cookieshas been flipped to true, as a secure default. This can cause problems if you have browser clients that use:bearertoken transport (which they shouldn't).Charon.Utils.KeyGeneratorno longer caches keys in:persistent_term. A simple cache helper has been added asCharon.Utils.PersistentTermCache. While caching of derived keys is often desirable, caching using:persistent_termis not always appropriate; this should not be used for dynamically generated keys, for example, but only for create-once-use-often keys. Calling code should decide this for itself.3.x marked-deprecated functions have been removed:
Charon.Utils.get_token_signature_transport/1Charon.Utils.set_token_signature_transport/2Charon.Utils.set_user_id/2Charon.TokenPlugs.get_token_sig_from_cookie/2
Non-breaking
Charon.SessionPlugs/Charon.Config- Config option
:gen_idnow allows overriding the session / access token / refresh token ID generator. The default remains the same - a 128-bits random url64-encoded string. Generated IDs must be unique and must be a binary.
- Config option
get_token_from_cookie/2no longer checks if a previously found bearer token ends in a dot. If both the authorization-header and the cookie are set, the cookie contents are always appended to the bearer token. Because signature verification will fail if the result is not a valid JWT, there was no added security benefit to the check.
3.4.1
- Fix a Blake3-related compiler warning.
3.4.0
- Support generating Poly1305 nonces using a configurable function, with
Charon.TokenFactory.Jwtconfig option:gen_poly1305_nonce. Generated nonces must be unique.
3.3.0
- Require Elixir 1.14
- Support Poly1305-signed JWTs by passing a key with type
:poly1305toCharon.TokenFactory.Jwt. - Default to
JSONinstead ofJasonon Elixir >= 1.18
3.2.0
- Drop
FastGlobaldependency in favor of OTP's:persistent_termfor caching derived keys.
3.1.0
- Supports cookie-only tokens (access / refresh tokens fully added to cookies) using
Charon.SessionPlugs.upsert_session/3opt:token_transport. - Support config option
:enforce_browser_cookiesto force browser clients to not use bearer tokens without any cookies. Browsers are detected by the presence of header "sec-fetch-mode", which is set by all major browsers on every request. - Improve test support.
3.x
Breaking
Charon.SessionStore.RedisStore- requires Redis >= 7.x.x
- uses a Redix connection pool by itself, which requires initialization under the application supervision tree
- implements optimistic locking
- uses a new storage format based on hash sets, to which sessions are migrated starting from Charon 2.8
- uses Redis functions to implement all session store operations in a single round trip to the Redis instance
- support for unsigned binaries has been dropped
- config options
:allow_unsigned?has been removed migrate_sessions/1has been removed- sessions that have not been migrated using
migrate_sessions/1can no longer be used
- config options
Charon.SessionStore.LocalStore- implements optimistic locking
2.x marked-deprecated functions have been removed:
Charon.Models.Session.deserialize/2Charon.Models.Session.serialize/1Charon.SessionStore.delete/3Charon.SessionStore.get/3Charon.SessionStore.delete_all/2Charon.SessionStore.get_all/2Charon.SessionStore.RedisStore.cleanup/1Charon.TokenPlugs.verify_refresh_token_fresh/2
Charon.TokenPlugs.verify_token_signature/2no longer adds default value "full" for claim "styp". This should not result in issues for tokens created by Charon 2.x.x deployments. Older deployments may wish to add a plug afterCharon.TokenPlugs.verify_token_signature/2that adds this default claim.