@@ -114,13 +114,13 @@ session:
114114 whoami :
115115 tokenizer :
116116 templates :
117- jwt_template_1 :
118- jwks_url : base64://... # A JSON Web Key Set (required)
119- claims_mapper_url : base64://... # A JsonNet template for modifying the claims
120- ttl : 1m # 1 minute (defaults to 10 minutes)
121- subject_source : id # (optional, defaults to id, other option: external_id if you're using `external_id` on identities)
122- another_jwt_template :
123- jwks_url : base64://... # A JSON Web Key Set
117+ jwt_template_1 :
118+ jwks_url : base64://... # A JSON Web Key Set (required)
119+ claims_mapper_url : base64://... # A JsonNet template for modifying the claims
120+ ttl : 1m # 1 minute (defaults to 10 minutes)
121+ subject_source : id # (optional, defaults to id, other option: external_id if you're using `external_id` on identities)
122+ another_jwt_template :
123+ jwks_url : base64://... # A JSON Web Key Set
124124` ` `
125125
126126### JSON Web Token claim mapper
@@ -220,3 +220,17 @@ If the key set contains more than one key, the first key in the list will be use
220220 ],
221221}
222222` ` `
223+
224+ # ## Handling `external_id` in the JWT sub claim
225+
226+ If your identities use `external_id`, set `subject_source` to `external_id` in the tokenizer template to populate the JWT sub
227+ claim with that value.
228+
229+ Tokenization will fail if `subject_source` is set to `external_id` but an identity is missing `external_id`. This is a security
230+ measure that prevents issuing tokens with the same sub claim for different identities, since identity IDs and `external_id` values
231+ are only guaranteed to be unique within their own namespaces, not across both.
232+
233+ To avoid this, configure a webhook to automatically set `external_id` for new identities (for example using the same ID generation
234+ logic as your previous system).
235+
236+ After migration, you can switch to using Ory identity IDs and set `subject_source` back to `id`.
0 commit comments