You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Run custom code before Auth Handlers](#run-custom-code-before-auth-handlers)
52
-
-[Run code after callback](#run-code-after-callback)
52
+
-[Run custom code before Auth Handlers](#run-custom-code-before-auth-handlers)
53
+
-[Run code after callback](#run-code-after-callback)
53
54
54
55
## Passing authorization parameters
55
56
@@ -965,6 +966,7 @@ export const auth0 = new Auth0Client({
965
966
## Transaction Cookie Configuration
966
967
967
968
### Customizing Transaction Cookie Expiration
969
+
968
970
You can configure transaction cookies expiration by providing a `maxAge` proeprty for `transactionCookie`.
969
971
970
972
```ts
@@ -975,11 +977,13 @@ export const auth0 = new Auth0Client({
975
977
},
976
978
}
977
979
```
980
+
978
981
Transaction cookies are used to maintain state during authentication flows. The SDK provides several configuration options to manage transaction cookie behavior and prevent cookie accumulation issues.
| cookieOptions.maxAge | `number`| The expiration time for transaction cookies in seconds. Defaults to `3600` (1 hour). After this time, abandoned transaction cookies will expire automatically. |
1014
-
| cookieOptions.prefix | `string`| The prefix for transaction cookie names. Defaults to `__txn_`. In parallel mode, cookies are named `__txn_{state}`. In single mode, just `__txn_`. |
1015
-
| cookieOptions.sameSite | `"strict" \|"lax" \|"none"`| Controls when the cookie is sent with cross-site requests. Defaults to `"lax"`. |
1016
-
| cookieOptions.secure | `boolean`| When `true`, the cookie will only be sent over HTTPS connections. Automatically determined based on your application's base URL protocol if not specified. |
1017
-
| cookieOptions.path | `string`| Specifies the URL path for which the cookie is valid. Defaults to `"/"`. |
| cookieOptions.maxAge | `number` | The expiration time for transaction cookies in seconds. Defaults to `3600` (1 hour). After this time, abandoned transaction cookies will expire automatically. |
1021
+
| cookieOptions.prefix | `string` | The prefix for transaction cookie names. Defaults to `__txn_`. In parallel mode, cookies are named `__txn_{state}`. In single mode, just `__txn_`. |
1022
+
| cookieOptions.sameSite | `"strict" \|"lax" \|"none"` | Controls when the cookie is sent with cross-site requests. Defaults to `"lax"`. |
1023
+
| cookieOptions.secure | `boolean` | When `true`, the cookie will only be sent over HTTPS connections. Automatically determined based on your application's base URL protocol if not specified. |
1024
+
| cookieOptions.path | `string` | Specifies the URL path for which the cookie is valid. Defaults to `"/"`. |
1018
1025
1019
1026
## Database sessions
1020
1027
@@ -1041,6 +1048,28 @@ export const auth0 = new Auth0Client({
1041
1048
});
1042
1049
```
1043
1050
1051
+
## Using Client-Initiated Backchannel Authentication
1052
+
1053
+
Using Client-Initiated Backchannel Authentication can be done by calling `backchannelAuthentication()`:
- `bindingMessage`: A human-readable message to be displayed at the consumption device and authentication device. This allows the user to ensure the transaction initiated by the consumption device is the same that triggers the action on the authentication device.
1067
+
- `loginHint.sub`: The `sub` claim of the user that is trying to login using Client-Initiated Backchannel Authentication, and to which a push notification to authorize the login will be sent.
1068
+
1069
+
> [!IMPORTANT]
1070
+
> Using Client-Initiated Backchannel Authentication requires the feature to be enabled in the Auth0 dashboard.
1071
+
> Read [the Auth0 docs](https://auth0.com/docs/get-started/authentication-and-authorization-flow/client-initiated-backchannel-authentication-flow) to learn more about Client-Initiated Backchannel Authentication.
1072
+
1044
1073
## Back-Channel Logout
1045
1074
1046
1075
The SDK can be configured to listen to [Back-Channel Logout](https://auth0.com/docs/authenticate/login/logout/back-channel-logout) events. By default, a route will be mounted `/auth/backchannel-logout` which will verify the logout token and call the `deleteByLogoutToken` method of your session store implementation to allow you to remove the session.
@@ -1402,6 +1431,7 @@ export async function middleware(request: NextRequest) {
1402
1431
Authentication routes (`/auth/login`, `/auth/logout`, `/auth/callback`) are handled automatically by the middleware. You can intercept these routes in your middleware to run custom logic before the auth handlers execute.
1403
1432
1404
1433
This approach allows you to:
1434
+
1405
1435
- Run custom code before authentication actions (logging, analytics, validation)
1406
1436
- Modify the response (set cookies, headers, etc.)
1407
1437
- Implement custom redirects or early returns when needed
@@ -1413,48 +1443,49 @@ The middleware-based approach provides the same level of control as v3's custom
1413
1443
### Run custom code before Auth Handlers
1414
1444
1415
1445
Following example shows how to run custom logic before the response of `logout` handler is returned:
1446
+
1416
1447
```ts
1417
1448
exportasyncfunction middleware(request) {
1449
+
// prepare NextResponse object from auth0 middleware
1450
+
const authRes =awaitauth0.middleware(request);
1418
1451
1419
-
// prepare NextResponse object from auth0 middleware
0 commit comments