Skip to content

Commit b920d9a

Browse files
Merge branch 'main' into 1965
2 parents bbc4347 + b92c9bf commit b920d9a

File tree

70 files changed

+938
-244
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+938
-244
lines changed

.version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v4.1.0
1+
v4.3.0

CHANGELOG.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
# Change Log
22

3+
## [v4.3.0](https://github.com/auth0/nextjs-auth0/tree/v4.3.0) (2025-03-28)
4+
[Full Changelog](https://github.com/auth0/nextjs-auth0/compare/v4.2.1...v4.3.0)
5+
6+
**Added**
7+
- Access Token Exposure Control [\#1979](https://github.com/auth0/nextjs-auth0/pull/1979) ([tusharpandey13](https://github.com/tusharpandey13))
8+
- Cookie chunking support [\#1975](https://github.com/auth0/nextjs-auth0/pull/1975) ([tusharpandey13](https://github.com/tusharpandey13))
9+
- Add idToken to TokenSet in SessionData [\#1978](https://github.com/auth0/nextjs-auth0/pull/1978) ([tusharpandey13](https://github.com/tusharpandey13))
10+
11+
## [v4.2.1](https://github.com/auth0/nextjs-auth0/tree/v4.2.1) (2025-03-24)
12+
[Full Changelog](https://github.com/auth0/nextjs-auth0/compare/v4.2.0...v4.2.1)
13+
14+
**Changed**
15+
- Bump next in SDK as well as examples [\#1992](https://github.com/auth0/nextjs-auth0/pull/1992) ([frederikprijck](https://github.com/frederikprijck))
16+
17+
## [v4.2.0](https://github.com/auth0/nextjs-auth0/tree/v4.2.0) (2025-03-23)
18+
[Full Changelog](https://github.com/auth0/nextjs-auth0/compare/v4.1.0...v4.2.0)
19+
20+
**Security**
21+
- Enforce nextjs peerDependency to 14.2.25 and 15.2.3 [\#1988](https://github.com/auth0/nextjs-auth0/pull/1988) ([frederikprijck](https://github.com/frederikprijck))
22+
23+
The above security fix was done to help prevent customers being vulnerable to [Authorization Bypass in Next.js Middleware](https://github.com/advisories/GHSA-f82v-jwr5-mffw).
24+
325
## [v4.1.0](https://github.com/auth0/nextjs-auth0/tree/v4.1.0) (2025-03-13)
426
[Full Changelog](https://github.com/auth0/nextjs-auth0/compare/v4.0.3...v4.1.0)
527

EXAMPLES.md

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
- [Custom routes](#custom-routes)
3333
- [Testing helpers](#testing-helpers)
3434
- [`generateSessionCookie`](#generatesessioncookie)
35+
- [Programmatically starting interactive login](#programmatically-starting-interactive-login)
36+
- [Passing authorization parameters](#passing-authorization-parameters-1)
37+
- [The `returnTo` parameter](#the-returnto-parameter-1)
38+
- [Redirecting the user after authentication](#redirecting-the-user-after-authentication-1)
3539

3640
## Passing authorization parameters
3741

@@ -60,14 +64,18 @@ The `returnTo` parameter can be appended to the login to specify where you would
6064

6165
For example: `/auth/login?returnTo=/dashboard` would redirect the user to the `/dashboard` route after they have authenticated.
6266

67+
> [!NOTE]
68+
> The URL specified as `returnTo` parameters must be registered in your client's **Allowed Callback URLs**.
69+
70+
6371
### Redirecting the user after logging out
6472

6573
The `returnTo` parameter can be appended to the logout to specify where you would like to redirect the user after they have logged out.
6674

6775
For example: `/auth/login?returnTo=https://example.com/some-page` would redirect the user to the `https://example.com/some-page` URL after they have logged out.
6876

6977
> [!NOTE]
70-
> The URLs specified as `returnTo` parameters must be registered in your client's **Allowed Logout URLs**.
78+
> The URL specified as `returnTo` parameters must be registered in your client's **Allowed Logout URLs**.
7179
7280
## Accessing the authenticated user
7381

@@ -185,6 +193,15 @@ export async function middleware(request: NextRequest) {
185193
> [!IMPORTANT]
186194
> The `request` object must be passed as a parameter to the `getSession(request)` method when called from a middleware to ensure that any updates to the session can be read within the same request.
187195
196+
## Accessing the idToken
197+
`idToken` can be accessed from the session in the following way:
198+
199+
```js
200+
const session = await auth0.getSession();
201+
const idToken = session.tokenSet.idToken;
202+
```
203+
204+
188205
## Updating the session
189206

190207
The `updateSession` method could be used to update the session of the currently authenticated user in the App Router, Pages Router, and middleware. If the user does not have a session, an error will be thrown.
@@ -754,31 +771,66 @@ const sessionCookieValue = await generateSessionCookie(
754771
```
755772

756773

757-
## Programmatic Pushed Authentication Requests (PAR)
774+
## Programmatically starting interactive login
758775

759-
The method `startInteractiveLogin` can be called with authorizationParams to initiate an interactive login flow.
760-
The code collects authorization parameters on the server side rather than constructing them directly in the browser.
776+
Additionally to the ability to initialize the interactive login process by redirecting the user to the built-in `auth/login` endpoint,
777+
the `startInteractiveLogin` method can also be called programmatically.
761778

762779
```typescript
763-
// app/api/auth/login/route.ts
764780
import { auth0 } from "./lib/auth0";
765781
import { NextRequest } from "next/server";
766782

767783
export const GET = async (req: NextRequest) => {
768-
// Extract custom parameters from request URL if needed
769-
const searchParams = Object.fromEntries(req.nextUrl.searchParams.entries());
784+
return auth0.startInteractiveLogin();
785+
};
786+
```
787+
788+
### Passing authorization parameters
789+
790+
There are 2 ways to customize the authorization parameters that will be passed to the `/authorize` endpoint when calling `startInteractiveLogin` programmatically. The first option is through static configuration when instantiating the client, like so:
791+
792+
```ts
793+
export const auth0 = new Auth0Client({
794+
authorizationParameters: {
795+
scope: "openid profile email",
796+
audience: "urn:custom:api",
797+
},
798+
});
799+
```
800+
801+
The second option is by configuring `authorizationParams` when calling `startInteractiveLogin`:
802+
803+
```ts
804+
import { auth0 } from "./lib/auth0";
805+
import { NextRequest } from "next/server";
770806

807+
export const GET = async (req: NextRequest) => {
771808
// Call startInteractiveLogin with optional parameters
772809
return auth0.startInteractiveLogin({
773-
// a custom returnTo URL can be specified
774-
returnTo: "/dashboard",
775810
authorizationParameters: {
776-
prompt: searchParams.prompt,
777-
login_hint: searchParams.login_hint,
778-
// Add any custom auth parameters if required
779-
audience: "custom-audience"
811+
scope: "openid profile email",
812+
audience: "urn:custom:api",
780813
}
781814
});
782815
};
816+
```
783817

784-
```
818+
## The `returnTo` parameter
819+
820+
### Redirecting the user after authentication
821+
822+
When calling `startInteractiveLogin`, the `returnTo` parameter can be configured to specify where you would like to redirect the user to after they have completed their authentication and have returned to your application.
823+
824+
```ts
825+
import { auth0 } from "./lib/auth0";
826+
import { NextRequest } from "next/server";
827+
828+
export const GET = async (req: NextRequest) => {
829+
return auth0.startInteractiveLogin({
830+
returnTo: '/dashboard',
831+
});
832+
};
833+
```
834+
835+
> [!NOTE]
836+
> The URLs specified as `returnTo` parameters must be registered in your client's **Allowed Callback URLs**.

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ You can customize the client by using the options below:
151151

152152
The SDK mounts 6 routes:
153153

154-
1. `/auth/login`: the login route that the user will be redirected to to start a initiate an authentication transaction
155-
2. `/auth/logout`: the logout route that must be addedto your Auth0 application's Allowed Logout URLs
156-
3. `/auth/callback`: the callback route that must be addedto your Auth0 application's Allowed Callback URLs
154+
1. `/auth/login`: the login route that the user will be redirected to to initiate an authentication transaction
155+
2. `/auth/logout`: the logout route that must be added to your Auth0 application's Allowed Logout URLs
156+
3. `/auth/callback`: the callback route that must be added to your Auth0 application's Allowed Callback URLs
157157
4. `/auth/profile`: the route to check the user's session and return their attributes
158158
5. `/auth/access-token`: the route to check the user's session and return an access token (which will be automatically refreshed if a refresh token is available)
159159
6. `/auth/backchannel-logout`: the route that will receive a `logout_token` when a configured Back-Channel Logout initiator occurs
@@ -165,7 +165,7 @@ The SDK mounts 6 routes:
165165
We appreciate feedback and contribution to this repo! Before you get started, please read the following:
166166

167167
- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)
168-
- [Auth0's code of conduct guidelines](https://github.com/auth0/express-openid-connect/blob/master/CODE-OF-CONDUCT.md)
168+
- [Auth0's code of conduct guidelines](https://github.com/auth0/nextjs-auth0/blob/main/CODE-OF-CONDUCT.md)
169169
- [This repo's contribution guide](./CONTRIBUTING.md)
170170

171171
### Raise an issue
@@ -189,5 +189,5 @@ Please do not report security vulnerabilities on the public GitHub issue tracker
189189
Auth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout <a href="https://auth0.com/why-auth0">Why Auth0?</a>
190190
</p>
191191
<p align="center">
192-
This project is licensed under the MIT license. See the <a href="https://github.com/auth0/express-openid-connect/blob/master/LICENSE"> LICENSE</a> file for more info.
192+
This project is licensed under the MIT license. See the <a href="https://github.com/auth0/nextjs-auth0/blob/main/LICENSE"> LICENSE</a> file for more info.
193193
</p>

docs/assets/hierarchy.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)