<@U04UQ68083H> How do I inject the `aud` claim int...
# ory-copilot
b
@chilly-king-10285 How do I inject the
aud
claim into the JWT generated from a session
c
A message from kapa.ai
To inject the
aud
claim into the JWT generated from a session, you can use the
id_token
mutator in Ory Oathkeeper. This mutator allows you to specify custom claims, like the audience of ID tokens, via the
claims
field of the mutator's
config
field. Here is an example of how you can set the
aud
claim in the configuration:
Copy code
json {   "handler": "id_token",   "config": {     "claims": "{\"aud\": [\"<https://my-backend-service/some/endpoint\>"],\"def\": \"{{ print .Extra.some.arbitrary.data }}\"}"   } }
In this example, the
aud
claim is set to the URL of the backend service. The
def
claim is set to an arbitrary data from the
Extra
map. The values are parsed by the Go
text/template
package for value substitution, receiving the
AuthenticationSession
struct. Please note that certain keys (such as the
sub
) claim can't be overwritten. For more details, please check the [Ory documentation](https://www.ory.sh/docs/oathkeeper/pipeline/mutator#id_token-claims).