Claim | Description |
---|---|
exp | Token expiration |
iss | Token issuer |
aud | Intended recipient of the token |
view:balance
) or transfer funds (scope transfer:funds
). When the application asks the API to retrieve the user’s balance, the access token should contain the view:balance
scope. To transfer money to another account, the access token should contain the transfer:funds
scope.
view:balance
scope.transfer:funds
scope. The application sends a request to the API using the same access token.transfer:funds
scope.transfer:funds
scope this time.view:balance
and transfer:funds
.transfer:funds
scope is requested. Go to Dashboard > Actions > Flows and create an Action that contains the following content:
CLIENTS_WITH_MFA
variable contains the of the applications you want this Action to apply to. You can remove this (and the if
conditional that follows) if you don’t need it.event.transaction.requested_scopes
property contains all the scopes for which the authentication request asked. If it includes the value transfer:funds
, then we ask for MFA by setting the context.multifactor
property to the appropriate value. In this case, we are asking for MFA using push.Parameter | Setting |
---|---|
audience | Set to the Identifier of your API (find it at API Settings). We set ours to https://my-banking-api . |
response_type | Set to id_token token so we get both an ID Token and an Access Token in the response. |
client_id | Set to the Client ID of your application (find it at Application Settings). |
redirect_uri | Set to a URL in your application that Auth0 should redirect back to after authentication (find it at Application Settings). |
nonce | Set to a secure string value which will be included in the response from Auth0. This is used to prevent token replay attacks and is required for response_type=id_token token . |
state | Set to an opaque value that Auth0 includes when redirecting back to the application. This value must be used by the application to prevent CSRF attacks. |
GET /balance
: to retrieve the current balance
POST /transfer
: to transfer funds
Node.js
and a number of modules:
expressJwtSecret
, we can generate a secret provider that will issue the right signing key to express-jwt
based on the kid
in the JWT header.npm install express express-jwt jwks-rsa express-jwt-authz --save
server.js
file should look like the following sample script:
checkJwt
middleware.express-jwt
decodes the token and passes the request, the header, and the payload to jwksRsa.expressJwtSecret
.jwks-rsa
downloads all signing keys from the JWKS endpoint and checks if one of the signing keys matches the kid
in the header of the access token. If none of the signing keys match the incoming kid
, an error is thrown. If there is a match, we pass the right signing key to express-jwt
.express-jwt
continues its own logic to validate the signature of the token, the expiration, audience, and the issuer.jwtAuthz
checks if the scope that the endpoint requires is part of the access token. If the specified scopes are missing from the access token, the request is rejected with a 403 error message.