npm
packages, and can connect external integrations that enhance your overall extensibility experience. To learn more about what Actions offer, read Understand How Auth0 Actions Work.To help with your migration, we offer guides that will help you migrate from Rules to Actions and migrate from Hooks to Actions. We also have a dedicated Move to Actions page that highlights feature comparisons, an Actions demo, and other resources to help you on your migration journey.To read more about the Rules and Hooks deprecation, read our blog post: Preparing for Rules and Hooks End of Life.context.redirect
property as follows:
context.redirect.url
property. Auth0 also passes a state
parameter in that URL. For example:
state
parameter and send it back to Auth0 to resume the authentication transaction. State is an opaque value, used to prevent Cross-Site Request Forgery (CSRF) attacks.
After the redirect, resume authentication by redirecting the user to the /continue
endpoint and include the state
parameter you received in the URL. If you do not send the original state back to the /continue
endpoint, Auth0 will lose the context of the login transaction and the user will not be able to log in due to an invalid_request
error.
For example:
THE_ORIGINAL_STATE
is the value that Auth0 generated and sent to the redirect URL. For example, if your rule redirected to https://example.com/foo
, Auth0 would use a redirect URL similar to https://example.com/foo?state=abc123
. So abc123
would be the THE_ORIGINAL_STATE
. To resume the authentication transaction, you would redirect to:
/continue
endpoint:
context.redirect
will be ignored to allow authentication to continue./continue
endpoint. For example, updates through the Auth0 are available after continuing the transaction.context.protocol
property:
authorize_again
claim from the verified and decoded JWT, then proceeds to redirect the user to that URL allowing them to sign in with their new password.UnauthorizedError
).
If, however, you need to communicate directly back to Auth0 and give it instructions for restricting access (you are implementing CAPTCHA checks or custom MFA), then you must have a way to securely tell Auth0 that the requirements of that operation were performed. Likewise, if you need to hand information to the application that you are redirecting to, then you must have a secure way to ensure that the information transferred has not been tampered with.
Token Element | Description |
---|---|
sub | The Auth0 user_id of the user. |
iss | An identifier that identifies the rule itself. |
aud | The application that is targeted for the redirect. |
jti | A randomly generated string that is stored for confirmation in the user object (in the rule code, set user.jti = uuid.v4(); and then add it as a jti to the token you create). user.jti will still be set when rules run again when /continue is called. This is inline with specifications. |
exp | Should be as short as possible to avoid re-use of the token. |
other | Any other custom claims information you need to pass. |
signature | Assuming that the application has a secure place to store a secret, you can use HS256 signed signatures. This greatly reduces the complexity of the solution and since the token being passed back will have to be signed as well, this is a requirement of this solution. You can use RS256, but it requires the creating of a certificate and updating that certificate when it expires. If you are not passing any information directly back to the rules, then you could use an SPA for this intermediate app and then may prefer RS256 so that the application doesn’t have to store the info. It would require you to have a way to validate the token, either through an introspection endpoint or through a public JWKS endpoint. |
/continue
endpoint. Only if the rule itself must get information and that information is only relevant to this particular sign in session should you pass information back to the rule.
When passing information back to the /continue
endpoint, the token passed should have the following requirements:
Token Element | Description |
---|---|
sub | The Auth0 user_id of the user. |
iss | The application that is targeted for the redirect. |
aud | Some identifier that identifies the rule itself. |
jti | The same JTI that was stored in the token passed to the application (NOTE: it should match user.jti or fail). |
exp | Should be as short as possible to avoid reuse of the token. |
other | Any other custom claims information you need to pass. |
signature | Assuming that the application has a secure place to store a secret, you can use HS256 signed signatures. This greatly reduces the complexity of the solution and since the token being passed back will have to be signed as well, this is a requirement of this solution. You can use RS256, but it requires the creating of a certificate and updating that certificate when it expires. |
context.request.body.token
(or something similar) rather than passing it as a query parameter. This is similar to the form-post method for authentication.
If you are not passing information back to the /continue
endpoint, you may want to denylist the JTI unless your expiration times are short enough that replay attacks will be almost impossible.
context.protocol
:
context.protocol === 'oauth2-password'
context.protocol === 'oauth2-refresh-token'
context.protocol === 'oauth2-resource-owner'
/oauth/token
directly for the Resource Owner Password Grant. Since the user is not in a redirect flow to begin with, you can not redirect the user in a rule. If you attempt to set context.redirect you will get a failed login attempt with the error interaction_required.
prompt=none
is to avoid any scenario where the user will be required to enter input, any redirection will result in an error=interaction_required
.
Since rules run after an authentication session is created, you cannot use prompt=none
if you have a redirect rule that is attempting to block access to tokens under certain conditions (custom MFA, CAPTCHA with login, etc.).
You cannot create a redirect flow that blocks token access and bypasses the redirect rule if prompt=none
because after a failed attempt, a user can simply call again with prompt=none
and get tokens because their authentication session has been created even though rules failed the first time.
/oauth/token
, this will also fail if you set context.redirect
.
It is difficult to securely verify that any restrictions on login were carried out. There is not a consistent session ID in the context that could be used to collect information associated with the session such as this user passed MFA challenges. Therefore, you cannot use prompt=none
at all.
Anytime context.redirect
is set in a rule, if prompt=none
was passed, then the authorization fails with error=interaction_required
, but since the user’s session is created even if rules fail, we can’t trust that a user passed all context.redirect
challenges and therefore can’t use prompt=none
as a way to get tokens.
In this specific case, we recommend that you use refresh tokens exclusively, because you can ensure that a user passed challenges if those challenges are required to generate a refresh token.