Changelog - 2026-11-06
An encrypted bearer token keeps null claims
Bug FixIn one line. With applicationSecret set, a claim whose value is null used to be dropped from the token, so someId: null arrived as no someId at all. It is now kept and decodes as null, the same as without encryption.
What changed
nullis a value.AbstractBearerTokenService.encryptPayloadencrypts anullclaim like any other, and it decodes asnull. An app can tell "null on purpose" from "claim absent", for example an older token.undefinedis still skipped. JSON drops it, so the claim is absent with encryption on or off.- Same payload either way. The encrypted and the plain mode decode the same payload to the same object.
- A
nullnever reaches a field codec. It is written and read as the textnullbefore the codec for its key is consulted, so a codec that expects a value, such as a date codec, is not called withnull. The one cost: a codec whose real output for a non-null value is exactly the textnullwould read back asnull; none of the built-in codecs does that.
Who is affected
- Apps with
applicationSecretthat mint tokens withnullclaims. Those claims now arrive asnullinstead of missing. Code that read a missing claim asundefinedand now meetsnullshould check for both. The framework reads anulluserId,principalTypeorrolesas it read a missing one: authorization treatsroles: nullas no roles and refuses anullprincipalType, and anulluserIdis not a user id (theallauthentication mode rejects it). - Tokens already issued. Unchanged: a token minted without the key still decodes without it.
- Everyone else. No action needed.
Details
| File | Package |
|---|---|
src/components/auth/authenticate/services/bearer/abstract.service.ts | core-server |