Skip to content

Commit 8fbdcbf

Browse files
committed
chore: synchronize workspaces
1 parent 87b398f commit 8fbdcbf

File tree

1 file changed

+38
-6
lines changed

1 file changed

+38
-6
lines changed

docs/getting-started/integrate-auth/14_auth-js.mdx

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,49 @@ cp .env.local.example .env.local
3030
npx auth secret
3131
```
3232

33-
In the `auth.ts` file, replace the `profiders` array with just Ory:
33+
In the `auth.ts` file, replace the `providers` array with just Ory:
3434

3535
```ts title="auth.ts"
36-
import { OryNetworkCta } from "./ory-network-cta"
36+
import { Profile } from "next-auth"
37+
import { OIDCConfig } from "next-auth/providers"
38+
3739
export const config = {
3840
theme: { logo: "https://authjs.dev/img/logo-sm.png" },
3941
providers: [
40-
// Apple,
41-
// AzureB2C,
42-
Ory,
42+
{
43+
id: "ory",
44+
name: "Ory",
45+
type: "oidc",
46+
issuer: process.env.ORY_SDK_URL,
47+
clientId: process.env.ORY_CLIENT_ID,
48+
clientSecret: process.env.ORY_CLIENT_SECRET,
49+
checks: ["pkce" as never, "state" as never],
50+
token: {
51+
idToken: true,
52+
},
53+
} satisfies OIDCConfig<Profile>,
4354
],
55+
callbacks: {
56+
authorized({ request, auth }) {
57+
const { pathname } = request.nextUrl
58+
if (pathname === "/middleware-example") return !!auth
59+
return true
60+
},
61+
session({ session, token }) {
62+
session.sid = token.sid as string
63+
session.idToken = token.idToken as string
64+
return session
65+
},
66+
jwt({ token, user, account, profile, isNewUser }) {
67+
if (profile) {
68+
token.sid = profile.sid
69+
}
70+
if (account) {
71+
token.idToken = account.id_token
72+
}
73+
return token
74+
},
75+
},
4476
// ...
4577
}
4678
```
@@ -103,7 +135,7 @@ AUTH_ORY_ISSUER=...
103135
Now everything is set up and you can run `npm run dev` to start the app and click on the top left "Sign in" button to start the
104136
login flow.
105137

106-
## Going to production
138+
## Go to production
107139

108140
When you are ready to go to production, you need to update the redirect URL in the Ory client settings to the production URL of
109141
your Next.js application.

0 commit comments

Comments
 (0)