Hi,
We’re using the JWT access token to manage SPA’s access to its REST API.
The token scopes are used to grant custom permissions, for instance:
{
"iss": "https://example.auth0.com/",
"sub": "auth0|user1234567890abcdefghij",
"aud": [
"https://api.example.com/",
"https://example.auth0.com/userinfo"
],
"iat": 1592186168,
"exp": 1592272568,
"azp": "AuthorizedPartyClientID123456789",
"scope": "openid profile email read:builds create:builds update:builds"
}
The protected API endpoint POST /builds
triggers a long-running build job.
The system needs to track completion of the build and record its result.
Once the job finishes, it can notify the API endpoint PUT /builds/<build_id>
.
It’s desirable to restrict access to this endpoint via Auth0 analogically to other endpoints.
The API does need the user context (user_id) to function.
Can the API server issue a new JWT with a subset of scopes of the original JWT?
The API server does have full access to the Auth0 Management API.
Newly issued token should be valid at the time when the build job finishes.
Thus, the token’s lifetime may need to exceed that of the original JWT.
The desired token claims would be as follows:
{
"iss": "https://example.auth0.com/",
"sub": "auth0|user1234567890abcdefghij",
"aud": [
"https://api.example.com/"
],
"iat": 1593186168,
"exp": 1593358968,
"azp": "AuthorizedPartyClientID123456789",
"scope": "update:builds"
}
I hope it is possible with Auth0. Otherwise, the endpoint would have to be “public” only protected by custom home-grown mechanisms involving a random secret in a persistent storage. That’s highly undesirable as the persistent storage/database is not in place in this serverless architecture.