From 241cea160570932acf9e14b0f1e4af6c3e6c2126 Mon Sep 17 00:00:00 2001 From: wangsijie Date: Tue, 6 Aug 2024 16:55:51 +0800 Subject: [PATCH] feat(console): support next auth v5 (#6397) --- .../docs/guides/web-next-auth/README.mdx | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/console/src/assets/docs/guides/web-next-auth/README.mdx b/packages/console/src/assets/docs/guides/web-next-auth/README.mdx index f9959c3bc52..2911141745d 100644 --- a/packages/console/src/assets/docs/guides/web-next-auth/README.mdx +++ b/packages/console/src/assets/docs/guides/web-next-auth/README.mdx @@ -2,6 +2,8 @@ import InlineNotification from '@/ds-components/InlineNotification'; import UriInputField from '@/mdx-components/UriInputField'; import Steps from '@/mdx-components/Steps'; import Step from '@/mdx-components/Step'; +import TabItem from '@/mdx-components/TabItem'; +import Tabs from '@/mdx-components/Tabs'; @@ -31,9 +33,43 @@ Modify your API route config of Next Auth, if you are using Pages Router, the fi The following is an example of App Router: - + + + + {`import NextAuth from 'next-auth'; +export const { handlers, signIn, signOut, auth } = NextAuth({ + providers: [ + { + id: 'logto', + name: 'Logto', + type: 'oidc', + issuer: '${props.endpoint}oidc', + clientId: '${props.app.id}', + clientSecret: '${props.secrets[0]?.value ?? props.app.secret}', + authorization: { + params: { scope: 'openid offline_access profile email' }, + }, + profile(profile) { + // You can customize the user profile mapping here + return { + id: profile.sub, + name: profile.name ?? profile.username, + email: profile.email, + image: profile.picture, + }; + }, + }, + ], +});`} + + + + + +{`import NextAuth from 'next-auth'; + const handler = NextAuth({ providers: [ { @@ -64,6 +100,9 @@ const handler = NextAuth({ export { handler as GET, handler as POST };`} + + +