From 7c1a3b547e9b1d177a1ce048556edefaa14580e5 Mon Sep 17 00:00:00 2001
From: GitHub Actions
Date: Sun, 5 Mar 2023 05:08:02 +0000
Subject: [PATCH 01/80] chore(release): bump package version(s) [skip ci]
---
packages/core/package.json | 2 +-
packages/frameworks-sveltekit/package.json | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/packages/core/package.json b/packages/core/package.json
index d1090362..b9edd730 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@auth/core",
- "version": "0.5.0",
+ "version": "0.5.1",
"description": "Authentication for the Web.",
"keywords": [
"authentication",
diff --git a/packages/frameworks-sveltekit/package.json b/packages/frameworks-sveltekit/package.json
index 6ab964c3..4adba140 100644
--- a/packages/frameworks-sveltekit/package.json
+++ b/packages/frameworks-sveltekit/package.json
@@ -1,6 +1,6 @@
{
"name": "@auth/sveltekit",
- "version": "0.2.2",
+ "version": "0.3.0",
"description": "Authentication for SvelteKit.",
"keywords": [
"authentication",
From 5cb8dd5f370492eb2490bbfded75cd7dded8235b Mon Sep 17 00:00:00 2001
From: Lluis Agusti
Date: Sun, 5 Mar 2023 15:56:10 +0100
Subject: [PATCH 02/80] fix(docs): add docs to source code (#6870)
* docs(adapters): move dgraph adapters docs to source code
* refactor: review suggestions (1)
---
.gitignore | 2 +-
docs/docs/reference/06-adapters/dgraph.md | 248 ---------------------
docs/docusaurus.config.js | 15 ++
docs/sidebars.js | 1 +
packages/adapter-dgraph/src/index.ts | 249 ++++++++++++++++++++++
5 files changed, 266 insertions(+), 249 deletions(-)
delete mode 100644 docs/docs/reference/06-adapters/dgraph.md
diff --git a/.gitignore b/.gitignore
index 1f4e2442..8b34733c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,7 +14,7 @@ yarn-error.log*
firebase-debug.log
ui-debug.log
.pnpm-debug.log
-
+.husky
# Dependencies
node_modules
diff --git a/docs/docs/reference/06-adapters/dgraph.md b/docs/docs/reference/06-adapters/dgraph.md
deleted file mode 100644
index a395059c..00000000
--- a/docs/docs/reference/06-adapters/dgraph.md
+++ /dev/null
@@ -1,248 +0,0 @@
----
-id: dgraph
-title: Dgraph
----
-
-This is the Dgraph Adapter for [`next-auth`](https://authjs.dev).
-
-## Getting Started
-
-1. Install the necessary packages
-
-```bash npm2yarn
-npm install next-auth @next-auth/dgraph-adapter
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```javascript title="pages/api/auth/[...nextauth].js"
-import NextAuth from "next-auth"
-import { DgraphAdapter } from "@next-auth/dgraph-adapter"
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-options
-export default NextAuth({
- // https://authjs.dev/reference/provideres/oauth-builtin
- providers: [],
- adapter: DgraphAdapter({
- endpoint: process.env.DGRAPH_GRAPHQL_ENDPOINT,
- authToken: process.env.DGRAPH_GRAPHQL_KEY,
-
- // you can omit the following properties if you are running an unsecure schema
- authHeader: process.env.AUTH_HEADER, // default: "Authorization",
- jwtSecret: process.env.SECRET,
- }),
-})
-```
-
-## Quick start with the unsecure schema
-
-The quickest way to use Dgraph is by applying the unsecure schema to your [local](https://dgraph.io/docs/graphql/admin/#modifying-a-schema) Dgraph instance or if using Dgraph [cloud](https://dgraph.io/docs/cloud/cloud-quick-start/#the-schema) you can paste the schema in the codebox to update.
-
-:::warning
-This approach is not secure or for production use, and does not require a `jwtSecret`.
-:::
-
-> This schema is adapted for use in Dgraph and based upon our main [schema](/reference/adapters/models)
-
-#### Unsecure schema
-
-```graphql
-type Account {
- id: ID
- type: String
- provider: String @search(by: [hash])
- providerAccountId: String @search(by: [hash])
- refreshToken: String
- expires_at: Int64
- accessToken: String
- token_type: String
- refresh_token: String
- access_token: String
- scope: String
- id_token: String
- session_state: String
- user: User @hasInverse(field: "accounts")
-}
-type Session {
- id: ID
- expires: DateTime
- sessionToken: String @search(by: [hash])
- user: User @hasInverse(field: "sessions")
-}
-type User {
- id: ID
- name: String
- email: String @search(by: [hash])
- emailVerified: DateTime
- image: String
- accounts: [Account] @hasInverse(field: "user")
- sessions: [Session] @hasInverse(field: "user")
-}
-
-type VerificationToken {
- id: ID
- identifier: String @search(by: [hash])
- token: String @search(by: [hash])
- expires: DateTime
-}
-```
-
-## Securing your database
-
-For production deployments you will want to restrict the access to the types used
-by next-auth. The main form of access control used in Dgraph is via `@auth` directive alongside types in the schema.
-
-#### Secure schema
-
-```graphql
-type Account
- @auth(
- delete: { rule: "{$nextAuth: { eq: true } }" }
- add: { rule: "{$nextAuth: { eq: true } }" }
- query: { rule: "{$nextAuth: { eq: true } }" }
- update: { rule: "{$nextAuth: { eq: true } }" }
- ) {
- id: ID
- type: String
- provider: String @search(by: [hash])
- providerAccountId: String @search(by: [hash])
- refreshToken: String
- expires_at: Int64
- accessToken: String
- token_type: String
- refresh_token: String
- access_token: String
- scope: String
- id_token: String
- session_state: String
- user: User @hasInverse(field: "accounts")
-}
-type Session
- @auth(
- delete: { rule: "{$nextAuth: { eq: true } }" }
- add: { rule: "{$nextAuth: { eq: true } }" }
- query: { rule: "{$nextAuth: { eq: true } }" }
- update: { rule: "{$nextAuth: { eq: true } }" }
- ) {
- id: ID
- expires: DateTime
- sessionToken: String @search(by: [hash])
- user: User @hasInverse(field: "sessions")
-}
-type User
- @auth(
- query: {
- or: [
- {
- rule: """
- query ($userId: String!) {queryUser(filter: { id: { eq: $userId } } ) {id}}
- """
- }
- { rule: "{$nextAuth: { eq: true } }" }
- ]
- }
- delete: { rule: "{$nextAuth: { eq: true } }" }
- add: { rule: "{$nextAuth: { eq: true } }" }
- update: {
- or: [
- {
- rule: """
- query ($userId: String!) {queryUser(filter: { id: { eq: $userId } } ) {id}}
- """
- }
- { rule: "{$nextAuth: { eq: true } }" }
- ]
- }
- ) {
- id: ID
- name: String
- email: String @search(by: [hash])
- emailVerified: DateTime
- image: String
- accounts: [Account] @hasInverse(field: "user")
- sessions: [Session] @hasInverse(field: "user")
-}
-
-type VerificationToken
- @auth(
- delete: { rule: "{$nextAuth: { eq: true } }" }
- add: { rule: "{$nextAuth: { eq: true } }" }
- query: { rule: "{$nextAuth: { eq: true } }" }
- update: { rule: "{$nextAuth: { eq: true } }" }
- ) {
- id: ID
- identifier: String @search(by: [hash])
- token: String @search(by: [hash])
- expires: DateTime
-}
-
-# Dgraph.Authorization {"VerificationKey":"","Header":"","Namespace":"","Algo":"HS256"}
-```
-
-#### Dgraph.Authorization
-
-In order to secure your graphql backend define the `Dgraph.Authorization` object at the
-bottom of your schema and provide `authHeader` and `jwtSecret` values to the DgraphClient.
-
-```js
-# Dgraph.Authorization {"VerificationKey":"","Header":"","Namespace":"YOUR CUSTOM NAMESPACE HERE","Algo":"HS256"}
-```
-
-#### VerificationKey and jwtSecret
-
-This is the key used to sign the JWT. Ex. `process.env.SECRET` or `process.env.APP_SECRET`.
-
-#### Header and authHeader
-
-The `Header` tells Dgraph where to lookup a JWT within the headers of the incoming requests made to the dgraph server.
-You have to configure it at the bottom of your schema file. This header is the same as the `authHeader` property you
-provide when you instantiate the `DgraphClient`.
-
-#### The nextAuth secret
-
-The `$nextAuth` secret is securely generated using the `jwtSecret` and injected by the DgraphAdapter in order to allow interacting with the JWT DgraphClient for anonymous user requests made within the system `ie. login, register`. This allows
-secure interactions to be made with all the auth types required by next-auth. You have to specify it for each auth rule of
-each type defined in your secure schema.
-
-```js
-type VerificationRequest
- @auth(
- delete: { rule: "{$nextAuth: { eq: true } }" },
- add: { rule: "{$nextAuth: { eq: true } }" },
- query: { rule: "{$nextAuth: { eq: true } }" },
- update: { rule: "{$nextAuth: { eq: true } }" }
- ) {
- ...
-}
-```
-
-## Working with JWT session and @auth directive
-
-Dgraph only works with HS256 or RS256 algorithms. If you want to use session jwt to securely interact with your dgraph
-database you must customize next-auth `encode` and `decode` functions, as the default algorithm is HS512. You can
-further customize the jwt with roles if you want to implement [`RBAC logic`](https://dgraph.io/docs/graphql/authorization/directive/#role-based-access-control).
-
-```js
-import * as jwt from "jsonwebtoken"
-export default NextAuth({
- session: {
- strategy: "jwt",
- },
- jwt: {
- secret: process.env.SECRET,
- encode: async ({ secret, token }) => {
- return jwt.sign({ ...token, userId: token.id }, secret, {
- algorithm: "HS256",
- expiresIn: 30 * 24 * 60 * 60, // 30 days
- })
- },
- decode: async ({ secret, token }) => {
- return jwt.verify(token, secret, { algorithms: ["HS256"] })
- },
- },
-})
-```
-
-Once your `Dgraph.Authorization` is defined in your schema and the JWT settings are set, this will allow you to define
-[`@auth rules`](https://dgraph.io/docs/graphql/authorization/authorization-overview/) for every part of your schema.
diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js
index 0ae8e673..c486fbe0 100644
--- a/docs/docusaurus.config.js
+++ b/docs/docusaurus.config.js
@@ -241,6 +241,21 @@ const docusaurusConfig = {
},
},
],
+ [
+ "docusaurus-plugin-typedoc",
+ {
+ ...typedocConfig,
+ id: "dgraph-adapter",
+ plugin: [require.resolve("./typedoc-mdn-links")],
+ watch: process.env.TYPEDOC_WATCH,
+ entryPoints: ["../packages/adapter-dgraph/src/index.ts"],
+ tsconfig: "../packages/adapter-dgraph/tsconfig.json",
+ out: "reference/adapter/dgraph",
+ sidebar: {
+ indexLabel: "Dgraph",
+ },
+ },
+ ],
],
}
diff --git a/docs/sidebars.js b/docs/sidebars.js
index 375a583c..17e4b966 100644
--- a/docs/sidebars.js
+++ b/docs/sidebars.js
@@ -51,6 +51,7 @@ module.exports = {
link: { type: "doc", id: "reference/adapters/overview" },
items: [
{ type: "doc", id: "reference/adapter/firebase/index" },
+ { type: "doc", id: "reference/adapter/dgraph/index" },
{ type: "autogenerated", dirName: "reference/06-adapters" },
],
},
diff --git a/packages/adapter-dgraph/src/index.ts b/packages/adapter-dgraph/src/index.ts
index e1345e26..8d609049 100644
--- a/packages/adapter-dgraph/src/index.ts
+++ b/packages/adapter-dgraph/src/index.ts
@@ -1,3 +1,16 @@
+/**
+ *
+ *
Official Dgraph adapter for Auth.js / NextAuth.js.
+ *
+ *
+ * ## Installation
+ *
+ * ```bash npm2yarn2pnpm
+ * npm install next-auth @next-auth/dgraph-adapter
+ * ```
+ *
+ * @module @next-auth/dgraph-adapter
+ */
import { client as dgraphClient } from "./client"
import { format } from "./utils"
import type { Adapter } from "next-auth/adapters"
@@ -6,7 +19,15 @@ import * as defaultFragments from "./graphql/fragments"
export type { DgraphClientParams, DgraphClientError } from "./client"
+/** This is the interface of the Dgraph adapter options. */
export interface DgraphAdapterOptions {
+ /**
+ * The GraphQL {@link https://dgraph.io/docs/query-language/fragments/ Fragments} you can supply to the adapter
+ * to define how the shapes of the `user`, `account`, `session`, `verificationToken` entities look.
+ *
+ * By default the adapter will uses the [default defined fragments](https://github.com/nextauthjs/next-auth/blob/main/packages/adapter-dgraph/src/graphql/fragments.ts)
+ * , this config option allows to extend them.
+ */
fragments?: {
User?: string
Account?: string
@@ -17,6 +38,234 @@ export interface DgraphAdapterOptions {
export { format }
+/**
+ * ### Basic usage
+ *
+ * Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
+ *
+ * ```ts title="pages/api/auth/[...nextauth].js"
+ * import NextAuth from "next-auth"
+ * import { DgraphAdapter } from "@next-auth/dgraph-adapter"
+ *
+ * export default NextAuth({
+ * providers: [],
+ * adapter: DgraphAdapter({
+ * endpoint: process.env.DGRAPH_GRAPHQL_ENDPOINT,
+ * authToken: process.env.DGRAPH_GRAPHQL_KEY,
+ * // you can omit the following properties if you are running an unsecure schema
+ * authHeader: process.env.AUTH_HEADER, // default: "Authorization",
+ * jwtSecret: process.env.SECRET,
+ * }),
+ * })
+ * ```
+ * ### Unsecure schema
+ *
+ * The quickest way to use Dgraph is by applying the unsecure schema to your [local](https://dgraph.io/docs/graphql/admin/#modifying-a-schema) Dgraph instance or if using Dgraph [cloud](https://dgraph.io/docs/cloud/cloud-quick-start/#the-schema) you can paste the schema in the codebox to update.
+ *
+ * :::warning
+ * This approach is not secure or for production use, and does not require a `jwtSecret`.
+ * :::
+ *
+ * > This schema is adapted for use in Dgraph and based upon our main [schema](/reference/adapters/models)
+ *
+ * #### Example
+ *
+ *```graphql
+ * type Account {
+ * id: ID
+ * type: String
+ * provider: String @search(by: [hash])
+ * providerAccountId: String @search(by: [hash])
+ * refreshToken: String
+ * expires_at: Int64
+ * accessToken: String
+ * token_type: String
+ * refresh_token: String
+ * access_token: String
+ * scope: String
+ * id_token: String
+ * session_state: String
+ * user: User @hasInverse(field: "accounts")
+ * }
+ * type Session {
+ * id: ID
+ * expires: DateTime
+ * sessionToken: String @search(by: [hash])
+ * user: User @hasInverse(field: "sessions")
+ * }
+ * type User {
+ * id: ID
+ * name: String
+ * email: String @search(by: [hash])
+ * emailVerified: DateTime
+ * image: String
+ * accounts: [Account] @hasInverse(field: "user")
+ * sessions: [Session] @hasInverse(field: "user")
+ * }
+ *
+ * type VerificationToken {
+ * id: ID
+ * identifier: String @search(by: [hash])
+ * token: String @search(by: [hash])
+ * expires: DateTime
+ * }
+ *```
+ * ### Secure schema
+ *
+ * For production deployments you will want to restrict the access to the types used
+ * by next-auth. The main form of access control used in Dgraph is via `@auth` directive alongside types in the schema.
+ * #### Example
+ *
+ * ```graphql
+ * type Account
+ * @auth(
+ * delete: { rule: "{$nextAuth: { eq: true } }" }
+ * add: { rule: "{$nextAuth: { eq: true } }" }
+ * query: { rule: "{$nextAuth: { eq: true } }" }
+ * update: { rule: "{$nextAuth: { eq: true } }" }
+ * ) {
+ * id: ID
+ * type: String
+ * provider: String @search(by: [hash])
+ * providerAccountId: String @search(by: [hash])
+ * refreshToken: String
+ * expires_at: Int64
+ * accessToken: String
+ * token_type: String
+ * refresh_token: String
+ * access_token: String
+ * scope: String
+ * id_token: String
+ * session_state: String
+ * user: User @hasInverse(field: "accounts")
+ * }
+ * type Session
+ * @auth(
+ * delete: { rule: "{$nextAuth: { eq: true } }" }
+ * add: { rule: "{$nextAuth: { eq: true } }" }
+ * query: { rule: "{$nextAuth: { eq: true } }" }
+ * update: { rule: "{$nextAuth: { eq: true } }" }
+ * ) {
+ * id: ID
+ * expires: DateTime
+ * sessionToken: String @search(by: [hash])
+ * user: User @hasInverse(field: "sessions")
+ * }
+ * type User
+ * @auth(
+ * query: {
+ * or: [
+ * {
+ * rule: """
+ * query ($userId: String!) {queryUser(filter: { id: { eq: $userId } } ) {id}}
+ * """
+ * }
+ * { rule: "{$nextAuth: { eq: true } }" }
+ * ]
+ * }
+ * delete: { rule: "{$nextAuth: { eq: true } }" }
+ * add: { rule: "{$nextAuth: { eq: true } }" }
+ * update: {
+ * or: [
+ * {
+ * rule: """
+ * query ($userId: String!) {queryUser(filter: { id: { eq: $userId } } ) {id}}
+ * """
+ * }
+ * { rule: "{$nextAuth: { eq: true } }" }
+ * ]
+ * }
+ * ) {
+ * id: ID
+ * name: String
+ * email: String @search(by: [hash])
+ * emailVerified: DateTime
+ * image: String
+ * accounts: [Account] @hasInverse(field: "user")
+ * sessions: [Session] @hasInverse(field: "user")
+ * }
+ *
+ * type VerificationToken
+ * @auth(
+ * delete: { rule: "{$nextAuth: { eq: true } }" }
+ * add: { rule: "{$nextAuth: { eq: true } }" }
+ * query: { rule: "{$nextAuth: { eq: true } }" }
+ * update: { rule: "{$nextAuth: { eq: true } }" }
+ * ) {
+ * id: ID
+ * identifier: String @search(by: [hash])
+ * token: String @search(by: [hash])
+ * expires: DateTime
+ * }
+ *
+ * # Dgraph.Authorization {"VerificationKey":"","Header":"","Namespace":"","Algo":"HS256"}
+ * ```
+ * ### Dgraph.Authorization
+ *
+ * In order to secure your graphql backend define the `Dgraph.Authorization` object at the
+ * bottom of your schema and provide `authHeader` and `jwtSecret` values to the DgraphClient.
+ *
+ * ```js
+ * # Dgraph.Authorization {"VerificationKey":"","Header":"","Namespace":"YOUR CUSTOM NAMESPACE HERE","Algo":"HS256"}
+ * ```
+ *
+ * ### VerificationKey and jwtSecret
+ *
+ * This is the key used to sign the JWT. Ex. `process.env.SECRET` or `process.env.APP_SECRET`.
+ *
+ * ### Header and authHeader
+ *
+ * The `Header` tells Dgraph where to lookup a JWT within the headers of the incoming requests made to the dgraph server.
+ * You have to configure it at the bottom of your schema file. This header is the same as the `authHeader` property you
+ * provide when you instantiate the `DgraphClient`.
+ *
+ * ### The nextAuth secret
+ *
+ * The `$nextAuth` secret is securely generated using the `jwtSecret` and injected by the DgraphAdapter in order to allow interacting with the JWT DgraphClient for anonymous user requests made within the system `ie. login, register`. This allows
+ * secure interactions to be made with all the auth types required by next-auth. You have to specify it for each auth rule of
+ * each type defined in your secure schema.
+ *
+ * ```js
+ * type VerificationRequest
+ * @auth(
+ * delete: { rule: "{$nextAuth: { eq: true } }" },
+ * add: { rule: "{$nextAuth: { eq: true } }" },
+ * query: { rule: "{$nextAuth: { eq: true } }" },
+ * update: { rule: "{$nextAuth: { eq: true } }" }
+ * ) {
+ * ...
+ * }
+ * ```
+ * ### JWT session and `@auth` directive
+ *
+ * Dgraph only works with HS256 or RS256 algorithms. If you want to use session jwt to securely interact with your dgraph
+ * database you must customize next-auth `encode` and `decode` functions, as the default algorithm is HS512. You can
+ * further customize the jwt with roles if you want to implement [`RBAC logic`](https://dgraph.io/docs/graphql/authorization/directive/#role-based-access-control).
+ *
+ * ```js
+ * import * as jwt from "jsonwebtoken"
+ * export default NextAuth({
+ * session: {
+ * strategy: "jwt",
+ * },
+ * jwt: {
+ * secret: process.env.SECRET,
+ * encode: async ({ secret, token }) => {
+ * return jwt.sign({ ...token, userId: token.id }, secret, {
+ * algorithm: "HS256",
+ * expiresIn: 30 * 24 * 60 * 60, // 30 days
+ * })
+ * },
+ * decode: async ({ secret, token }) => {
+ * return jwt.verify(token, secret, { algorithms: ["HS256"] })
+ * },
+ * },
+ * })
+ * ```
+ *
+ * Once your `Dgraph.Authorization` is defined in your schema and the JWT settings are set, this will allow you to define
+ * [`@auth rules`](https://dgraph.io/docs/graphql/authorization/authorization-overview/) for every part of your schema.
+ **/
export function DgraphAdapter(
client: DgraphClientParams,
options?: DgraphAdapterOptions
From d06a552bf6739a30a4094e2673aeea97dd8c843c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?=
Date: Sun, 5 Mar 2023 16:07:51 +0100
Subject: [PATCH 03/80] chore: format
---
docs/vercel.json | 57 ++++++++----------------------------------------
1 file changed, 9 insertions(+), 48 deletions(-)
diff --git a/docs/vercel.json b/docs/vercel.json
index 4623996f..332dd7b7 100644
--- a/docs/vercel.json
+++ b/docs/vercel.json
@@ -4,18 +4,9 @@
{
"source": "/(.*)",
"headers": [
- {
- "key": "X-Content-Type-Options",
- "value": "nosniff"
- },
- {
- "key": "X-Frame-Options",
- "value": "DENY"
- },
- {
- "key": "X-XSS-Protection",
- "value": "1; mode=block"
- }
+ { "key": "X-Content-Type-Options", "value": "nosniff" },
+ { "key": "X-Frame-Options", "value": "DENY" },
+ { "key": "X-XSS-Protection", "value": "1; mode=block" }
]
}
],
@@ -67,62 +58,32 @@
},
{
"source": "/",
- "has": [
- {
- "type": "host",
- "value": "sveltekit.authjs.dev"
- }
- ],
+ "has": [{ "type": "host", "value": "sveltekit.authjs.dev" }],
"destination": "https://authjs.dev/reference/sveltekit"
},
{
"source": "/",
- "has": [
- {
- "type": "host",
- "value": "solid-start.authjs.dev"
- }
- ],
+ "has": [{ "type": "host", "value": "solid-start.authjs.dev" }],
"destination": "https://authjs.dev/reference/solid-start"
},
{
"source": "/:path(.*)",
- "has": [
- {
- "type": "host",
- "value": "errors.authjs.dev"
- }
- ],
+ "has": [{ "type": "host", "value": "errors.authjs.dev" }],
"destination": "https://authjs.dev/reference/core/errors/:path*"
},
{
"source": "/:path(.*)",
- "has": [
- {
- "type": "host",
- "value": "warnings.authjs.dev"
- }
- ],
+ "has": [{ "type": "host", "value": "warnings.authjs.dev" }],
"destination": "https://authjs.dev/reference/warnings/:path*"
},
{
"source": "/:path(.*)",
- "has": [
- {
- "type": "host",
- "value": "adapters.authjs.dev"
- }
- ],
+ "has": [{ "type": "host", "value": "adapters.authjs.dev" }],
"destination": "https://authjs.dev/reference/adapters/:path*"
},
{
"source": "/:path",
- "has": [
- {
- "type": "host",
- "value": "providers.authjs.dev"
- }
- ],
+ "has": [{ "type": "host", "value": "providers.authjs.dev" }],
"destination": "https://authjs.dev/reference/core/providers_:path.default"
}
]
From 2e8e90a9be3348d53ecf85472934b8948f657cd0 Mon Sep 17 00:00:00 2001
From: Nico Domino
Date: Sun, 5 Mar 2023 16:32:08 +0100
Subject: [PATCH 04/80] chore(docs): new guide for sending email via http api
(#6555)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* chore(docs): new guide for sending email via http api
* chore(docs): prettier code blocks
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* fix: relative links and remove prisma specific mention
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* Update docs/docs/guides/04-providers/03-email-http-api.md
Co-authored-by: Balázs Orbán
* chore: reword to be more inclusive
* feat: use custom provider
* Apply suggestions from code review
* code review changes
---------
Co-authored-by: Balázs Orbán
---
.../guides/04-providers/03-email-http-api.md | 109 ++++++++++++++++++
1 file changed, 109 insertions(+)
create mode 100644 docs/docs/guides/04-providers/03-email-http-api.md
diff --git a/docs/docs/guides/04-providers/03-email-http-api.md b/docs/docs/guides/04-providers/03-email-http-api.md
new file mode 100644
index 00000000..4184d0a4
--- /dev/null
+++ b/docs/docs/guides/04-providers/03-email-http-api.md
@@ -0,0 +1,109 @@
+---
+id: email-http
+title: HTTP-based Email Provider
+---
+
+## Introduction
+
+:::note
+The following guide is written for `next-auth` (NextAuth.js), but it should work for any of the Auth.js framework libraries (`@auth/*`) as well.
+:::
+
+
+There is a built-in Email provider with which you could connect to the SMTP server of your choice to send "magic link" emails for sign-in purposes. However, the Email provider can also be used with HTTP-based email services, like AWS SES, Postmark, Sendgrid, etc. In this guide, we are going to explain how to use our Email magic link provider with any of the more modern HTTP-based Email APIs.
+
+For this example, we will be using [SendGrid](https://sendgrid.com), but any email service providing an HTTP API or JS client library will work.
+We will also refer to the [Prisma Adapter](/reference/adapter/prisma). A [database adapter](/adapters/overview) is a requirement for the Email provider.
+
+## Setup
+
+First, if you do not have a project using Auth.js, clone and set up a basic Auth.js project like the one [provided in](https://github.com/nextauthjs/next-auth-example.git) our example repo](https://github.com/nextauthjs/next-auth-example.git).
+
+- Install the [Prisma Adapter](/reference/adapter/prisma)
+- Generate an API key from your cloud Email provider of choice and add it to your `.env.*` file. For example, mine is going to be called `SENDGRID_API`
+- Add the following configuration to your configuration file:
+
+```js title="pages/api/auth/[...nextauth].ts"
+import NextAuth, { NextAuthOptions } from "next-auth"
+import { PrismaAdapter } from "@next-auth/prisma-adapter"
+import { PrismaClient } from "@prisma/client"
+
+const prisma = new PrismaClient()
+
+export const authOptions: NextAuthOptions = {
+ adapter: PrismaAdapter(prisma),
+ providers: [
+ {
+ id: 'sendgrid',
+ type: 'email',
+ async sendVerificationRequest({identifier: email, url}) {
+ }
+ }
+ ],
+}
+
+export default NextAuth(authOptions)
+```
+
+Next, all that's left to do is call the HTTP endpoint from our cloud email provider and pass it the required metadata like the `to` address, the email `body`, and any other fields we may need to include.
+
+As mentioned earlier, we're going to be using SendGrid in this example, so the appropriate endpoint is `https://api.sendgrid.com/v3/mail/send` ([more info](https://docs.sendgrid.com/for-developers/sending-email/api-getting-started)). Therefore, we're going to pull out some of the important information from the `params` argument and use it in a `fetch()` call to the previously mentioned SendGrid API.
+
+```js title="pages/api/auth/[...nextauth].ts"
+import NextAuth, { NextAuthOptions } from "next-auth"
+import { PrismaAdapter } from "@next-auth/prisma-adapter"
+import { PrismaClient } from "@prisma/client"
+
+const prisma = new PrismaClient()
+
+export const authOptions: NextAuthOptions = {
+ adapter: PrismaAdapter(prisma),
+ providers: [
+ {
+ id: 'sendgrid',
+ type: 'email',
+ async sendVerificationRequest({identifier: email, url}) {
+ // highlight-start
+ // Call the cloud Email provider API for sending emails
+ // See https://docs.sendgrid.com/api-reference/mail-send/mail-send
+ const response = await fetch("https://api.sendgrid.com/v3/mail/send", {
+ // The body format will vary depending on provider, please see their documentation
+ // for further details.
+ body: JSON.stringify({
+ personalizations: [{ to: [{ email }] }],
+ from: { email: "noreply@company.com" },
+ subject: "Sign in to Your page",
+ content: [
+ {
+ type: "text/plain",
+ value: `Please click here to authenticate - ${url}`,
+ },
+ ],
+ }),
+ headers: {
+ // Authentication will also vary from provider to provider, please see their docs.
+ Authorization: `Bearer ${process.env.SENDGRID_API}`,
+ "Content-Type": "application/json",
+ },
+ method: "POST",
+ })
+
+ if (!response.ok) {
+ const { errors } = await response.json()
+ throw new Error(JSON.stringify(errors))
+ }
+ // highlight-end
+ },
+ }
+ ],
+}
+```
+
+And that's all we need to do to send Emails via an HTTP API! Note here that the example is only using `text/plain` as the body type. You'll probably want to change that to `text/html` and pass in a nice-looking HTML email. See, for example, our `html` function in [the Auth.js docs](/providers/email#customizing-emails).
+
+To sign in via this custom provider, you would refer to it by the `id` in when you are calling the sign-in method, for example: `signIn('sendgrid', { email: 'user@company.com' })`.
+
+## References
+
+- [Email provider documentation with HTML generation and more](/reference/core/modules/providers_email)
+- [SendGrid JSON Body documentation](https://docs.sendgrid.com/api-reference/mail-send/mail-send#body)
From 36286b1fae4f07fa8c204e88aefb0876479e8b03 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?=
Date: Sun, 5 Mar 2023 16:39:23 +0100
Subject: [PATCH 05/80] fix(adapter): improve `Adapter` docs, add runtime
assertions (#6612)
* fix(ts): improve Adapter documentation
* chore: simplify code
* assert missing adapter methods
* add federated logout guide link
* oidc -> oauth
---
packages/core/src/adapters.ts | 208 ++++++++++++++++------
packages/core/src/index.ts | 42 ++++-
packages/core/src/lib/assert.ts | 58 ++++--
packages/core/src/lib/callback-handler.ts | 15 +-
packages/core/src/lib/cookie.ts | 9 +-
packages/core/src/lib/init.ts | 6 +-
packages/core/src/lib/routes/callback.ts | 9 +-
packages/core/src/lib/routes/session.ts | 2 +-
packages/core/src/lib/routes/shared.ts | 15 --
packages/core/src/lib/routes/signin.ts | 9 +-
packages/core/src/types.ts | 71 ++------
11 files changed, 273 insertions(+), 171 deletions(-)
diff --git a/packages/core/src/adapters.ts b/packages/core/src/adapters.ts
index 9e4520fe..4d67cbce 100644
--- a/packages/core/src/adapters.ts
+++ b/packages/core/src/adapters.ts
@@ -1,19 +1,22 @@
/**
- * This module contains functions and types that a database adapter
- * can use to be compatible with Auth.js.
+ * Auth.js can be integrated with _any_ data layer (database, ORM, or backend API, HTTP client)
+ * in order to automatically create users, handle account linking automatically, support passwordless login,
+ * and to store session information.
*
- * A database adapter provides a common interface for Auth.js so that it can work with
- * _any_ database/ORM adapter without concerning itself with the implementation details of the database/ORM.
+ * This module contains utility functions and types to create an Auth.js compatible adapter.
*
* Auth.js supports 2 session strategies to persist the login state of a user.
* The default is to use a cookie + {@link https://authjs.dev/concepts/session-strategies#jwt JWT}
* based session store (`strategy: "jwt"`),
* but you can also use a database adapter to store the session in a database.
*
- * :::info Note
- * Auth.js _currently_ does **not** implement {@link https://authjs.dev/concepts/session-strategies#federated-logout federated logout}.
- * So even if the session is deleted from the database, the user will still be logged in to the provider (but will be logged out of the app).
- * See [this discussion](https://github.com/nextauthjs/next-auth/discussions/3938) for more information.
+ * Before you continue, Auth.js has a list of {@link https://authjs.dev/reference/adapters/overview official database adapters}. If your database is listed there, you
+ * probably do not need to create your own. If you are using a data solution that cannot be integrated with an official adapter, this module will help you create a compatible adapter.
+ *
+ * :::caution Note
+ * Although `@auth/core` _is_ framework/runtime agnostic, an adapter might rely on a client/ORM package,
+ * that is not yet compatible with your framework/runtime (e.g. it might rely on [Node.js APIs](https://nodejs.org/docs/latest/api)).
+ * Related issues should be reported to the corresponding package maintainers.
* :::
*
* ## Installation
@@ -22,73 +25,143 @@
* npm install @auth/core
* ```
*
- * You can then import this submodule from `@auth/core/adapters`.
+ * Then, you can import this submodule from `@auth/core/adapters`.
*
* ## Usage
*
- * {@link https://authjs.dev/reference/adapters/overview Built-in adapters} already implement this interface, so you likely won't need to
- * implement it yourself. If you do, you can use the following example as a
- * starting point.
+ * Each adapter method and its function signature is documented in the {@link Adapter} interface.
*
- * ```ts title=your-adapter.ts
+ * ```ts title=my-adapter.ts
* import { type Adapter } from "@auth/core/adapters"
*
- * export function MyAdapter(config: {}): Adapter {
- * // implement the adapter methods
+ * // 1. Simplest form, a plain object.
+ * export const MyAdapter: Adapter {
+ * // implement the adapter methods here
* }
+ *
+ * // or
+ *
+ * // 2. A function that returns an object. Official adapters use this pattern.
+ * export function MyAdapter(config: any): Adapter {
+ * // Instantiate a client/ORM here with the provided config, or pass it in as a parameter.
+ * // Usually, you might already have a client instance elsewhere in your application,
+ * // so you should only create a new instance if you need to or you don't have one.
+ *
+ * return {
+ * // implement the adapter methods
+ * }
+ * }
+ *
* ```
*
- * ```ts title=index.ts
- * import { MyAdapter } from "./your-adapter"
+ * Then, you can pass your adapter to Auth.js as the `adapter` option.
*
- * const response = Auth({
- * adapter: MyAdapter({ /* ...adapter config *\/ }),
- * // ... auth config
+ * ```ts title=index.ts
+ * import { MyAdapter } from "./my-adapter"
+ *
+ * const response = await Auth(..., {
+ * adapter: MyAdapter, // 1.
+ * // or
+ * adapter: MyAdapter({ /* config *\/ }), // 2.
+ * ...
* })
* ```
*
- * :::caution Note
- * Although `@auth/core` is framework/runtime agnostic, an adapter might rely on a client/ORM package,
- * that is not yet compatible with your runtime
- * (E.g. it might rely on [Node.js-specific APIs](https://nodejs.org/docs/latest/api)) when you are trying to use it elsewhere.
- * Related issues should be reported to the corresponding package maintainers.
- * :::
+ * Note, you might be able to tweak an existing adapter to work with your data layer, instead of creating one from scratch.
*
- * ### Testing
- * :::tip
- * If you are writing your own adapter, there is a test suite [available](https://github.com/nextauthjs/next-auth/tree/main/packages/adapter-test)
+ * ```ts title=my-adapter.ts
+ * import { type Adapter } from "@auth/core/adapters"
+ * import { PrismaAdapter } from "@next-auth/prisma-adapter"
+ * import { PrismaClient } from "@prisma/client"
+ *
+ * const prisma = new PrismaClient()
+ *
+ * const adapter: Adapter = {
+ * ...PrismaAdapter(prisma),
+ * // Add your custom methods here
+ * }
+ *
+ * const request = new Request("https://example.com")
+ * const response = await Auth(request, { adapter, ... })
+ * ```
+ *
+ * ## Testing
+ *
+ * There is a test suite [available](https://github.com/nextauthjs/next-auth/tree/main/packages/adapter-test)
* to ensure that your adapter is compatible with Auth.js.
- * :::
*
- * ## Resources
+ * ## Known issues
*
- * - [What is a database session strategy?](https://authjs.dev/concepts/session-strategies#database)
+ * The following are missing built-in features in Auth.js but can be solved in user land. If you would like to help implement these features, please reach out.
+ *
+ * ### Token rotation
+ *
+ * Auth.js _currently_ does not support {@link https://authjs.dev/concepts/oauth#token-rotation `access_token` rotation} out of the box.
+ * The necessary information (`refresh_token`, expiry, etc.) is being stored in the database, but the logic to rotate the token is not implemented
+ * in the core library.
+ * [This guide](https://authjs.dev/guides/basics/refresh-token-rotation#database-strategy) should provide the necessary steps to do this in user land.
+ *
+ * ### Federated logout
+ *
+ * Auth.js _currently_ does not support {@link https://authjs.dev/concepts/oauth#federated-logout federated logout} out of the box.
+ * This means that even if an active session is deleted from the database, the user will still be signed in to the identity provider,
+ * they will only be signed out of the application.
+ * Eg. if you use Google as an identity provider, and you delete the session from the database,
+ * the user will still be signed in to Google, but they will be signed out of your application.
+ *
+ * If your users might be using the application from a publicly shared computer (eg: library), you might want to implement federated logout.
+ * {@link https://authjs.dev/guides/providers/federated-logout This guide} should provide the necessary steps.
*
* @module adapters
*/
+import { ProviderType } from "./providers/index.js"
import type { Account, Awaitable, User } from "./types.js"
-
// TODO: Discuss if we should expose methods to serialize and deserialize
// the data? Many adapters share this logic, so it could be useful to
// have a common implementation.
+/**
+ * A user represents a person who can sign in to the application.
+ * If a user does not exist yet, it will be created when they sign in for the first time,
+ * using the information (profile data) returned by the identity provider.
+ * A corresponding account is also created and linked to the user.
+ */
export interface AdapterUser extends User {
+ /** A unique identifier for the user. */
id: string
+ /** The user's email address. */
email: string
+ /**
+ * Whether the user has verified their email address via an [Email provider](https://authjs.dev/reference/core/providers_email).
+ * It is `null` if the user has not signed in with the Email provider yet, or the date of the first successful signin.
+ */
emailVerified: Date | null
}
+/**
+ * An account is a connection between a user and a provider.
+ *
+ * There are two types of accounts:
+ * - OAuth/OIDC accounts, which are created when a user signs in with an OAuth provider.
+ * - Email accounts, which are created when a user signs in with an [Email provider](https://authjs.dev/reference/core/providers_email).
+ *
+ * One user can have multiple accounts.
+ */
export interface AdapterAccount extends Account {
userId: string
+ type: Extract
}
/**
- * The session object implementing this interface
- * is used to look up the user in the database.
+ * A session holds information about a user's current signin state.
*/
export interface AdapterSession {
- /** A randomly generated value that is used to get hold of the session. */
+ /**
+ * A randomly generated value that is used to look up the session in the database
+ * when using `"database"` `AuthConfig.strategy` option.
+ * This value is saved in a secure, HTTP-Only cookie on the client.
+ */
sessionToken: string
/** Connects the active session to a user in the database */
userId: string
@@ -96,8 +169,8 @@ export interface AdapterSession {
* The absolute date when the session expires.
*
* If a session is accessed prior to its expiry date,
- * it will be extended based on the `maxAge` option as defined in by {@linkcode SessionOptions.maxAge}.
- * It is never extended more than once in a period defined by {@linkcode SessionOptions.updateAge}.
+ * it will be extended based on the `maxAge` option as defined in by `SessionOptions.maxAge`.
+ * It is never extended more than once in a period defined by `SessionOptions.updateAge`.
*
* If a session is accessed past its expiry date,
* it will be removed from the database to clean up inactive sessions.
@@ -106,62 +179,79 @@ export interface AdapterSession {
expires: Date
}
+/**
+ * A verification token is a temporary token that is used to sign in a user via their email address.
+ * It is created when a user signs in with an [Email provider](https://authjs.dev/reference/core/providers_email).
+ * When the user clicks the link in the email, the token and email is sent back to the server
+ * where it is hashed and compared to the value in the database.
+ * If the tokens and emails match, and the token hasn't expired yet, the user is signed in.
+ * The token is then deleted from the database.
+ */
export interface VerificationToken {
+ /** The user's email address. */
identifier: string
+ /** The absolute date when the token expires. */
expires: Date
+ /**
+ * A [hashed](https://authjs.dev/concepts/hashing) token, using the `AuthConfig.secret` value.
+ */
token: string
}
/**
- * Using a custom adapter you can connect to any database backend or even several different databases.
- * Custom adapters created and maintained by our community can be found in the adapters repository.
- * Feel free to add a custom adapter from your project to the repository,
- * or even become a maintainer of a certain adapter.
- * Custom adapters can still be created and used in a project without being added to the repository.
+ * An adapter is an object with function properties (methods) that read and write data from a data source.
+ * Think of these methods as a way to normalize the data layer to common interfaces that Auth.js can understand.
*
- * ## Resources
+ * This is what makes Auth.js very flexible and allows it to be used with any data layer.
*
- * - [Session strategies](https://authjs.dev/concepts/session-strategies#database)
- * - [Using a database adapter](https://authjs.dev/guides/adapters/using-a-database-adapter)
- * - [Creating a database adapter](https://authjs.dev/guides/adapters/creating-a-database-adapter)
+ * The adapter methods are used to perform the following operations:
+ * - Create/update/delete a user
+ * - Link/unlink an account to/from a user
+ * - Handle active sessions
+ * - Support passwordless authentication across multiple devices
+ *
+ * :::note
+ * If any of the methods are not implemented, but are called by Auth.js,
+ * an error will be shown to the user and the operation will fail.
+ * :::
*/
export interface Adapter {
- createUser(user: Omit): Awaitable
- getUser(id: string): Awaitable
- getUserByEmail(email: string): Awaitable
+ createUser?(user: Omit): Awaitable
+ getUser?(id: string): Awaitable
+ getUserByEmail?(email: string): Awaitable
/** Using the provider id and the id of the user for a specific account, get the user. */
- getUserByAccount(
+ getUserByAccount?(
providerAccountId: Pick
): Awaitable
- updateUser(user: Partial): Awaitable
- /** @todo This method is currently not implemented. Defining it will have no effect */
+ updateUser?(user: Partial): Awaitable
+ /** @todo This method is currently not invoked yet. */
deleteUser?(
userId: string
): Promise | Awaitable
- linkAccount(
+ linkAccount?(
account: AdapterAccount
): Promise | Awaitable
- /** @todo This method is currently not implemented. Defining it will have no effect */
+ /** @todo This method is currently not invoked yet. */
unlinkAccount?(
providerAccountId: Pick
): Promise | Awaitable
/** Creates a session for the user and returns it. */
- createSession(session: {
+ createSession?(session: {
sessionToken: string
userId: string
expires: Date
}): Awaitable
- getSessionAndUser(
+ getSessionAndUser?(
sessionToken: string
): Awaitable<{ session: AdapterSession; user: AdapterUser } | null>
- updateSession(
+ updateSession?(
session: Partial & Pick
): Awaitable
/**
* Deletes a session from the database. It is preferred that this method also
* returns the session that is being deleted for logging purposes.
*/
- deleteSession(
+ deleteSession?(
sessionToken: string
): Promise | Awaitable
createVerificationToken?(
diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts
index 827fb6bb..02308bd9 100644
--- a/packages/core/src/index.ts
+++ b/packages/core/src/index.ts
@@ -49,7 +49,6 @@ import type {
CookiesOptions,
EventCallbacks,
PagesOptions,
- SessionOptions,
Theme,
} from "./types.js"
import type { Provider } from "./providers/index.js"
@@ -182,15 +181,50 @@ export interface AuthConfig {
* If not specified, it falls back to `AUTH_SECRET` or `NEXTAUTH_SECRET` from environment variables.
* To generate a random string, you can use the following command:
*
- * On Unix systems: `openssl rand -hex 32`
- * Or go to https://generate-secret.vercel.app/32
+ * - On Unix systems, type `openssl rand -hex 32` in the terminal
+ * - Or generate one [online](https://generate-secret.vercel.app/32)
*/
secret?: string
/**
* Configure your session like if you want to use JWT or a database,
* how long until an idle session expires, or to throttle write operations in case you are using a database.
*/
- session?: Partial
+ session?: {
+ /**
+ * Choose how you want to save the user session.
+ * The default is `"jwt"`, an encrypted JWT (JWE) in the session cookie.
+ *
+ * If you use an `adapter` however, we default it to `"database"` instead.
+ * You can still force a JWT session by explicitly defining `"jwt"`.
+ *
+ * When using `"database"`, the session cookie will only contain a `sessionToken` value,
+ * which is used to look up the session in the database.
+ *
+ * [Documentation](https://authjs.dev/reference/configuration/auth-config#session) | [Adapter](https://authjs.dev/reference/configuration/auth-config#adapter) | [About JSON Web Tokens](https://authjs.dev/reference/faq#json-web-tokens)
+ */
+ strategy?: "jwt" | "database"
+ /**
+ * Relative time from now in seconds when to expire the session
+ *
+ * @default 2592000 // 30 days
+ */
+ maxAge?: number
+ /**
+ * How often the session should be updated in seconds.
+ * If set to `0`, session is updated every time.
+ *
+ * @default 86400 // 1 day
+ */
+ updateAge?: number
+ /**
+ * Generate a custom session token for database-based sessions.
+ * By default, a random UUID or string is generated depending on the Node.js version.
+ * However, you can specify your own custom string (such as CUID) to be used.
+ *
+ * @default `randomUUID` or `randomBytes.toHex` depending on the Node.js version
+ */
+ generateSessionToken?: () => string
+ }
/**
* JSON Web Tokens are enabled by default if you have not specified an {@link AuthConfig.adapter}.
* JSON Web Tokens are encrypted (JWE) by default. We recommend you keep this behaviour.
diff --git a/packages/core/src/lib/assert.ts b/packages/core/src/lib/assert.ts
index 797d1df7..28bd9af2 100644
--- a/packages/core/src/lib/assert.ts
+++ b/packages/core/src/lib/assert.ts
@@ -34,9 +34,33 @@ function isValidHttpUrl(url: string, baseUrl: string) {
}
}
+let hasCredentials = false
+let hasEmail = false
+
+const emailMethods = [
+ "createVerificationToken",
+ "useVerificationToken",
+ "getUserByEmail",
+]
+
+const sessionMethods = [
+ "createUser",
+ "getUser",
+ "getUserByEmail",
+ "getUserByAccount",
+ "updateUser",
+ "linkAccount",
+ "createSession",
+ "getSessionAndUser",
+ "updateSession",
+ "deleteSession",
+]
+
/**
* Verify that the user configured Auth.js correctly.
* Good place to mention deprecations as well.
+ *
+ * This is invoked before the init method, so default values are not available yet.
*/
export function assertConfig(
request: RequestInternal,
@@ -77,8 +101,6 @@ export function assertConfig(
)
}
- let hasCredentials, hasEmail
-
for (const provider of options.providers) {
if (
(provider.type === "oauth" || provider.type === "oidc") &&
@@ -123,23 +145,29 @@ export function assertConfig(
}
}
- if (hasEmail) {
- const { adapter } = options
- if (!adapter) {
- return new MissingAdapter("E-mail login requires an adapter.")
+ const { adapter, session } = options
+ if (
+ hasEmail ||
+ session?.strategy === "database" ||
+ (!session?.strategy && adapter)
+ ) {
+ let methods: string[]
+
+ if (hasEmail) {
+ if (!adapter)
+ return new MissingAdapter("Email login requires an adapter.")
+ methods = emailMethods
+ } else {
+ if (!adapter)
+ return new MissingAdapter("Database session requires an adapter.")
+ methods = sessionMethods
}
- const missingMethods = (
- [
- "createVerificationToken",
- "useVerificationToken",
- "getUserByEmail",
- ] as const
- ).filter((method) => !adapter[method])
+ const missing = methods.filter((m) => !adapter[m as keyof typeof adapter])
- if (missingMethods.length) {
+ if (missing.length) {
return new MissingAdapterMethods(
- `Required adapter methods were missing: ${missingMethods.join(", ")}`
+ `Required adapter methods were missing: ${missing.join(", ")}`
)
}
}
diff --git a/packages/core/src/lib/callback-handler.ts b/packages/core/src/lib/callback-handler.ts
index f05623bf..2344a81d 100644
--- a/packages/core/src/lib/callback-handler.ts
+++ b/packages/core/src/lib/callback-handler.ts
@@ -1,7 +1,11 @@
import { AccountNotLinked } from "../errors.js"
import { fromDate } from "./utils/date.js"
-import type { AdapterSession, AdapterUser } from "../adapters.js"
+import type {
+ AdapterAccount,
+ AdapterSession,
+ AdapterUser,
+} from "../adapters.js"
import type { Account, InternalOptions, User } from "../types.js"
import type { JWT } from "../jwt.js"
import type { OAuthConfig } from "../providers/index.js"
@@ -22,13 +26,13 @@ import type { SessionToken } from "./cookie.js"
export async function handleLogin(
sessionToken: SessionToken,
_profile: User | AdapterUser | { email: string },
- account: Account | null,
+ _account: AdapterAccount | Account | null,
options: InternalOptions
) {
// Input validation
- if (!account?.providerAccountId || !account.type)
+ if (!_account?.providerAccountId || !_account.type)
throw new Error("Missing or invalid provider account")
- if (!["email", "oauth", "oidc"].includes(account.type))
+ if (!["email", "oauth", "oidc"].includes(_account.type))
throw new Error("Provider not supported")
const {
@@ -41,10 +45,11 @@ export async function handleLogin(
// If no adapter is configured then we don't have a database and cannot
// persist data; in this mode we just return a dummy session object.
if (!adapter) {
- return { user: _profile as User, account }
+ return { user: _profile as User, account: _account as Account }
}
const profile = _profile as AdapterUser
+ const account = _account as AdapterAccount
const {
createUser,
diff --git a/packages/core/src/lib/cookie.ts b/packages/core/src/lib/cookie.ts
index 42edff56..4c434278 100644
--- a/packages/core/src/lib/cookie.ts
+++ b/packages/core/src/lib/cookie.ts
@@ -1,9 +1,4 @@
-import type {
- CookieOption,
- CookiesOptions,
- LoggerInstance,
- SessionStrategy,
-} from "../types.js"
+import type { CookieOption, CookiesOptions, LoggerInstance } from "../types.js"
// Uncomment to recalculate the estimated size
// of an empty session cookie
@@ -41,7 +36,7 @@ export type SetCookieOptions = Partial & {
* If `options.session.strategy` is set to `jwt`, this is a stringified `JWT`.
* In case of `strategy: "database"`, this is the `sessionToken` of the session in the database.
*/
-export type SessionToken = T extends "jwt"
+export type SessionToken = T extends "jwt"
? JWTString
: string
diff --git a/packages/core/src/lib/init.ts b/packages/core/src/lib/init.ts
index 3a105b01..7ef95f71 100644
--- a/packages/core/src/lib/init.ts
+++ b/packages/core/src/lib/init.ts
@@ -181,10 +181,10 @@ function eventsErrorHandler(
}
/** Handles adapter induced errors. */
-function adapterErrorHandler(
- adapter: TAdapter | undefined,
+function adapterErrorHandler(
+ adapter: AuthConfig["adapter"],
logger: LoggerInstance
-): TAdapter | undefined {
+) {
if (!adapter) return
return Object.keys(adapter).reduce((acc, name) => {
diff --git a/packages/core/src/lib/routes/callback.ts b/packages/core/src/lib/routes/callback.ts
index 6c372818..7a81683b 100644
--- a/packages/core/src/lib/routes/callback.ts
+++ b/packages/core/src/lib/routes/callback.ts
@@ -2,7 +2,7 @@ import { handleLogin } from "../callback-handler.js"
import { CallbackRouteError, Verification } from "../../errors.js"
import { handleOAuth } from "../oauth/callback.js"
import { createHash } from "../web.js"
-import { getAdapterUserFromEmail, handleAuthorized } from "./shared.js"
+import { handleAuthorized } from "./shared.js"
import type { AdapterSession } from "../../adapters.js"
import type {
@@ -180,8 +180,11 @@ export async function callback(params: {
const invalidInvite = !hasInvite || expired
if (invalidInvite) throw new Verification({ hasInvite, expired })
- // @ts-expect-error -- Verified in `assertConfig`.
- const user = await getAdapterUserFromEmail(identifier, adapter)
+ const user = (await adapter!.getUserByEmail(identifier)) ?? {
+ id: identifier,
+ email: identifier,
+ emailVerified: null,
+ }
const account: Account = {
providerAccountId: user.email,
diff --git a/packages/core/src/lib/routes/session.ts b/packages/core/src/lib/routes/session.ts
index 3c5251db..a7a67ad8 100644
--- a/packages/core/src/lib/routes/session.ts
+++ b/packages/core/src/lib/routes/session.ts
@@ -85,7 +85,7 @@ export async function session(
// Retrieve session from database
try {
const { getSessionAndUser, deleteSession, updateSession } =
- adapter as Adapter
+ adapter as Required
let userAndSession = await getSessionAndUser(sessionToken)
// If session has expired, clean up the database
diff --git a/packages/core/src/lib/routes/shared.ts b/packages/core/src/lib/routes/shared.ts
index 9706aa21..1216d0b5 100644
--- a/packages/core/src/lib/routes/shared.ts
+++ b/packages/core/src/lib/routes/shared.ts
@@ -1,8 +1,6 @@
import { AuthorizedCallbackError } from "../../errors.js"
import { InternalOptions } from "../../types.js"
-import type { Adapter, AdapterUser } from "../../adapters.js"
-
export async function handleAuthorized(
params: any,
{ url, logger, callbacks: { signIn } }: InternalOptions
@@ -23,16 +21,3 @@ export async function handleAuthorized(
return { status: 500 as const, redirect: url.toString() }
}
}
-
-/**
- * Query the database for a user by email address.
- * If it's an existing user, return a user object,
- * otherwise use placeholder.
- */
-export async function getAdapterUserFromEmail(
- email: string,
- adapter: Adapter
-): Promise {
- const user = await adapter.getUserByEmail(email)
- return user ?? { id: email, email, emailVerified: null }
-}
diff --git a/packages/core/src/lib/routes/signin.ts b/packages/core/src/lib/routes/signin.ts
index 3cdd190c..da873e9c 100644
--- a/packages/core/src/lib/routes/signin.ts
+++ b/packages/core/src/lib/routes/signin.ts
@@ -1,7 +1,7 @@
import emailSignin from "../email/signin.js"
import { SignInError } from "../../errors.js"
import { getAuthorizationUrl } from "../oauth/authorization-url.js"
-import { getAdapterUserFromEmail, handleAuthorized } from "./shared.js"
+import { handleAuthorized } from "./shared.js"
import type {
Account,
@@ -28,8 +28,11 @@ export async function signin(
const normalizer = provider.normalizeIdentifier ?? defaultNormalizer
const email = normalizer(body?.email)
- // @ts-expect-error -- Verified in `assertConfig`
- const user = await getAdapterUserFromEmail(email, options.adapter)
+ const user = (await options.adapter!.getUserByEmail(email)) ?? {
+ id: email,
+ email,
+ emailVerified: null,
+ }
const account: Account = {
providerAccountId: email,
diff --git a/packages/core/src/types.ts b/packages/core/src/types.ts
index 9e4f0f12..555bbdaa 100644
--- a/packages/core/src/types.ts
+++ b/packages/core/src/types.ts
@@ -71,6 +71,7 @@ import type {
import type { JWT, JWTOptions } from "./jwt.js"
import type { Cookie } from "./lib/cookie.js"
import type { LoggerInstance } from "./lib/utils/logger.js"
+import { AuthConfig } from "./index.js"
export type { AuthConfig } from "./index.js"
export type Awaitable = T | PromiseLike
@@ -103,19 +104,19 @@ export type TokenSet = Partial<
* and also extends `TokenSet`, which is different tokens returned by OAuth Providers.
*/
export interface Account extends Partial {
+ /** Provider's id for this account. Eg.: "google" */
+ provider: string
/**
* This value depends on the type of the provider being used to create the account.
- * - oauth: The OAuth account's id, returned from the `profile()` callback.
+ * - oauth/oidc: The OAuth account's id, returned from the `profile()` callback.
* - email: The user's email address.
* - credentials: `id` returned from the `authorize()` callback
*/
providerAccountId: string
- /** id of the user this account belongs to. */
- userId?: string
- /** id of the provider used for this account */
- provider: string
/** Provider's type for this account */
type: ProviderType
+ /** id of the user this account belongs to */
+ userId?: string
}
/** The OAuth profile returned from your provider */
@@ -265,7 +266,7 @@ export interface EventCallbacks {
*/
signOut: (
message:
- | { session: Awaited> }
+ | { session: Awaited["deleteSession"]>> }
| { token: Awaited> }
) => Awaitable
createUser: (message: { user: User }) => Awaitable
@@ -349,53 +350,6 @@ export interface DefaultSession {
*/
export interface Session extends DefaultSession {}
-export type SessionStrategy = "jwt" | "database"
-
-/** [Documentation](https://authjs.dev/reference/configuration/auth-config#session) */
-export interface SessionOptions {
- /**
- * Choose how you want to save the user session.
- * The default is `"jwt"`, an encrypted JWT (JWE) in the session cookie.
- *
- * If you use an `adapter` however, we default it to `"database"` instead.
- * You can still force a JWT session by explicitly defining `"jwt"`.
- *
- * When using `"database"`, the session cookie will only contain a `sessionToken` value,
- * which is used to look up the session in the database.
- *
- * [Documentation](https://authjs.dev/reference/configuration/auth-config#session) | [Adapter](https://authjs.dev/reference/configuration/auth-config#adapter) | [About JSON Web Tokens](https://authjs.dev/reference/faq#json-web-tokens)
- */
- strategy: SessionStrategy
- /**
- * Relative time from now in seconds when to expire the session
- *
- * @default 2592000 // 30 days
- */
- maxAge: number
- /**
- * How often the session should be updated in seconds.
- * If set to `0`, session is updated every time.
- *
- * @default 86400 // 1 day
- */
- updateAge: number
- /**
- * Generate a custom session token for database-based sessions.
- * By default, a random UUID or string is generated depending on the Node.js version.
- * However, you can specify your own custom string (such as CUID) to be used.
- *
- * @default `randomUUID` or `randomBytes.toHex` depending on the Node.js version
- */
- generateSessionToken: () => string
-}
-
-export interface DefaultUser {
- id: string
- name?: string | null
- email?: string | null
- image?: string | null
-}
-
/**
* The shape of the returned object in the OAuth providers' `profile` callback,
* available in the `jwt` and `session` callbacks,
@@ -406,7 +360,12 @@ export interface DefaultUser {
* [`jwt` callback](https://authjs.dev/guides/basics/callbacks#jwt-callback) |
* [`profile` OAuth provider callback](https://authjs.dev/guides/providers/custom-provider)
*/
-export interface User extends DefaultUser {}
+export interface User {
+ id: string
+ name?: string | null
+ email?: string | null
+ image?: string | null
+}
// Below are types that are only supposed be used by next-auth internally
@@ -469,11 +428,11 @@ export interface InternalOptions {
theme: Theme
debug: boolean
logger: LoggerInstance
- session: Required
+ session: NonNullable>
pages: Partial
jwt: JWTOptions
events: Partial
- adapter: Adapter | undefined
+ adapter: Required | undefined
callbacks: CallbacksOptions
cookies: CookiesOptions
callbackUrl: string
From 7462e797dee6f2ecd405cc37885b6ceb36f3be91 Mon Sep 17 00:00:00 2001
From: Lluis Agusti
Date: Sun, 5 Mar 2023 17:18:31 +0100
Subject: [PATCH 06/80] fix(adapter): improve Adapter docs, add runtime
assertions (#6877)
* docs(adapters): move dgraph adapters docs to source code
* refactor: review suggestions (1)
* docs(prisma): move content to source code
* chore: sort
* fix: dgraph logo and content
---
docs/docs/reference/06-adapters/prisma.md | 210 ---------------------
docs/docusaurus.config.js | 48 +++--
docs/sidebars.js | 3 +-
packages/adapter-dgraph/README.md | 6 -
packages/adapter-dgraph/logo.svg | 15 ++
packages/adapter-dgraph/src/index.ts | 7 +-
packages/adapter-prisma/src/index.ts | 219 ++++++++++++++++++++++
7 files changed, 271 insertions(+), 237 deletions(-)
delete mode 100644 docs/docs/reference/06-adapters/prisma.md
create mode 100644 packages/adapter-dgraph/logo.svg
diff --git a/docs/docs/reference/06-adapters/prisma.md b/docs/docs/reference/06-adapters/prisma.md
deleted file mode 100644
index a9cbbc95..00000000
--- a/docs/docs/reference/06-adapters/prisma.md
+++ /dev/null
@@ -1,210 +0,0 @@
----
-id: prisma
-title: Prisma
----
-
-To use this Adapter, you need to install Prisma Client, Prisma CLI, and the separate `@next-auth/prisma-adapter` package:
-
-```bash npm2yarn
-npm install next-auth @prisma/client @next-auth/prisma-adapter
-npm install prisma --save-dev
-```
-
-Configure your Auth.js to use the Prisma Adapter:
-
-```javascript title="pages/api/auth/[...nextauth].js"
-import NextAuth from "next-auth"
-import GoogleProvider from "next-auth/providers/google"
-import { PrismaAdapter } from "@next-auth/prisma-adapter"
-import { PrismaClient } from "@prisma/client"
-
-const prisma = new PrismaClient()
-
-export default NextAuth({
- adapter: PrismaAdapter(prisma),
- providers: [
- GoogleProvider({
- clientId: process.env.GOOGLE_CLIENT_ID,
- clientSecret: process.env.GOOGLE_CLIENT_SECRET,
- }),
- ],
-})
-```
-
-Schema for the Prisma Adapter (`@next-auth/prisma-adapter`)
-
-## Setup
-
-### Create the Prisma schema
-
-You need to use at least Prisma 2.26.0. Create a schema file in `prisma/schema.prisma` similar to this one:
-
-> This schema is adapted for use in Prisma and based upon our main [schema](/reference/adapters/models)
-
-```json title="schema.prisma"
-datasource db {
- provider = "postgresql"
- url = env("DATABASE_URL")
- shadowDatabaseUrl = env("SHADOW_DATABASE_URL") // Only needed when using a cloud provider that doesn't support the creation of new databases, like Heroku. Learn more: https://pris.ly/d/migrate-shadow
-}
-
-generator client {
- provider = "prisma-client-js"
- previewFeatures = ["referentialActions"] // You won't need this in Prisma 3.X or higher.
-}
-
-model Account {
- id String @id @default(cuid())
- userId String
- type String
- provider String
- providerAccountId String
- refresh_token String? @db.Text
- access_token String? @db.Text
- expires_at Int?
- token_type String?
- scope String?
- id_token String? @db.Text
- session_state String?
-
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
-
- @@unique([provider, providerAccountId])
-}
-
-model Session {
- id String @id @default(cuid())
- sessionToken String @unique
- userId String
- expires DateTime
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
-}
-
-model User {
- id String @id @default(cuid())
- name String?
- email String? @unique
- emailVerified DateTime?
- image String?
- accounts Account[]
- sessions Session[]
-}
-
-model VerificationToken {
- identifier String
- token String @unique
- expires DateTime
-
- @@unique([identifier, token])
-}
-```
-
-:::note
-When using the MySQL connector for Prisma, the [Prisma `String` type](https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#string) gets mapped to `varchar(191)` which may not be long enough to store fields such as `id_token` in the `Account` model. This can be avoided by explicitly using the `Text` type with `@db.Text`.
-:::
-
-### Create the database schema with Prisma Migrate
-
-```
-npx prisma migrate dev
-```
-
-This will create an SQL migration file and execute it.
-
-Note that you will need to specify your database connection string in the environment variable `DATABASE_URL`. You can do this by setting it in a `.env` file at the root of your project.
-
-To learn more about [Prisma Migrate](https://www.prisma.io/migrate), check out the [Migrate docs](https://www.prisma.io/docs/concepts/components/prisma-migrate).
-
-### Generate Client
-
-Once you have saved your schema, use the Prisma CLI to generate the Prisma Client:
-
-```
-npx prisma generate
-```
-
-To configure your database to use the new schema (i.e. create tables and columns) use the `prisma migrate` command:
-
-```
-npx prisma migrate dev
-```
-
-### MongoDB
-
-Prisma supports MongoDB, and so does Auth.js. Following the instructions of the [Prisma documentation](https://www.prisma.io/docs/concepts/database-connectors/mongodb) on the MongoDB connector, things you have to change are:
-
-1. Make sure that the id fields are mapped correctly
-
-```prisma
-id String @id @default(auto()) @map("_id") @db.ObjectId
-```
-
-2. The Native database type attribute to `@db.String` from `@db.Text` and userId to `@db.ObjectId`.
-
-```prisma
-user_id String @db.ObjectId
-refresh_token String? @db.String
-access_token String? @db.String
-id_token String? @db.String
-```
-
-Everything else should be the same.
-
-## Naming Conventions
-
-If mixed snake_case and camelCase column names is an issue for you and/or your underlying database system, we recommend using Prisma's `@map()`([see the documentation here](https://www.prisma.io/docs/concepts/components/prisma-schema/names-in-underlying-database)) feature to change the field names. This won't affect Auth.js, but will allow you to customize the column names to whichever naming convention you wish.
-
-For example, moving to `snake_case` and plural table names.
-
-```json title="schema.prisma"
-model Account {
- id String @id @default(cuid())
- userId String @map("user_id")
- type String
- provider String
- providerAccountId String @map("provider_account_id")
- refresh_token String? @db.Text
- access_token String? @db.Text
- expires_at Int?
- token_type String?
- scope String?
- id_token String? @db.Text
- session_state String?
-
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
-
- @@unique([provider, providerAccountId])
- @@map("accounts")
-}
-
-model Session {
- id String @id @default(cuid())
- sessionToken String @unique @map("session_token")
- userId String @map("user_id")
- expires DateTime
- user User @relation(fields: [userId], references: [id], onDelete: Cascade)
-
- @@map("sessions")
-}
-
-model User {
- id String @id @default(cuid())
- name String?
- email String? @unique
- emailVerified DateTime? @map("email_verified")
- image String?
- accounts Account[]
- sessions Session[]
-
- @@map("users")
-}
-
-model VerificationToken {
- identifier String
- token String @unique
- expires DateTime
-
- @@unique([identifier, token])
- @@map("verificationtokens")
-}
-```
diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js
index c486fbe0..7c549057 100644
--- a/docs/docusaurus.config.js
+++ b/docs/docusaurus.config.js
@@ -1,3 +1,5 @@
+// @ts-check
+
const fs = require("fs")
const path = require("path")
@@ -11,6 +13,25 @@ const providers = fs
const typedocConfig = require("./typedoc.json")
delete typedocConfig.$schema
+/**
+ * @param {string} name
+ * @returns Record
+ */
+function createTypeDocAdapterConfig(name) {
+ const slug = name.toLowerCase().replace(" ", "-")
+ return {
+ id: slug,
+ plugin: [require.resolve("./typedoc-mdn-links")],
+ watch: process.env.TYPEDOC_WATCH,
+ entryPoints: [`../packages/adapter-${slug}/src/index.ts`],
+ tsconfig: `../packages/adapter-${slug}/tsconfig.json`,
+ out: `reference/adapter/${slug}`,
+ sidebar: {
+ indexLabel: name,
+ },
+ }
+}
+
/** @type {import("@docusaurus/types").Config} */
const docusaurusConfig = {
title: "Auth.js",
@@ -230,30 +251,21 @@ const docusaurusConfig = {
"docusaurus-plugin-typedoc",
{
...typedocConfig,
- id: "firebase-adapter",
- plugin: [require.resolve("./typedoc-mdn-links")],
- watch: process.env.TYPEDOC_WATCH,
- entryPoints: ["../packages/adapter-firebase/src/index.ts"],
- tsconfig: "../packages/adapter-firebase/tsconfig.json",
- out: "reference/adapter/firebase",
- sidebar: {
- indexLabel: "Firebase",
- },
+ ...createTypeDocAdapterConfig("Firebase"),
},
],
[
"docusaurus-plugin-typedoc",
{
...typedocConfig,
- id: "dgraph-adapter",
- plugin: [require.resolve("./typedoc-mdn-links")],
- watch: process.env.TYPEDOC_WATCH,
- entryPoints: ["../packages/adapter-dgraph/src/index.ts"],
- tsconfig: "../packages/adapter-dgraph/tsconfig.json",
- out: "reference/adapter/dgraph",
- sidebar: {
- indexLabel: "Dgraph",
- },
+ ...createTypeDocAdapterConfig("Dgraph"),
+ },
+ ],
+ [
+ "docusaurus-plugin-typedoc",
+ {
+ ...typedocConfig,
+ ...createTypeDocAdapterConfig("Prisma"),
},
],
],
diff --git a/docs/sidebars.js b/docs/sidebars.js
index 17e4b966..929f0de9 100644
--- a/docs/sidebars.js
+++ b/docs/sidebars.js
@@ -50,8 +50,9 @@ module.exports = {
label: "Database Adapters",
link: { type: "doc", id: "reference/adapters/overview" },
items: [
- { type: "doc", id: "reference/adapter/firebase/index" },
{ type: "doc", id: "reference/adapter/dgraph/index" },
+ { type: "doc", id: "reference/adapter/firebase/index" },
+ { type: "doc", id: "reference/adapter/prisma/index" },
{ type: "autogenerated", dirName: "reference/06-adapters" },
],
},
diff --git a/packages/adapter-dgraph/README.md b/packages/adapter-dgraph/README.md
index 4aa5b16c..813a28b8 100644
--- a/packages/adapter-dgraph/README.md
+++ b/packages/adapter-dgraph/README.md
@@ -5,11 +5,6 @@
Open Source. Full Stack. Own Your Data.
-
## Overview
@@ -152,7 +147,6 @@ type User
We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
## License
ISC
diff --git a/packages/adapter-dgraph/logo.svg b/packages/adapter-dgraph/logo.svg
new file mode 100644
index 00000000..3b26aabc
--- /dev/null
+++ b/packages/adapter-dgraph/logo.svg
@@ -0,0 +1,15 @@
+
\ No newline at end of file
diff --git a/packages/adapter-dgraph/src/index.ts b/packages/adapter-dgraph/src/index.ts
index 8d609049..62b2c1fb 100644
--- a/packages/adapter-dgraph/src/index.ts
+++ b/packages/adapter-dgraph/src/index.ts
@@ -1,6 +1,9 @@
/**
*
- *
Official Dgraph adapter for Auth.js / NextAuth.js.
+ *
Official Dgraph adapter for Auth.js / NextAuth.js.
*
@@ -44,7 +44,7 @@ export interface DynamoDBAdapterOptions {
* By default, the adapter expects a table with a partition key `pk` and a sort key `sk`, as well as a global secondary index named `GSI1` with `GSI1PK` as partition key and `GSI1SK` as sorting key. To automatically delete sessions and verification requests after they expire using [dynamodb TTL](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html) you should [enable the TTL](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-how-to.html) with attribute name 'expires'. You can set whatever you want as the table name and the billing method.
* You can find the full schema in the table structure section below.
*
- * ## Configuring `pages/api/auth/[...nextauth].js`
+ * ## Configuring Auth.js
*
* You need to pass `DynamoDBDocument` client from the modular [`aws-sdk`](https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/dynamodb-example-dynamodb-utilities.html) v3 to the adapter.
* The default table name is `next-auth`, but you can customise that by passing `{ tableName: 'your-table-name' }` as the second parameter in the adapter.
diff --git a/packages/adapter-fauna/src/index.ts b/packages/adapter-fauna/src/index.ts
index 0e613b57..29cd0b1e 100644
--- a/packages/adapter-fauna/src/index.ts
+++ b/packages/adapter-fauna/src/index.ts
@@ -1,4 +1,20 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
+/**
+ *
-## Overview
+---
-This is the PouchDB Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-Depending on your architecture you can use PouchDB's http adapter to reach any database compliant with the CouchDB protocol (CouchDB, Cloudant, ...) or use any other PouchDB compatible adapter (leveldb, in-memory, ...)
-
-## Getting Started
-
-1. Install `next-auth` and `@next-auth/pouchdb-adapter`, as well as `pouchdb`.
-
-> **Prerequisite**: Your PouchDB instance MUST provide the `pouchdb-find` plugin since it is used internally by the adapter to build and manage indexes
-
-```js
-npm install next-auth @next-auth/pouchdb-adapter pouchdb
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import Providers from "next-auth/providers"
-import { PouchDBAdapter } from "@next-auth/pouchdb-adapter"
-import PouchDB from "pouchdb"
-
-// Setup your PouchDB instance and database
-PouchDB.plugin(require("pouchdb-adapter-leveldb")) // Or any other PouchDB-compliant adapter
- .plugin(require("pouchdb-find")) // Don't forget the `pouchdb-find` plugin
-
-const pouchdb = new PouchDB("auth_db", { adapter: "leveldb" })
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-options
-export default NextAuth({
- // https://authjs.dev/reference/providers/oauth-builtin
- providers: [
- Providers.Google({
- clientId: process.env.GOOGLE_ID,
- clientSecret: process.env.GOOGLE_SECRET,
- }),
- ],
- adapter: PouchDBAdapter(pouchdb),
- // ...
-})
-```
-
-## Advanced
-
-### Memory-First Caching Strategy
-
-If you need to boost your authentication layer performance, you may use PouchDB's powerful sync features and various adapters, to build a memory-first caching strategy.
-
-Use an in-memory PouchDB as your main authentication database, and synchronize it with any other persisted PouchDB. You may do a one way, one-off replication at startup from the persisted PouchDB into the in-memory PouchDB, then two-way, continuous, retriable sync.
-
-This will probably not improve performance much in a serverless environment for various reasons such as concurrency, function startup time increases, etc.
-
-For more details, please see https://pouchdb.com/api.html#sync
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/pouchdb).
\ No newline at end of file
diff --git a/packages/adapter-pouchdb/package.json b/packages/adapter-pouchdb/package.json
index ebc03b5f..a180e335 100644
--- a/packages/adapter-pouchdb/package.json
+++ b/packages/adapter-pouchdb/package.json
@@ -8,7 +8,6 @@
"url": "https://github.com/nextauthjs/next-auth/issues"
},
"author": "jpbourgeon (https://github.com/jpbourgeon)",
- "main": "dist/index.js",
"license": "ISC",
"keywords": [
"next-auth",
@@ -16,27 +15,35 @@
"oauth",
"pouchdb"
],
+ "type": "module",
+ "exports": {
+ ".": {
+ "types": "./index.d.ts",
+ "import": "./index.js"
+ }
+ },
"private": false,
"publishConfig": {
"access": "public"
},
"scripts": {
- "build:wip": "tsc",
- "tdd": "jest --watch",
- "test:wip": "jest"
+ "build": "pnpm clean && tsc",
+ "clean": "rm -rf index.*",
+ "test": "jest",
+ "test:dev": "jest --watch"
},
"files": [
- "README.md",
- "dist"
+ "*.js",
+ "*.d.ts*",
+ "src"
],
"peerDependencies": {
- "next-auth": "^3",
- "pouchdb": "^7.2.2",
- "pouchdb-find": "^7.2.2"
+ "next-auth": "^4",
+ "pouchdb": "^8.0.1",
+ "pouchdb-find": "^8.0.1"
},
"dependencies": {
- "crypto": "^1.0.1",
- "ulid": "^2.3.0"
+ "ulid": "2.3.0"
},
"devDependencies": {
"@next-auth/adapter-test": "workspace:*",
@@ -44,11 +51,11 @@
"@types/pouchdb": "^6.4.0",
"jest": "^27.4.3",
"next-auth": "workspace:*",
- "pouchdb": "^7.2.2",
- "pouchdb-adapter-memory": "^7.2.2",
- "pouchdb-find": "^7.2.2"
+ "pouchdb": "^8.0.1",
+ "pouchdb-adapter-memory": "^8.0.1",
+ "pouchdb-find": "^8.0.1"
},
"jest": {
"preset": "@next-auth/adapter-test/jest"
}
-}
\ No newline at end of file
+}
diff --git a/packages/adapter-pouchdb/src/index.ts b/packages/adapter-pouchdb/src/index.ts
index c3e6f208..aca57e22 100644
--- a/packages/adapter-pouchdb/src/index.ts
+++ b/packages/adapter-pouchdb/src/index.ts
@@ -1,359 +1,444 @@
-import type { Adapter } from "next-auth/adapters"
-import { createHash, randomBytes } from "crypto"
-import { Profile } from "next-auth"
+/**
+ *
+ *
Official PouchDB adapter for Auth.js / NextAuth.js.
-## Overview
+---
-This is the Dgraph Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-You can find two Graphql schemas in the [`docs`](https://authjs.dev/adapters/dgraph/schema.gql).
-
-1. The unsecure don't implement any auth directive is perfect for a quick start.
-2. The second one is more secure and require you replace some value before copy pasting it into your Dgraph console ([`see Securing your database`](#securing-your-database)).
-
-## Getting Started
-
-1. Install `next-auth` and `@next-auth/dgraph-adapter`
-
-```js
-npm install next-auth @next-auth/dgraph-adapter
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import { DgraphAdapter } from "@next-auth/dgraph-adapter";
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-options
-export default NextAuth({
- // https://authjs.dev/reference/providers/oauth-builtin
- providers: [
- ...,
- ],
- adapter: DgraphAdapter({
- endpoint: process.env.DGRAPH_GRAPHQL_ENDPOINT,
- authToken: process.env.DGRAPH_GRAPHQL_KEY,
-
- // you can omit the following properties if you are running an unsecure schema
- authHeader: "",
- jwtSecret: process.env.SECRET
- })
- ...
-})
-```
-
-## Quick start with the unsecure schema
-
-The simplest way to use Dgraph is by copy pasting the unsecure schema into your dashboard. Then create an api client key and grab your endpoint to initialize your `DgraphClient`. Forget about `authHeader` and `jwtSecret`.
-
-## Securing your database
-
-Fore sake of security and mostly if your client directly communicate with the graphql server you obviously want to restrict the access to the types used by next-auth. That's why you see a lot of @auth directive alongside this types in the schema.
-
-### Dgraph.Authorization
-
-The first thing to do in order to secure your graphql backend is to define the `Dgraph.Authorization` object at the bottom of your schema and provide `authHeader` and `jwtSecret` values to the DgraphClient.
-
-```js
-# Dgraph.Authorization {"VerificationKey":"","Header":"","Namespace":"","Algo":"HS256"}
-```
-
-### VerificationKey and jwtSecret
-
-This is the key you use to sign the JWT. Probably your `process.env.SECRET`.
-
-### Header and authHeader
-
-The `Header` tells Dgraph where to lookup for a jwt with auth credentials. You have to configure it a te bottom of your schema. This header is the same as the `authHeader` property you provide when you instantiate the DgraphClient.
-
-## Working with JWT session and @auth directive
-
-Dgraph only works with HS256 or RS256 algorithms. If you want to use session jwt to securely interact with your dgraph database you have to customize next-auth encode and decode functions because the default algorithm is HS512. You can there going further and customize the jwt with roles if you want to implement [`RBAC logic`](https://dgraph.io/docs/graphql/authorization/directive/#role-based-access-control).
-
-```js
-import * as jwt from "jsonwebtoken";
-
-export default NextAuth({
-
-...
-
-session: {
- jwt: true
- },
- jwt: {
- secret: process.env.SECRET,
- encode: async ({ secret, token }) => {
- return jwt.sign({
- ...token,
- userId: token.id,
- // role: "ADMIN" for RBAC
- },
- secret,
- {
- algorithm: "HS256",
- expiresIn: 30 * 24 * 60 * 60; // 30 days
- });;
- },
- decode: async ({ secret, token }) => {
- return jwt.verify(token, secret, { algorithms: ["HS256"] });
- }
- },
-
-...
-
-})
-```
-
-Once your `Dgraph.Authorization` define in your schema and this JWT settings set, this will allow you to define [`@auth rules`](https://dgraph.io/docs/graphql/authorization/authorization-overview/) for every part of your schema.
-
-## @auth implementation
-
-```graphql
-
-type User
- @auth(
- ...
-
- query: { or: [
- {
- rule: """
- query ($userId: String!) {
- queryUser(filter: { id: { eq: $userId } } ) {
- id
- }
- }
- """
- },
- { rule: "{$role { eq: "ADMIN" } }" }
- { rule: "{$nextAuth { eq: true } }" },
- ]},
-
- ...
- ) {
- id: ID
- ...
-}
-
-```
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/dgraph).
\ No newline at end of file
diff --git a/packages/adapter-dgraph/src/index.ts b/packages/adapter-dgraph/src/index.ts
index 16f9d6af..d4e034e9 100644
--- a/packages/adapter-dgraph/src/index.ts
+++ b/packages/adapter-dgraph/src/index.ts
@@ -2,7 +2,7 @@
*
*
Official DynamoDB adapter for Auth.js / NextAuth.js.
-## Overview
+---
-This is the AWS DynamoDB Adapter for next-auth. This package can only be used in conjunction with the primary next-auth package. It is not a standalone package.
-
-You need a table with a partition key `pk` and a sort key `sk`. Your table also needs a global secondary index named `GSI1` with `GSI1PK` as partition key and `GSI1SK` as sorting key. You can set whatever you want as the table name and the billing method.
-
-If you want sessions and verification tokens to get automatically removed from your table you need to [activate TTL](https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html) on your table with the TTL attribute name set to `expires`
-
-You can find the DynamoDB schema in the docs at [authjs.dev/reference/adapters/dynamodb](https://authjs.dev/reference/adapters/dynamodb).
-
-## Getting Started
-
-1. Install `next-auth` and `@next-auth/dynamodb-adapter`
-
-```js
-npm install next-auth @next-auth/dynamodb-adapter
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-You need to pass `DocumentClient` instance from `aws-sdk` to the adapter.
-The default table name is `next-auth`, but you can customise that by passing `{ tableName: 'your-table-name' }` as the second parameter in the adapter.
-
-```js
-import { DynamoDB } from "@aws-sdk/client-dynamodb"
-import { DynamoDBDocument } from "@aws-sdk/lib-dynamodb"
-import NextAuth from "next-auth";
-import Providers from "next-auth/providers";
-import { DynamoDBAdapter } from "@next-auth/dynamodb-adapter"
-
-const config: DynamoDBClientConfig = {
- credentials: {
- accessKeyId: process.env.NEXT_AUTH_AWS_ACCESS_KEY as string,
- secretAccessKey: process.env.NEXT_AUTH_AWS_SECRET_KEY as string,
- },
- region: process.env.NEXT_AUTH_AWS_REGION,
-};
-
-const client = DynamoDBDocument.from(new DynamoDB(config), {
- marshallOptions: {
- convertEmptyValues: true,
- removeUndefinedValues: true,
- convertClassInstanceToMap: true,
- },
-})
-
-export default NextAuth({
- // Configure one or more authentication providers
- providers: [
- Providers.GitHub({
- clientId: process.env.GITHUB_ID,
- clientSecret: process.env.GITHUB_SECRET,
- }),
- Providers.Email({
- server: process.env.EMAIL_SERVER,
- from: process.env.EMAIL_FROM,
- }),
- // ...add more providers here
- ],
- adapter: DynamoDBAdapter(
- client
- ),
- ...
-});
-```
-
-(AWS secrets start with `NEXT_AUTH_` in order to not conflict with [Vercel's reserved environment variables](https://vercel.com/docs/environment-variables#reserved-environment-variables).)
-
-## Table structure
-
-The table respects the single table design pattern. This has many advantages:
-
-- Only one table to manage, monitor and provision.
-- Querying relations is faster than with multi-table schemas (for eg. retrieving all sessions for a user).
-- Only one table needs to be replicated, if you want to go multi-region.
-
-Here is a schema of the table :
-
-
-
-
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/dynamodb).
\ No newline at end of file
diff --git a/packages/adapter-fauna/CHANGELOG.md b/packages/adapter-fauna/CHANGELOG.md
deleted file mode 100644
index eb189d95..00000000
--- a/packages/adapter-fauna/CHANGELOG.md
+++ /dev/null
@@ -1,49 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-## [1.0.2](https://github.com/nextauthjs/adapters/compare/@next-auth/fauna-adapter@1.0.1...@next-auth/fauna-adapter@1.0.2) (2022-01-10)
-
-### Bug Fixes
-
-- **fauna:** Convert `value` prop to `Date` only if of type `string` ([#365](https://github.com/nextauthjs/adapters/issues/365)) ([c8dad2b](https://github.com/nextauthjs/adapters/commit/c8dad2b1bf74ab1574c92ee5fda879d798a43977)), closes [#364](https://github.com/nextauthjs/adapters/issues/364)
-
-## [1.0.1](https://github.com/nextauthjs/adapters/compare/@next-auth/fauna-adapter@1.0.0...@next-auth/fauna-adapter@1.0.1) (2021-12-06)
-
-**Note:** Version bump only for package @next-auth/fauna-adapter
-
-## [0.2.4](https://github.com/nextauthjs/adapters/compare/@next-auth/fauna-adapter@0.2.3...@next-auth/fauna-adapter@0.2.4) (2021-10-27)
-
-### Reverts
-
-- Revert "docs(fauna): update `README.md` (#244)" (#246) ([26cd24a](https://github.com/nextauthjs/adapters/commit/26cd24a6eba3d42ed7febd5eb45b13c236c57819)), closes [#244](https://github.com/nextauthjs/adapters/issues/244) [#246](https://github.com/nextauthjs/adapters/issues/246)
-
-## [0.2.3](https://github.com/nextauthjs/adapters/compare/@next-auth/fauna-adapter@0.2.2...@next-auth/fauna-adapter@0.2.3) (2021-09-19)
-
-**Note:** Version bump only for package @next-auth/fauna-adapter
-
-## [0.2.2](https://github.com/nextauthjs/adapters/compare/@next-auth/fauna-adapter@0.2.1...@next-auth/fauna-adapter@0.2.2) (2021-07-02)
-
-**Note:** Version bump only for package @next-auth/fauna-adapter
-
-## [0.2.1](https://github.com/nextauthjs/adapters/compare/@next-auth/fauna-adapter@0.2.0...@next-auth/fauna-adapter@0.2.1) (2021-06-30)
-
-### Bug Fixes
-
-- **fauna:** change the name of the index to `verification_request_by_token_and_identifier` ([#157](https://github.com/nextauthjs/adapters/issues/157)) ([01a3c52](https://github.com/nextauthjs/adapters/commit/01a3c5205f30eec57c7b9298b762cccf1f2400fd))
-
-# [0.2.0](https://github.com/nextauthjs/adapters/compare/@next-auth/fauna-adapter@0.1.0...@next-auth/fauna-adapter@0.2.0) (2021-06-30)
-
-### Bug Fixes
-
-- adapter export function name ([eb6a21a](https://github.com/nextauthjs/adapters/commit/eb6a21a0302ef42a32314e48a75542bade26605e))
-- include /dist files in published build ([751ea95](https://github.com/nextauthjs/adapters/commit/751ea95a3b40dc3a94bf4de6253974e1664a2661))
-- merge conflicts ([aa48f2f](https://github.com/nextauthjs/adapters/commit/aa48f2f7586345764d0a586df23534f9abc2b53d))
-- rm type=module from package.json ([c207348](https://github.com/nextauthjs/adapters/commit/c207348d126a766abe341e6afe36b04d47c6bac6))
-- specify module in package.json ([d6e85ce](https://github.com/nextauthjs/adapters/commit/d6e85ce68b0a7d70f6b6078ac8d66e36c4724131))
-- test match new export ([ee96664](https://github.com/nextauthjs/adapters/commit/ee966647dadbc649d6a93f5ae4d5fb5deb6f6772))
-
-### Features
-
-- add build step to package.json ([28a4f40](https://github.com/nextauthjs/adapters/commit/28a4f403b07fc115c171623d6801c9392f50bd28))
diff --git a/packages/adapter-fauna/README.md b/packages/adapter-fauna/README.md
index f4a43330..f855aac0 100644
--- a/packages/adapter-fauna/README.md
+++ b/packages/adapter-fauna/README.md
@@ -1,60 +1,28 @@
-## Overview
+---
-This is the Fauna Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-You can find the Fauna schema and seed information in the docs at [authjs.dev/reference/adapters/fauna](https://authjs.dev/reference/adapters/fauna).
-
-## Getting Started
-
-1. Install `faunadb`, `next-auth` and `@next-auth/fauna-adapter`
-
-```js
-npm install faunadb next-auth @next-auth/fauna-adapter@next
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import { Client as FaunaClient } from "faunadb"
-import { FaunaAdapter } from "@next-auth/fauna-adapter"
-
-const client = new FaunaClient({
- secret: "secret",
- scheme: "http",
- domain: "localhost",
- port: 8443,
-})
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-options
-export default NextAuth({
- // https://authjs.dev/reference/providers/oauth-builtin
- providers: [],
- adapter: FaunaAdapter(client)
- ...
-})
-```
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/fauna).
\ No newline at end of file
diff --git a/packages/adapter-fauna/src/index.ts b/packages/adapter-fauna/src/index.ts
index 29cd0b1e..82c84a38 100644
--- a/packages/adapter-fauna/src/index.ts
+++ b/packages/adapter-fauna/src/index.ts
@@ -3,7 +3,7 @@
*
+---
-This is the official Firebase Adapter for [Auth.js](https://authjs.dev) / [NextAuth.js](https://next-auth.js.org/), using the [Firebase Admin SDK](https://firebase.google.com/docs/admin/setup) and [Firestore](https://firebase.google.com/docs/firestore).
-
-## Documentation
-
-Check out the [documentation](https://authjs.dev/reference/adapter/firebase) to learn how to use this adapter in your project.
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/firebase).
\ No newline at end of file
diff --git a/packages/adapter-firebase/src/index.ts b/packages/adapter-firebase/src/index.ts
index 577853e7..2fdf9d04 100644
--- a/packages/adapter-firebase/src/index.ts
+++ b/packages/adapter-firebase/src/index.ts
@@ -5,7 +5,7 @@
* using the Firebase Admin SDK
* and Firestore.
*
- *
+ *
*
*
*
diff --git a/packages/adapter-mikro-orm/CHANGELOG.md b/packages/adapter-mikro-orm/CHANGELOG.md
deleted file mode 100644
index 6519a20a..00000000
--- a/packages/adapter-mikro-orm/CHANGELOG.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-## [1.0.1](https://github.com/nextauthjs/adapters/compare/@next-auth/mikro-orm-adapter@1.0.0...@next-auth/mikro-orm-adapter@1.0.1) (2021-12-06)
-
-**Note:** Version bump only for package @next-auth/mikro-orm-adapter
diff --git a/packages/adapter-mikro-orm/README.md b/packages/adapter-mikro-orm/README.md
index 6965546d..ffa08208 100644
--- a/packages/adapter-mikro-orm/README.md
+++ b/packages/adapter-mikro-orm/README.md
@@ -1,56 +1,28 @@
-## Overview
+---
-This is the MikroORM Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-## Getting Started
-
-1. Install `next-auth` and `@next-auth/mikro-orm-adapter`
-
- ```js
- npm install next-auth @next-auth/mikro-orm-adapter@next
- ```
-
-2. Add this adapter to your `pages/api/[...nextauth].ts` next-auth configuration object.
-
- ```typescript title="pages/api/auth/[...nextauth].ts"
- import NextAuth from "next-auth"
- import { MikroOrmAdapter } from "@next-auth/mikro-orm-adapter"
-
- // For more information on each option (and a full list of options) go to
- // https://authjs.dev/reference/configuration/auth-options
- export default NextAuth({
- // https://authjs.dev/reference/providers/oauth-builtin
- providers: [],
- adapter: MikroOrmAdapter({
- dbName: "./db.sqlite",
- type: "sqlite",
- debug: process.env.DEBUG === "true" || process.env.DEBUG?.includes("db"),
- ...
- }, {
- // pass extended models as { entities: { } } if needed
- }),
- ...
- });
- ```
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/mikro-orm).
\ No newline at end of file
diff --git a/packages/adapter-mongodb/CHANGELOG.md b/packages/adapter-mongodb/CHANGELOG.md
deleted file mode 100644
index 0a20d839..00000000
--- a/packages/adapter-mongodb/CHANGELOG.md
+++ /dev/null
@@ -1,8 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-## [1.0.1](https://github.com/nextauthjs/adapters/compare/@next-auth/mongodb-adapter@1.0.0...@next-auth/mongodb-adapter@1.0.1) (2021-12-06)
-
-**Note:** Version bump only for package @next-auth/mongodb-adapter
diff --git a/packages/adapter-mongodb/README.md b/packages/adapter-mongodb/README.md
index 0455e62c..87a578e5 100644
--- a/packages/adapter-mongodb/README.md
+++ b/packages/adapter-mongodb/README.md
@@ -1,88 +1,28 @@
-## Overview
+---
-This is the MongoDB Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-## Getting Started
-
-1. Install `mongodb`, `next-auth` and `@next-auth/mongodb-adapter`
-
-```js
-npm install mongodb next-auth @next-auth/mongodb-adapter@next
-```
-
-2. Add `lib/mongodb.js`
-
-```js
-// This approach is taken from https://github.com/vercel/next.js/tree/canary/examples/with-mongodb
-import { MongoClient } from "mongodb"
-
-const uri = process.env.MONGODB_URI
-const options = {
- useUnifiedTopology: true,
- useNewUrlParser: true,
-}
-
-let client
-let clientPromise
-
-if (!process.env.MONGODB_URI) {
- throw new Error("Please add your Mongo URI to .env.local")
-}
-
-if (process.env.NODE_ENV === "development") {
- // In development mode, use a global variable so that the value
- // is preserved across module reloads caused by HMR (Hot Module Replacement).
- if (!global._mongoClientPromise) {
- client = new MongoClient(uri, options)
- global._mongoClientPromise = client.connect()
- }
- clientPromise = global._mongoClientPromise
-} else {
- // In production mode, it's best to not use a global variable.
- client = new MongoClient(uri, options)
- clientPromise = client.connect()
-}
-
-// Export a module-scoped MongoClient promise. By doing this in a
-// separate module, the client can be shared across functions.
-export default clientPromise
-```
-
-3. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import { MongoDBAdapter } from "@next-auth/mongodb-adapter"
-import clientPromise from "lib/mongodb"
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-options
-export default NextAuth({
- adapter: MongoDBAdapter(clientPromise, {
- databaseName: 'my-data-base-name'
- }),
- ...
-})
-```
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/mongodb).
\ No newline at end of file
diff --git a/packages/adapter-mongodb/src/index.ts b/packages/adapter-mongodb/src/index.ts
index 90da4010..f12d4b83 100644
--- a/packages/adapter-mongodb/src/index.ts
+++ b/packages/adapter-mongodb/src/index.ts
@@ -2,7 +2,7 @@
*
*
Official MongoDB adapter for Auth.js / NextAuth.js.
-## Overview
+---
-This is the Neo4j Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-You can find the Neo4j schema in the docs at [authjs.dev/reference/adapters/neo4j](authjs.dev/reference/adapters/neo4j).
-
-## Getting Started
-
-1. Install `neo4j-driver`, `next-auth` and `@next-auth/neo4j-adapter`
-
-```js
-npm install neo4j-driver next-auth @next-auth/neo4j-adapter@next
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import neo4j from "neo4j-driver"
-import { Neo4jAdapter } from "@next-auth/neo4j-adapter"
-
-// Setup your neo4j driver instance
-const driver = neo4j.driver(
- "bolt://localhost",
- neo4j.auth.basic("neo4j", "password")
-)
-const neo4jSession = driver.session()
-
-export default NextAuth({
- // https://authjs.dev/reference/providers/oauth-builtin
- providers: [],
- adapter: Neo4jAdapter(neo4jSession),
- ...
-})
-```
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please first read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/neo4j).
\ No newline at end of file
diff --git a/packages/adapter-pouchdb/README.md b/packages/adapter-pouchdb/README.md
index 0d605941..87e08c2b 100644
--- a/packages/adapter-pouchdb/README.md
+++ b/packages/adapter-pouchdb/README.md
@@ -1,9 +1,9 @@
-## Overview
+---
-This is the Prisma Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-You can find the Prisma schema in the docs at [authjs.dev/reference/adapters/prisma](https://authjs.dev/reference/adapters/prisma).
-
-## Getting Started
-
-1. Install `next-auth` and `@next-auth/prisma-adapter` as well as `prisma` and `@prisma/client`.
-
-```js
-npm install next-auth @next-auth/prisma-adapter @prisma/client
-npm install --save-dev prisma
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import { PrismaAdapter } from "@next-auth/prisma-adapter"
-import * as Prisma from "@prisma/client"
-
-const prisma = new Prisma.PrismaClient()
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-options
-export default NextAuth({
- // https://authjs.dev/reference/providers/oauth-builtin
- providers: [],
- adapter: PrismaAdapter(prisma)
- ...
-})
-```
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/prisma).
\ No newline at end of file
diff --git a/packages/adapter-prisma/src/index.ts b/packages/adapter-prisma/src/index.ts
index 69897d85..012ea823 100644
--- a/packages/adapter-prisma/src/index.ts
+++ b/packages/adapter-prisma/src/index.ts
@@ -2,7 +2,7 @@
*
*
Official Prisma adapter for Auth.js / NextAuth.js.
-## Overview
+---
-This is the Sequelize Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-You can find the Sequelize schema in the docs at [authjs.dev/reference/adapters/sequelize](https://authjs.dev/reference/adapters/sequelize).
-
-## Getting Started
-
-1. Install `next-auth` and `@next-auth/sequelize-adapter` as well as `sequelize` and your [database driver](https://sequelize.org/master/manual/getting-started.html) of choice.
-
-```js
-npm install next-auth @next-auth/sequelize-adapter sequelize sqlite3
-npm install --save-dev sequelize
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import SequelizeAdapter from "@next-auth/sequelize-adapter"
-import Sequelize from 'sequelize'
-
-const sequelize = new Sequelize("sqlite::memory:")
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-options
-export default NextAuth({
- ...
- adapter: SequelizeAdapter(sequelize)
- ...
-})
-```
-
-## Updating the database schema
-
-In development, the sequelize adapter will create the necessary tables, foreign keys and indexes in your database. In production, synchronization is disabled. Best practice is to create the [required tables](https://authjs.dev/reference/adapters/models) in your database via [migrations](https://sequelize.org/master/manual/migrations.html).
-
-In development, if you do not want the adapter to automatically create tables, you are able to pass `{ synchronize: false }` as the second option to `SequelizeAdapter` to disable this behavior:
-
-```js
-import NextAuth from "next-auth"
-import SequelizeAdapter from "@next-auth/sequelize-adapter"
-import Sequelize from 'sequelize'
-
-const sequelize = new Sequelize("sqlite::memory:")
-
-export default NextAuth({
- ...
- adapter: SequelizeAdapter(sequelize, { synchronize: false })
- ...
-})
-```
-
-## Using custom models
-
-Sequelize models are option to customization like so:
-
-```js
-import NextAuth from "next-auth"
-import SequelizeAdapter, { models } from "@next-auth/sequelize-adapter"
-import Sequelize, { DataTypes } from 'sequelize'
-
-const sequelize = new Sequelize("sqlite::memory:")
-
-export default NextAuth({
- ...
- adapter: SequelizeAdapter(sequelize, {
- models: {
- User: sequelize.define('user', { ...models.User, phoneNumber: DataTypes.STRING })
- }
- })
- ...
-})
-```
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/sequelize).
\ No newline at end of file
diff --git a/packages/adapter-supabase/README.md b/packages/adapter-supabase/README.md
index 7d6c3bbf..821aff07 100644
--- a/packages/adapter-supabase/README.md
+++ b/packages/adapter-supabase/README.md
@@ -1,57 +1,28 @@
-## Overview
+---
-This is the Supabase Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-You can find more Supabase information in the docs at [authjs.dev/reference/adapters/supabase](https://authjs.dev/reference/adapters/supabase).
-
-## Getting Started
-
-1. Install `@supabase/supabase-js`, `next-auth` and `@next-auth/supabase-adapter`.
-
-```js
-npm install @supabase/supabase-js next-auth @next-auth/supabase-adapter
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import { SupabaseAdapter } from "@next-auth/supabase-adapter"
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-options
-export default NextAuth({
- // https://authjs.dev/reference/providers/oauth-builtin
- providers: [
- // ...
- ],
- adapter: SupabaseAdapter({
- url: process.env.NEXT_PUBLIC_SUPABASE_URL,
- secret: process.env.SUPABASE_SERVICE_ROLE_KEY,
- }),
- // ...
-})
-```
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/next-auth/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/supabase).
\ No newline at end of file
diff --git a/packages/adapter-typeorm-legacy/CHANGELOG.md b/packages/adapter-typeorm-legacy/CHANGELOG.md
deleted file mode 100644
index 3b35d350..00000000
--- a/packages/adapter-typeorm-legacy/CHANGELOG.md
+++ /dev/null
@@ -1,24 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-## [1.0.1](https://github.com/nextauthjs/adapters/compare/@next-auth/typeorm-legacy-adapter@1.0.0...@next-auth/typeorm-legacy-adapter@1.0.1) (2021-12-06)
-
-**Note:** Version bump only for package @next-auth/typeorm-legacy-adapter
-
-## [0.1.4](https://github.com/nextauthjs/adapters/compare/@next-auth/typeorm-legacy-adapter@0.1.3...@next-auth/typeorm-legacy-adapter@0.1.4) (2021-08-17)
-
-**Note:** Version bump only for package @next-auth/typeorm-legacy-adapter
-
-## [0.1.3](https://github.com/nextauthjs/adapters/compare/@next-auth/typeorm-legacy-adapter@0.1.2...@next-auth/typeorm-legacy-adapter@0.1.3) (2021-07-11)
-
-**Note:** Version bump only for package @next-auth/typeorm-legacy-adapter
-
-## [0.1.2](https://github.com/nextauthjs/adapters/compare/@next-auth/typeorm-legacy-adapter@0.1.1...@next-auth/typeorm-legacy-adapter@0.1.2) (2021-07-02)
-
-**Note:** Version bump only for package @next-auth/typeorm-legacy-adapter
-
-## [0.1.1](https://github.com/nextauthjs/adapters/compare/@next-auth/typeorm-legacy-adapter@0.1.0...@next-auth/typeorm-legacy-adapter@0.1.1) (2021-06-30)
-
-**Note:** Version bump only for package @next-auth/typeorm-legacy-adapter
diff --git a/packages/adapter-typeorm-legacy/README.md b/packages/adapter-typeorm-legacy/README.md
index 7ef24335..8bff6662 100644
--- a/packages/adapter-typeorm-legacy/README.md
+++ b/packages/adapter-typeorm-legacy/README.md
@@ -1,87 +1,28 @@
-## Overview
+---
-This is the TypeORM Adapter for [`auth.js`](https://authjs.dev). This package can only be used in conjunction with the primary `auth.js` package. It is not a standalone package.
-
-You can find more TypeORM information in the docs at [authjs.dev/adapters/typeorm](https://authjs.dev/reference/adapters/typeorm).
-
-## Getting Started
-
-1. Install `typeorm`, `next-auth` and `@next-auth/typeorm-legacy-adapter`
-
-```js
-npm install next-auth @next-auth/typeorm-legacy-adapter@next typeorm
-```
-
-2. Add this adapter to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import { TypeORMLegacyAdapter } from "@next-auth/typeorm-legacy-adapter"
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-config
-export default NextAuth({
- // https://authjs.dev/reference/providers/oauth-builtin
- providers: [],
- adapter: TypeORMLegacyAdapter({
- type: 'sqlite', // or mysql, postgresql, mssql
- database: ':memory:',
- synchronize: true
- }),
- ...
-})
-```
-
-> The `synchronize` option in TypeORM will generate SQL that exactly matches the documented schemas for MySQL and Postgres.
->
-> However, it should not be enabled against production databases as it may cause data loss if the configured schema does not match the expected schema!
-
-## Options
-
-This adapter supports MySQL, PostgreSQL, SQLite, as well as MSSQL. Further configuration options are listed below.
-
-> If you're looking for MongoDB support, it's been pulled out into its own adapter [@next-auth/mongodb-adapter](https://authjs.dev/reference/adapters/mongodb).
-
-### SQLite
-
-With sqlite, you have the option of using a file on disk as the database, or using a temporary in-memory database. In the `database` field you can either pass in a valid file path to the on-disk database you want to use, or simply write `:memory:` for an in-memory database which will disappear whenever you restart the process.
-
-### MySQL
-
-For MySQL, simply pass a valid connection string to the `database` option, such as `mysql://nextauth:password@127.0.0.1:3306/nextauth?synchronise=true`, and do not forget to set the `type` value to `mysql`.
-
-Schema: [mysql/schema.sql](https://github.com/nextauthjs/adapters/tree/canary/packages/typeorm-legacy/tests/mysql/schema.sql)
-
-### PostgreSQL
-
-For PostgreSQL, you also only need to pass a valid connection string to the `database` option, such as `postgres://nextauth:password@127.0.0.1:5432/nextauth`, and do not forget to set the `type` value to `postgres`.
-
-Schema: [postgresql/schema.sql](https://github.com/nextauthjs/adapters/tree/canary/packages/typeorm-legacy/tests/postgresql/schema.sql)
-
-### Microsoft SQL Server
-
-For MsSQL, pass a valid connection string to the `database` option, such as `mssql://nextauth:password@127.0.0.1:1433/nextauth`, and do not forget to set the `type` value to `mssql`.
-
-Schema: [mssql/schema.sql](https://github.com/nextauthjs/adapters/tree/canary/packages/typeorm-legacy/tests/mssql/schema.sql)
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/typeorm).
\ No newline at end of file
diff --git a/packages/adapter-upstash-redis/CHANGELOG.md b/packages/adapter-upstash-redis/CHANGELOG.md
deleted file mode 100644
index 8f36f71c..00000000
--- a/packages/adapter-upstash-redis/CHANGELOG.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-# 1.1.0 (2022-01-17)
-
-### Bug Fixes
-
-- **upstash-redis:** expose environment variables in workflow ([#373](https://github.com/nextauthjs/adapters/issues/373)) ([fcee362](https://github.com/nextauthjs/adapters/commit/fcee36227fec4e42e818f104b06a3030838790da))
-- **upstash-redis:** fix deployment ([c2df2c8](https://github.com/nextauthjs/adapters/commit/c2df2c86b53f4e42a2bc1051256701ec7cc08fbd))
-
-### Features
-
-- **upstash-redis:** add upstash-redis adapter ([#341](https://github.com/nextauthjs/adapters/issues/341)) ([f4a8464](https://github.com/nextauthjs/adapters/commit/f4a84644296f545c1dac16519337a6dc7718c88c))
diff --git a/packages/adapter-upstash-redis/README.md b/packages/adapter-upstash-redis/README.md
index 4ead3a9c..39e565f8 100644
--- a/packages/adapter-upstash-redis/README.md
+++ b/packages/adapter-upstash-redis/README.md
@@ -1,87 +1,28 @@
-## Overview
+---
-This is the Upstash Redis adapter for [`next-auth`](https://authjs.dev). This package can only be used in conjunction with the primary `next-auth` and `@upstash/redis` packages. It is not a standalone package.
-
-## Getting Started
-
-1. Install `next-auth` and `@next-auth/upstash-redis-adapter` as well as `@upstash/redis` via NPM.
-
-```js
-npm install next-auth @next-auth/upstash-redis-adapter @upstash/redis
-```
-
-2. Add the following code to your `pages/api/[...nextauth].js` next-auth configuration object.
-
-```js
-import NextAuth from "next-auth"
-import { UpstashRedisAdapter } from "@next-auth/upstash-adapter"
-import { Redis } from "@upstash/redis"
-
-const redis = new Redis({
- url:"UPSTASH_REDIS_REST_URL",
- token:"UPSTASH_REDIS_REST_TOKEN",
-})
-
-// For more information on each option (and a full list of options) go to
-// https://authjs.dev/reference/configuration/auth-options
-export default NextAuth({
- ...
- adapter: UpstashRedisAdapter(redis)
- ...
-})
-```
-
-## Using Multiple Apps with a Single Upstash Redis Instance
-
-The Upstash free-tier allows for only one Redis instance. If you have multiple Next-Auth connected apps using this instance, you need different key prefixes for every app.
-
-You can change the prefixes by passing an `options` object as the second argument to the adapter factory function.
-
-The default values for this object are:
-
-```js
-const defaultOptions = {
- baseKeyPrefix: "",
- accountKeyPrefix: "user:account:",
- accountByUserIdPrefix: "user:account:by-user-id:",
- emailKeyPrefix: "user:email:",
- sessionKeyPrefix: "user:session:",
- sessionByUserIdKeyPrefix: "user:session:by-user-id:",
- userKeyPrefix: "user:",
- verificationTokenKeyPrefix: "user:token:",
-}
-```
-
-Usually changing the `baseKeyPrefix` should be enough for this scenario, but for more custom setups, you can also change the prefixes of every single key.
-
-Example:
-
-```js
-export default NextAuth({
- ...
- adapter: UpstashRedisAdapter(redis, {baseKeyPrefix: "app2:"})
- ...
-})
-```
-
-## Contributing
-
-We're open to all community contributions! If you'd like to contribute in any way, please read our [Contributing Guide](https://github.com/nextauthjs/.github/blob/main/CONTRIBUTING.md).
-
-## License
-
-ISC
+Check out the documentation at [authjs.dev](https://authjs.dev/reference/adapter/upstash-redis).
\ No newline at end of file
diff --git a/packages/adapter-xata/README.md b/packages/adapter-xata/README.md
index 02c0cd00..a1898165 100644
--- a/packages/adapter-xata/README.md
+++ b/packages/adapter-xata/README.md
@@ -1,248 +1,28 @@
*
From 81589bf738f5bb18da066481f8176f9927951b1a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?=
Date: Tue, 21 Mar 2023 00:49:39 +0100
Subject: [PATCH 45/80] docs: remove/rename files/directories
---
...-tutorial.mdx => credentials-tutorial.mdx} | 0
.../{06-databases.md => databases.md} | 0
...-email-tutorial.mdx => email-tutorial.mdx} | 0
.../{01-introduction.md => introduction.md} | 0
...-oauth-tutorial.mdx => oauth-tutorial.mdx} | 0
.../{07-security.md => security.md} | 0
.../{05-typescript.md => typescript.md} | 0
.../{08-upgrade-to-v4.md => upgrade-to-v4.md} | 0
.../guides/04-providers/00-custom-provider.md | 136 ------
.../{05-adapters => adapters}/_category_.json | 0
.../creating-a-database-adapter.md | 0
.../using-a-database-adapter.md | 0
.../{03-basics => basics}/_category_.json | 0
.../guides/{03-basics => basics}/callbacks.md | 0
.../{03-basics => basics}/deployment.md | 0
.../guides/{03-basics => basics}/events.md | 0
.../{03-basics => basics}/initialization.md | 0
.../{03-basics => basics}/overriding-jwt.md | 0
.../guides/{03-basics => basics}/pages.md | 0
.../refresh-token-rotation.md | 0
.../role-based-access-control.md | 0
.../securing-pages-and-api-routes.md | 0
.../_category_.json | 0
...-corporate-link-checking-email-provider.md | 0
.../corporate-proxy.md | 0
.../{08-other => other}/_category_.json | 0
.../guides/{08-other => other}/ldap-auth.md | 0
.../usage-with-class-components.md | 0
.../_category_.json | 0
.../credentials-provider.md} | 0
docs/docs/guides/providers/custom-provider.md | 112 +++++
.../email-http-api.md} | 0
.../email-provider.md} | 0
.../guides/{09-resources.md => resources.md} | 0
.../{06-testing => testing}/_category_.json | 0
.../testing-with-cypress.md | 0
.../02-configuration/01-auth-config.md | 447 ------------------
.../docs/reference/02-configuration/04-env.md | 38 --
.../02-configuration/_category_.json | 5 -
.../04-providers/02-oauth-builtin.mdx | 23 -
docs/docs/reference/04-providers/02-oauth.mdx | 193 --------
docs/docs/reference/04-providers/04-email.md | 19 -
.../reference/04-providers/05-credentials.md | 17 -
.../reference/04-providers/_category_.json | 5 -
docs/docs/reference/04-providers/index.md | 16 -
docs/docs/reference/05-oauth-providers/42.md | 38 --
.../05-oauth-providers/_category_.json | 5 -
.../reference/05-oauth-providers/apple.md | 137 ------
.../reference/05-oauth-providers/atlassian.md | 52 --
.../reference/05-oauth-providers/auth0.md | 39 --
.../reference/05-oauth-providers/authentik.md | 35 --
.../05-oauth-providers/azure-ad-b2c.md | 117 -----
.../reference/05-oauth-providers/azure-ad.md | 59 ---
.../reference/05-oauth-providers/battlenet.md | 46 --
docs/docs/reference/05-oauth-providers/box.md | 34 --
.../05-oauth-providers/boxyhq-saml.md | 58 ---
.../reference/05-oauth-providers/bungie.md | 137 ------
.../reference/05-oauth-providers/cognito.md | 49 --
.../reference/05-oauth-providers/coinbase.md | 38 --
.../reference/05-oauth-providers/discord.md | 34 --
.../reference/05-oauth-providers/dropbox.md | 34 --
.../reference/05-oauth-providers/eveonline.md | 51 --
.../reference/05-oauth-providers/facebook.md | 42 --
.../reference/05-oauth-providers/faceit.md | 38 --
.../05-oauth-providers/foursquare.md | 39 --
.../05-oauth-providers/freshbooks.md | 34 --
.../05-oauth-providers/fusionauth.md | 59 ---
.../reference/05-oauth-providers/github.md | 46 --
.../reference/05-oauth-providers/gitlab.md | 38 --
.../reference/05-oauth-providers/google.md | 93 ----
.../05-oauth-providers/identity-server4.md | 61 ---
.../reference/05-oauth-providers/instagram.md | 50 --
.../reference/05-oauth-providers/kakao.md | 40 --
.../reference/05-oauth-providers/keycloak.md | 41 --
.../docs/reference/05-oauth-providers/line.md | 47 --
.../reference/05-oauth-providers/linkedin.md | 38 --
.../reference/05-oauth-providers/mailchimp.md | 34 --
.../reference/05-oauth-providers/mailru.md | 34 --
.../05-oauth-providers/mattermost.md | 36 --
.../reference/05-oauth-providers/medium.md | 38 --
.../reference/05-oauth-providers/naver.md | 34 --
.../reference/05-oauth-providers/netlify.md | 34 --
.../docs/reference/05-oauth-providers/okta.md | 31 --
.../reference/05-oauth-providers/onelogin.md | 35 --
.../docs/reference/05-oauth-providers/osso.md | 47 --
docs/docs/reference/05-oauth-providers/osu.md | 38 --
.../reference/05-oauth-providers/patreon.md | 40 --
.../reference/05-oauth-providers/pipedrive.md | 30 --
.../reference/05-oauth-providers/reddit.md | 73 ---
.../05-oauth-providers/salesforce.md | 30 --
.../reference/05-oauth-providers/slack.md | 41 --
.../reference/05-oauth-providers/spotify.md | 34 --
.../reference/05-oauth-providers/strava.md | 30 --
.../reference/05-oauth-providers/todoist.md | 35 --
.../reference/05-oauth-providers/trakt.md | 41 --
.../reference/05-oauth-providers/twitch.md | 36 --
.../reference/05-oauth-providers/twitter.md | 62 ---
.../05-oauth-providers/united-effects.md | 43 --
docs/docs/reference/05-oauth-providers/vk.md | 57 ---
.../reference/05-oauth-providers/wordpress.md | 38 --
.../reference/05-oauth-providers/workos.md | 103 ----
.../reference/05-oauth-providers/yandex.md | 34 --
.../docs/reference/05-oauth-providers/zoho.md | 34 --
.../docs/reference/05-oauth-providers/zoom.md | 34 --
docs/docs/reference/08-rest-api.md | 73 ---
.../reference/{04-nextjs => nextjs}/client.md | 0
.../reference/{04-nextjs => nextjs}/index.md | 0
.../{04-solidstart => solidstart}/client.md | 0
.../{04-solidstart => solidstart}/index.md | 0
.../protected.md | 0
.../reference/{09-warnings.md => warnings.md} | 0
docs/scripts/generate-providers.mjs | 18 +-
112 files changed, 124 insertions(+), 3763 deletions(-)
rename docs/docs/getting-started/{04-credentials-tutorial.mdx => credentials-tutorial.mdx} (100%)
rename docs/docs/getting-started/{06-databases.md => databases.md} (100%)
rename docs/docs/getting-started/{03-email-tutorial.mdx => email-tutorial.mdx} (100%)
rename docs/docs/getting-started/{01-introduction.md => introduction.md} (100%)
rename docs/docs/getting-started/{02-oauth-tutorial.mdx => oauth-tutorial.mdx} (100%)
rename docs/docs/getting-started/{07-security.md => security.md} (100%)
rename docs/docs/getting-started/{05-typescript.md => typescript.md} (100%)
rename docs/docs/getting-started/{08-upgrade-to-v4.md => upgrade-to-v4.md} (100%)
delete mode 100644 docs/docs/guides/04-providers/00-custom-provider.md
rename docs/docs/guides/{05-adapters => adapters}/_category_.json (100%)
rename docs/docs/guides/{05-adapters => adapters}/creating-a-database-adapter.md (100%)
rename docs/docs/guides/{05-adapters => adapters}/using-a-database-adapter.md (100%)
rename docs/docs/guides/{03-basics => basics}/_category_.json (100%)
rename docs/docs/guides/{03-basics => basics}/callbacks.md (100%)
rename docs/docs/guides/{03-basics => basics}/deployment.md (100%)
rename docs/docs/guides/{03-basics => basics}/events.md (100%)
rename docs/docs/guides/{03-basics => basics}/initialization.md (100%)
rename docs/docs/guides/{03-basics => basics}/overriding-jwt.md (100%)
rename docs/docs/guides/{03-basics => basics}/pages.md (100%)
rename docs/docs/guides/{03-basics => basics}/refresh-token-rotation.md (100%)
rename docs/docs/guides/{03-basics => basics}/role-based-access-control.md (100%)
rename docs/docs/guides/{03-basics => basics}/securing-pages-and-api-routes.md (100%)
rename docs/docs/guides/{07-corporate-proxies => corporate-proxies}/_category_.json (100%)
rename docs/docs/guides/{07-corporate-proxies => corporate-proxies}/avoid-corporate-link-checking-email-provider.md (100%)
rename docs/docs/guides/{07-corporate-proxies => corporate-proxies}/corporate-proxy.md (100%)
rename docs/docs/guides/{08-other => other}/_category_.json (100%)
rename docs/docs/guides/{08-other => other}/ldap-auth.md (100%)
rename docs/docs/guides/{08-other => other}/usage-with-class-components.md (100%)
rename docs/docs/guides/{04-providers => providers}/_category_.json (100%)
rename docs/docs/guides/{04-providers/01-credentials-provider.md => providers/credentials-provider.md} (100%)
create mode 100644 docs/docs/guides/providers/custom-provider.md
rename docs/docs/guides/{04-providers/03-email-http-api.md => providers/email-http-api.md} (100%)
rename docs/docs/guides/{04-providers/02-email-provider.md => providers/email-provider.md} (100%)
rename docs/docs/guides/{09-resources.md => resources.md} (100%)
rename docs/docs/guides/{06-testing => testing}/_category_.json (100%)
rename docs/docs/guides/{06-testing => testing}/testing-with-cypress.md (100%)
delete mode 100644 docs/docs/reference/02-configuration/01-auth-config.md
delete mode 100644 docs/docs/reference/02-configuration/04-env.md
delete mode 100644 docs/docs/reference/02-configuration/_category_.json
delete mode 100644 docs/docs/reference/04-providers/02-oauth-builtin.mdx
delete mode 100644 docs/docs/reference/04-providers/02-oauth.mdx
delete mode 100644 docs/docs/reference/04-providers/04-email.md
delete mode 100644 docs/docs/reference/04-providers/05-credentials.md
delete mode 100644 docs/docs/reference/04-providers/_category_.json
delete mode 100644 docs/docs/reference/04-providers/index.md
delete mode 100644 docs/docs/reference/05-oauth-providers/42.md
delete mode 100644 docs/docs/reference/05-oauth-providers/_category_.json
delete mode 100644 docs/docs/reference/05-oauth-providers/apple.md
delete mode 100644 docs/docs/reference/05-oauth-providers/atlassian.md
delete mode 100644 docs/docs/reference/05-oauth-providers/auth0.md
delete mode 100644 docs/docs/reference/05-oauth-providers/authentik.md
delete mode 100644 docs/docs/reference/05-oauth-providers/azure-ad-b2c.md
delete mode 100644 docs/docs/reference/05-oauth-providers/azure-ad.md
delete mode 100644 docs/docs/reference/05-oauth-providers/battlenet.md
delete mode 100644 docs/docs/reference/05-oauth-providers/box.md
delete mode 100644 docs/docs/reference/05-oauth-providers/boxyhq-saml.md
delete mode 100644 docs/docs/reference/05-oauth-providers/bungie.md
delete mode 100644 docs/docs/reference/05-oauth-providers/cognito.md
delete mode 100644 docs/docs/reference/05-oauth-providers/coinbase.md
delete mode 100644 docs/docs/reference/05-oauth-providers/discord.md
delete mode 100644 docs/docs/reference/05-oauth-providers/dropbox.md
delete mode 100644 docs/docs/reference/05-oauth-providers/eveonline.md
delete mode 100644 docs/docs/reference/05-oauth-providers/facebook.md
delete mode 100644 docs/docs/reference/05-oauth-providers/faceit.md
delete mode 100644 docs/docs/reference/05-oauth-providers/foursquare.md
delete mode 100644 docs/docs/reference/05-oauth-providers/freshbooks.md
delete mode 100644 docs/docs/reference/05-oauth-providers/fusionauth.md
delete mode 100644 docs/docs/reference/05-oauth-providers/github.md
delete mode 100644 docs/docs/reference/05-oauth-providers/gitlab.md
delete mode 100644 docs/docs/reference/05-oauth-providers/google.md
delete mode 100644 docs/docs/reference/05-oauth-providers/identity-server4.md
delete mode 100644 docs/docs/reference/05-oauth-providers/instagram.md
delete mode 100644 docs/docs/reference/05-oauth-providers/kakao.md
delete mode 100644 docs/docs/reference/05-oauth-providers/keycloak.md
delete mode 100644 docs/docs/reference/05-oauth-providers/line.md
delete mode 100644 docs/docs/reference/05-oauth-providers/linkedin.md
delete mode 100644 docs/docs/reference/05-oauth-providers/mailchimp.md
delete mode 100644 docs/docs/reference/05-oauth-providers/mailru.md
delete mode 100644 docs/docs/reference/05-oauth-providers/mattermost.md
delete mode 100644 docs/docs/reference/05-oauth-providers/medium.md
delete mode 100644 docs/docs/reference/05-oauth-providers/naver.md
delete mode 100644 docs/docs/reference/05-oauth-providers/netlify.md
delete mode 100644 docs/docs/reference/05-oauth-providers/okta.md
delete mode 100644 docs/docs/reference/05-oauth-providers/onelogin.md
delete mode 100644 docs/docs/reference/05-oauth-providers/osso.md
delete mode 100644 docs/docs/reference/05-oauth-providers/osu.md
delete mode 100644 docs/docs/reference/05-oauth-providers/patreon.md
delete mode 100644 docs/docs/reference/05-oauth-providers/pipedrive.md
delete mode 100644 docs/docs/reference/05-oauth-providers/reddit.md
delete mode 100644 docs/docs/reference/05-oauth-providers/salesforce.md
delete mode 100644 docs/docs/reference/05-oauth-providers/slack.md
delete mode 100644 docs/docs/reference/05-oauth-providers/spotify.md
delete mode 100644 docs/docs/reference/05-oauth-providers/strava.md
delete mode 100644 docs/docs/reference/05-oauth-providers/todoist.md
delete mode 100644 docs/docs/reference/05-oauth-providers/trakt.md
delete mode 100644 docs/docs/reference/05-oauth-providers/twitch.md
delete mode 100644 docs/docs/reference/05-oauth-providers/twitter.md
delete mode 100644 docs/docs/reference/05-oauth-providers/united-effects.md
delete mode 100644 docs/docs/reference/05-oauth-providers/vk.md
delete mode 100644 docs/docs/reference/05-oauth-providers/wordpress.md
delete mode 100644 docs/docs/reference/05-oauth-providers/workos.md
delete mode 100644 docs/docs/reference/05-oauth-providers/yandex.md
delete mode 100644 docs/docs/reference/05-oauth-providers/zoho.md
delete mode 100644 docs/docs/reference/05-oauth-providers/zoom.md
delete mode 100644 docs/docs/reference/08-rest-api.md
rename docs/docs/reference/{04-nextjs => nextjs}/client.md (100%)
rename docs/docs/reference/{04-nextjs => nextjs}/index.md (100%)
rename docs/docs/reference/{04-solidstart => solidstart}/client.md (100%)
rename docs/docs/reference/{04-solidstart => solidstart}/index.md (100%)
rename docs/docs/reference/{04-solidstart => solidstart}/protected.md (100%)
rename docs/docs/reference/{09-warnings.md => warnings.md} (100%)
diff --git a/docs/docs/getting-started/04-credentials-tutorial.mdx b/docs/docs/getting-started/credentials-tutorial.mdx
similarity index 100%
rename from docs/docs/getting-started/04-credentials-tutorial.mdx
rename to docs/docs/getting-started/credentials-tutorial.mdx
diff --git a/docs/docs/getting-started/06-databases.md b/docs/docs/getting-started/databases.md
similarity index 100%
rename from docs/docs/getting-started/06-databases.md
rename to docs/docs/getting-started/databases.md
diff --git a/docs/docs/getting-started/03-email-tutorial.mdx b/docs/docs/getting-started/email-tutorial.mdx
similarity index 100%
rename from docs/docs/getting-started/03-email-tutorial.mdx
rename to docs/docs/getting-started/email-tutorial.mdx
diff --git a/docs/docs/getting-started/01-introduction.md b/docs/docs/getting-started/introduction.md
similarity index 100%
rename from docs/docs/getting-started/01-introduction.md
rename to docs/docs/getting-started/introduction.md
diff --git a/docs/docs/getting-started/02-oauth-tutorial.mdx b/docs/docs/getting-started/oauth-tutorial.mdx
similarity index 100%
rename from docs/docs/getting-started/02-oauth-tutorial.mdx
rename to docs/docs/getting-started/oauth-tutorial.mdx
diff --git a/docs/docs/getting-started/07-security.md b/docs/docs/getting-started/security.md
similarity index 100%
rename from docs/docs/getting-started/07-security.md
rename to docs/docs/getting-started/security.md
diff --git a/docs/docs/getting-started/05-typescript.md b/docs/docs/getting-started/typescript.md
similarity index 100%
rename from docs/docs/getting-started/05-typescript.md
rename to docs/docs/getting-started/typescript.md
diff --git a/docs/docs/getting-started/08-upgrade-to-v4.md b/docs/docs/getting-started/upgrade-to-v4.md
similarity index 100%
rename from docs/docs/getting-started/08-upgrade-to-v4.md
rename to docs/docs/getting-started/upgrade-to-v4.md
diff --git a/docs/docs/guides/04-providers/00-custom-provider.md b/docs/docs/guides/04-providers/00-custom-provider.md
deleted file mode 100644
index b539f37b..00000000
--- a/docs/docs/guides/04-providers/00-custom-provider.md
+++ /dev/null
@@ -1,136 +0,0 @@
----
-title: Using a custom Provider
-sidebar_label: Creating a Provider
----
-
-You can use an OAuth provider that isn't built-in by using a custom object.
-
-As an example of what this looks like, this is the provider object returned for the Google provider:
-
-```js
-{
- id: "google",
- name: "Google",
- type: "oauth",
- wellKnown: "https://accounts.google.com/.well-known/openid-configuration",
- authorization: { params: { scope: "openid email profile" } },
- idToken: true,
- checks: ["pkce", "state"],
- profile(profile) {
- return {
- id: profile.sub,
- name: profile.name,
- email: profile.email,
- image: profile.picture,
- }
- },
-}
-```
-
-As you can see, if your provider supports OpenID Connect and the `/.well-known/openid-configuration` endpoint contains support for the `grant_type`: `authorization_code`, you only need to pass the URL to that configuration file and define some basic fields like `name` and `type`.
-
-Otherwise, you can pass a more full set of URLs for each OAuth2.0 flow step, for example:
-
-```js
-{
- id: "kakao",
- name: "Kakao",
- type: "oauth",
- authorization: "https://kauth.kakao.com/oauth/authorize",
- token: "https://kauth.kakao.com/oauth/token",
- userinfo: "https://kapi.kakao.com/v2/user/me",
- profile(profile) {
- return {
- id: profile.id,
- name: profile.kakao_account?.profile.nickname,
- email: profile.kakao_account?.email,
- image: profile.kakao_account?.profile.profile_image_url,
- }
- },
-}
-```
-
-Replace all the options in this JSON object with the ones from your custom provider - be sure to give it a unique ID and specify the required URLs, and finally add it to the providers array when initializing the library:
-
-```js title="pages/api/auth/[...nextauth].js"
-import TwitterProvider from "next-auth/providers/twitter"
-...
-providers: [
- TwitterProvider({
- clientId: process.env.TWITTER_ID,
- clientSecret: process.env.TWITTER_SECRET,
- }),
- {
- id: 'customProvider',
- name: 'CustomProvider',
- type: 'oauth',
- scope: '' // Make sure to request the users email address
- ...
- }
-]
-...
-```
-
-### Override default options
-
-For built-in providers, in most cases you will only need to specify the `clientId` and `clientSecret`. If you need to override any of the defaults, add your own [options](#options).
-
-Even if you are using a built-in provider, you can override any of these options to tweak the default configuration.
-
-:::note
-The user provided options are deeply merged with the default options. That means you only have to override part of the options that you need to be different. For example if you want different scopes, overriding `authorization.params.scope` is enough, instead of the whole `authorization` option.
-:::
-
-```js title=/api/auth/[...nextauth].js
-import Auth0Provider from "next-auth/providers/auth0"
-
-Auth0Provider({
- clientId: process.env.CLIENT_ID,
- clientSecret: process.env.CLIENT_SECRET,
- issuer: process.env.ISSUER,
- authorization: { params: { scope: "openid your_custom_scope" } },
-})
-```
-
-Another example, the `profile` callback will return `id`, `name`, `email` and `picture` by default, but you might need more information from the provider. After setting the correct scopes, you can then do something like this:
-
-```js title=/api/auth/[...nextauth].js
-import GoogleProvider from "next-auth/providers/google"
-
-GoogleProvider({
- clientId: process.env.GOOGLE_CLIENT_ID,
- clientSecret: process.env.GOOGLE_CLIENT_SECRET,
- profile(profile) {
- return {
- // Return all the profile information you need.
- // The only truly required field is `id`
- // to be able identify the account when added to a database
- }
- },
-})
-```
-
-An example of how to enable automatic account linking:
-
-```js title=/api/auth/[...nextauth].js
-import GoogleProvider from "next-auth/providers/google"
-GoogleProvider({
- clientId: process.env.GOOGLE_CLIENT_ID,
- clientSecret: process.env.GOOGLE_CLIENT_SECRET,
- allowDangerousEmailAccountLinking: true,
-})
-```
-
-### Adding a new built-in provider
-
-If you think your custom provider might be useful to others, we encourage you to open a PR and add it to the built-in list so others can discover it much more easily!
-
-You only need to add three changes:
-
-1. Add your config: [`src/providers/{provider}.ts`](https://github.com/nextauthjs/next-auth/tree/main/packages/next-auth/src/providers)
- - Make sure you use a named default export, like this: `export default function YourProvider`
- - Add two SVG's of the provider logo, like `google-dark.svg` (dark mode) and `google.svg` (light mode), to the `/packages/next-auth/provider-logos/` directory as well as the styling config to the provider config object. See existing provider for example
-2. Add provider documentation: [`docs/docs/reference/05-oauth-providers/{provider}.md`](https://github.com/nextauthjs/next-auth/tree/main/docs/docs/reference/05-oauth-providers)
-3. Add the new provider name to the `Provider type` dropdown options in [`the provider issue template`](https://github.com/nextauthjs/next-auth/edit/main/.github/ISSUE_TEMPLATE/2_bug_provider.yml)
-
-That's it! 🎉 Others will be able to discover and use this provider much more easily now!
diff --git a/docs/docs/guides/05-adapters/_category_.json b/docs/docs/guides/adapters/_category_.json
similarity index 100%
rename from docs/docs/guides/05-adapters/_category_.json
rename to docs/docs/guides/adapters/_category_.json
diff --git a/docs/docs/guides/05-adapters/creating-a-database-adapter.md b/docs/docs/guides/adapters/creating-a-database-adapter.md
similarity index 100%
rename from docs/docs/guides/05-adapters/creating-a-database-adapter.md
rename to docs/docs/guides/adapters/creating-a-database-adapter.md
diff --git a/docs/docs/guides/05-adapters/using-a-database-adapter.md b/docs/docs/guides/adapters/using-a-database-adapter.md
similarity index 100%
rename from docs/docs/guides/05-adapters/using-a-database-adapter.md
rename to docs/docs/guides/adapters/using-a-database-adapter.md
diff --git a/docs/docs/guides/03-basics/_category_.json b/docs/docs/guides/basics/_category_.json
similarity index 100%
rename from docs/docs/guides/03-basics/_category_.json
rename to docs/docs/guides/basics/_category_.json
diff --git a/docs/docs/guides/03-basics/callbacks.md b/docs/docs/guides/basics/callbacks.md
similarity index 100%
rename from docs/docs/guides/03-basics/callbacks.md
rename to docs/docs/guides/basics/callbacks.md
diff --git a/docs/docs/guides/03-basics/deployment.md b/docs/docs/guides/basics/deployment.md
similarity index 100%
rename from docs/docs/guides/03-basics/deployment.md
rename to docs/docs/guides/basics/deployment.md
diff --git a/docs/docs/guides/03-basics/events.md b/docs/docs/guides/basics/events.md
similarity index 100%
rename from docs/docs/guides/03-basics/events.md
rename to docs/docs/guides/basics/events.md
diff --git a/docs/docs/guides/03-basics/initialization.md b/docs/docs/guides/basics/initialization.md
similarity index 100%
rename from docs/docs/guides/03-basics/initialization.md
rename to docs/docs/guides/basics/initialization.md
diff --git a/docs/docs/guides/03-basics/overriding-jwt.md b/docs/docs/guides/basics/overriding-jwt.md
similarity index 100%
rename from docs/docs/guides/03-basics/overriding-jwt.md
rename to docs/docs/guides/basics/overriding-jwt.md
diff --git a/docs/docs/guides/03-basics/pages.md b/docs/docs/guides/basics/pages.md
similarity index 100%
rename from docs/docs/guides/03-basics/pages.md
rename to docs/docs/guides/basics/pages.md
diff --git a/docs/docs/guides/03-basics/refresh-token-rotation.md b/docs/docs/guides/basics/refresh-token-rotation.md
similarity index 100%
rename from docs/docs/guides/03-basics/refresh-token-rotation.md
rename to docs/docs/guides/basics/refresh-token-rotation.md
diff --git a/docs/docs/guides/03-basics/role-based-access-control.md b/docs/docs/guides/basics/role-based-access-control.md
similarity index 100%
rename from docs/docs/guides/03-basics/role-based-access-control.md
rename to docs/docs/guides/basics/role-based-access-control.md
diff --git a/docs/docs/guides/03-basics/securing-pages-and-api-routes.md b/docs/docs/guides/basics/securing-pages-and-api-routes.md
similarity index 100%
rename from docs/docs/guides/03-basics/securing-pages-and-api-routes.md
rename to docs/docs/guides/basics/securing-pages-and-api-routes.md
diff --git a/docs/docs/guides/07-corporate-proxies/_category_.json b/docs/docs/guides/corporate-proxies/_category_.json
similarity index 100%
rename from docs/docs/guides/07-corporate-proxies/_category_.json
rename to docs/docs/guides/corporate-proxies/_category_.json
diff --git a/docs/docs/guides/07-corporate-proxies/avoid-corporate-link-checking-email-provider.md b/docs/docs/guides/corporate-proxies/avoid-corporate-link-checking-email-provider.md
similarity index 100%
rename from docs/docs/guides/07-corporate-proxies/avoid-corporate-link-checking-email-provider.md
rename to docs/docs/guides/corporate-proxies/avoid-corporate-link-checking-email-provider.md
diff --git a/docs/docs/guides/07-corporate-proxies/corporate-proxy.md b/docs/docs/guides/corporate-proxies/corporate-proxy.md
similarity index 100%
rename from docs/docs/guides/07-corporate-proxies/corporate-proxy.md
rename to docs/docs/guides/corporate-proxies/corporate-proxy.md
diff --git a/docs/docs/guides/08-other/_category_.json b/docs/docs/guides/other/_category_.json
similarity index 100%
rename from docs/docs/guides/08-other/_category_.json
rename to docs/docs/guides/other/_category_.json
diff --git a/docs/docs/guides/08-other/ldap-auth.md b/docs/docs/guides/other/ldap-auth.md
similarity index 100%
rename from docs/docs/guides/08-other/ldap-auth.md
rename to docs/docs/guides/other/ldap-auth.md
diff --git a/docs/docs/guides/08-other/usage-with-class-components.md b/docs/docs/guides/other/usage-with-class-components.md
similarity index 100%
rename from docs/docs/guides/08-other/usage-with-class-components.md
rename to docs/docs/guides/other/usage-with-class-components.md
diff --git a/docs/docs/guides/04-providers/_category_.json b/docs/docs/guides/providers/_category_.json
similarity index 100%
rename from docs/docs/guides/04-providers/_category_.json
rename to docs/docs/guides/providers/_category_.json
diff --git a/docs/docs/guides/04-providers/01-credentials-provider.md b/docs/docs/guides/providers/credentials-provider.md
similarity index 100%
rename from docs/docs/guides/04-providers/01-credentials-provider.md
rename to docs/docs/guides/providers/credentials-provider.md
diff --git a/docs/docs/guides/providers/custom-provider.md b/docs/docs/guides/providers/custom-provider.md
new file mode 100644
index 00000000..a2a3bbd4
--- /dev/null
+++ b/docs/docs/guides/providers/custom-provider.md
@@ -0,0 +1,112 @@
+---
+title: Customized OAuth Provider
+---
+
+Auth.js comes with a set of built-in OAuth providers that you can import from `@auth/core/providers/*`. Every provider has their separate documentation page under the [core package's API Reference](/reference/core)
+
+
+## Use your own provider
+
+However, you can use _any_ provider as long as they are compliant with the OAuth/OIDC specifications.
+
+Auth.js uses the [`oauth4webapi`](https://github.com/panva/oauth4webapi/blob/main/docs/README.md) package under the hood.
+
+To use a custom OAuth provider with Auth.js, pass an object to the [`providers` list](/reference/core#providers).
+
+It can implement either the [`OAuth2Config`](/reference/core/providers#oauth2configprofile) or the [`OIDCConfig`](/reference/core/providers#oidcconfigprofile) interface, depending on if your provider is OAuth 2 or OpenID Connect compliant.
+
+For example, if you have a fully OIDC-compliant provider, this is all you need:
+
+```ts
+import type { OIDCConfig } from "@auth/core/providers"
+
+...
+providers: [
+ {
+ id: "my-oidc-provider",
+ name: "My Provider",
+ type: "oidc",
+ issuer: "https://my.oidc-provider.com",
+ clientId: process.env.CLIENT_ID,
+ clientSecret: process.env.CLIENT_SECRET
+ } satisfies OIDCConfig
+]
+...
+```
+
+Then, you can set the [Redirect URI](https://www.ietf.org/archive/id/draft-ietf-oauth-v2-1-07.html#name-client-redirection-endpoint) in your provider's dashboard to something like `https://app-url.com/{path-to-auth-handler}/callback/my-oidc-provider`.
+
+`{path-to-auth-handler}` is _usually_ `auth` or `api/auth`, depending on your framework of your choice.
+`my-oidc-provider` matches the `id` you set in the [`providers` list](/reference/core#providers).
+
+
+## Override default provider config
+
+For built-in providers, in most cases you will only need to specify the `clientId` and `clientSecret`, and in case of OIDC providers, the `issuer` property. If you need to override any of the defaults, you can add them in the provider's function call and they will be deep-merged with the default configuration options.
+
+:::note
+The user provided options are deeply merged with the default options. That means you only have to override part of the options that you need to be different. For example if you want different scopes, overriding `authorization.params.scope` is enough, instead of the whole `authorization` option.
+:::
+
+
+For example, to override a provider's default scopes, you can do the following:
+
+```ts
+import Auth0Provider from "@auth/core/providers/auth0"
+
+Auth0Provider({
+ clientId: process.env.CLIENT_ID,
+ clientSecret: process.env.CLIENT_SECRET,
+ issuer: process.env.ISSUER,
+ authorization: { params: { scope: "openid your_custom_scope" } },
+})
+```
+
+Another example, the `profile` callback will return `id`, `name`, `email` and `picture` by default, but you might want to return more information from the provider. After setting the correct scopes, you can then do something like this:
+
+```ts
+import GoogleProvider from "@auth/core/providers/google"
+
+GoogleProvider({
+ clientId: process.env.GOOGLE_CLIENT_ID,
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET,
+ profile(profile) {
+ return {
+ // Return all the profile information you need.
+ // The only truly required field is `id`
+ // to be able identify the account when added to a database
+ }
+ },
+})
+```
+
+An example of how to enable automatic account linking:
+
+```ts
+import GoogleProvider from "@auth/core/providers/google"
+
+GoogleProvider({
+ clientId: process.env.GOOGLE_CLIENT_ID,
+ clientSecret: process.env.GOOGLE_CLIENT_SECRET,
+ allowDangerousEmailAccountLinking: true,
+})
+```
+
+### Adding a new built-in provider
+
+If you think your custom provider might be useful to others, we encourage you to open a PR and add it to the built-in list.
+
+:::note
+We are only accepting new providers to `@auth/core`, and not `next-auth`. Follow the steps below to make sure your PR is merged!
+:::
+
+1. Create a new `{provider}.ts` (for it to get merged, you must use TypeScript) file under the [`packages/core/src/providers`](https://github.com/nextauthjs/next-auth/tree/main/packages/core/src/providers) directory.
+2. Make sure that you are following other providers, ie.:
+ - Use a named default export: `export default function YourProvider`
+ - Export the TypeScript `interface` that defines the provider's available user info properties
+ - Add the necessary JSDoc comments/documentation (Study the built-in providers to get an understanding what's needed. For example, the [Auth0 provider](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/auth0.ts) is a good example for OIDC and the [GitHub Provider](https://github.com/nextauthjs/next-auth/blob/main/packages/core/src/providers/github.ts) is an OAuth provider.)
+ - Add links to the provider's API reference/documentation so others can understand how to use the provider
+3. Add the new provider name to the `Provider type` dropdown options in [`the provider issue template`](https://github.com/nextauthjs/next-auth/edit/main/.github/ISSUE_TEMPLATE/2_bug_provider.yml)
+4. (Optional): Add a logo `{provider}.svg` to the [`docs/static/img/providers`](https://github.com/nextauthjs/next-auth/tree/main/docs/static/img/providers) directory.
+
+That's it! 🎉 Others will be able to discover and use this provider!
\ No newline at end of file
diff --git a/docs/docs/guides/04-providers/03-email-http-api.md b/docs/docs/guides/providers/email-http-api.md
similarity index 100%
rename from docs/docs/guides/04-providers/03-email-http-api.md
rename to docs/docs/guides/providers/email-http-api.md
diff --git a/docs/docs/guides/04-providers/02-email-provider.md b/docs/docs/guides/providers/email-provider.md
similarity index 100%
rename from docs/docs/guides/04-providers/02-email-provider.md
rename to docs/docs/guides/providers/email-provider.md
diff --git a/docs/docs/guides/09-resources.md b/docs/docs/guides/resources.md
similarity index 100%
rename from docs/docs/guides/09-resources.md
rename to docs/docs/guides/resources.md
diff --git a/docs/docs/guides/06-testing/_category_.json b/docs/docs/guides/testing/_category_.json
similarity index 100%
rename from docs/docs/guides/06-testing/_category_.json
rename to docs/docs/guides/testing/_category_.json
diff --git a/docs/docs/guides/06-testing/testing-with-cypress.md b/docs/docs/guides/testing/testing-with-cypress.md
similarity index 100%
rename from docs/docs/guides/06-testing/testing-with-cypress.md
rename to docs/docs/guides/testing/testing-with-cypress.md
diff --git a/docs/docs/reference/02-configuration/01-auth-config.md b/docs/docs/reference/02-configuration/01-auth-config.md
deleted file mode 100644
index ea8e74fa..00000000
--- a/docs/docs/reference/02-configuration/01-auth-config.md
+++ /dev/null
@@ -1,447 +0,0 @@
----
-title: Initialization
----
-
-## Options
-
-Options are passed to Auth.js when initializing it in a server environment like a Next.js API Route.
-
-### providers
-
-- **Default value**: `[]`
-- **Required**: _Yes_
-
-#### Description
-
-An array of authentication providers for signing in (e.g. Google, Facebook, Twitter, GitHub, Email, etc) in any order. This can be one of the built-in providers or an object with a custom provider.
-
-Refer to the list of [all available Oauth providers](/reference/providers/oauth-builtin) and the [Oauth tutorial](/getting-started/oauth-tutorial) on how to use them.
-
----
-
-### secret
-
-- **Default value**: `string` (_SHA hash of the "options" object_) in development, no default in production.
-- **Required**: _Yes, in production!_
-
-#### Description
-
-A random string is used to hash tokens, sign/encrypt cookies and generate cryptographic keys.
-
-If you set [`NEXTAUTH_SECRET`](#nextauth_secret) as an environment variable, you don't have to define this option.
-
-If no value specified specified in development (and there is no `NEXTAUTH_SECRET` variable either), it uses a hash for all configuration options, including OAuth Client ID / Secrets for entropy.
-
-:::warning
-Not providing any `secret` or `NEXTAUTH_SECRET` will throw [an error](/reference/errors#no_secret) in production.
-:::
-
-You can quickly create a good value on the command line via this `openssl` command.
-
-```bash
-$ openssl rand -base64 32
-```
-
-:::tip
-If you rely on the default secret generation in development, you might notice JWT decryption errors, since the secret changes whenever you change your configuration. Defining an explicit secret will make this problem go away. We will likely make this option mandatory, even in development, in the future.
-:::
-
----
-
-### session
-
-- **Default value**: `object`
-- **Required**: _No_
-
-#### Description
-
-The `session` object and all properties on it are optional.
-
-Default values for this option are shown below:
-
-```js
-session: {
- // Choose how you want to save the user session.
- // The default is `"jwt"`, an encrypted JWT (JWE) stored in the session cookie.
- // If you use an `adapter` however, we default it to `"database"` instead.
- // You can still force a JWT session by explicitly defining `"jwt"`.
- // When using `"database"`, the session cookie will only contain a `sessionToken` value,
- // which is used to look up the session in the database.
- strategy: "database",
-
- // Seconds - How long until an idle session expires and is no longer valid.
- maxAge: 30 * 24 * 60 * 60, // 30 days
-
- // Seconds - Throttle how frequently to write to database to extend a session.
- // Use it to limit write operations. Set to 0 to always update the database.
- // Note: This option is ignored if using JSON Web Tokens
- updateAge: 24 * 60 * 60, // 24 hours
-}
-```
-
----
-
-### jwt
-
-- **Default value**: `object`
-- **Required**: _No_
-
-#### Description
-
-JSON Web Tokens can be used for session tokens if enabled with `session: { strategy: "jwt" }` option. JSON Web Tokens are enabled by default if you have not specified an adapter. JSON Web Tokens are encrypted (JWE) by default. We recommend you keep this behaviour. See the [Override JWT `encode` and `decode` methods](#override-jwt-encode-and-decode-methods) advanced option.
-
-#### JSON Web Token Options
-
-```js
-jwt: {
- // The maximum age of the Auth.js issued JWT in seconds.
- // Defaults to `session.maxAge`.
- maxAge: 60 * 60 * 24 * 30,
- // You can define your own encode/decode functions for signing and encryption
- async encode() {},
- async decode() {},
-}
-```
-
-An example JSON Web Token contains a payload like this:
-
-```js
-{
- name: 'Iain Collins',
- email: 'me@iaincollins.com',
- picture: 'https://example.com/image.jpg',
- iat: 1594601838,
- exp: 1597193838
-}
-```
-
-#### JWT Helper
-
-You can use the built-in `getToken()` helper method to verify and decrypt the token, like this:
-
-```js
-import { getToken } from "next-auth/jwt"
-
-const secret = process.env.NEXTAUTH_SECRET
-
-export default async function handler(req, res) {
- // if using `NEXTAUTH_SECRET` env variable, we detect it, and you won't actually need to `secret`
- // const token = await getToken({ req })
- const token = await getToken({ req, secret })
- console.log("JSON Web Token", token)
- res.end()
-}
-```
-
-_For convenience, this helper function is also able to read and decode tokens passed from the `Authorization: 'Bearer token'` HTTP header._
-
-**Required**
-
-The getToken() helper requires the following options:
-
-- `req` - (object) Request object
-- `secret` - (string) JWT Secret. Use `NEXTAUTH_SECRET` instead.
-
-You must also pass _any options configured on the `jwt` option_ to the helper.
-
-e.g. Including custom session `maxAge` and custom signing and/or encryption keys or options
-
-**Optional**
-
-It also supports the following options:
-
-- `secureCookie` - (boolean) Use secure prefixed cookie name
-
- By default, the helper function will attempt to determine if it should use the secure prefixed cookie (e.g. `true` in production and `false` in development, unless NEXTAUTH_URL contains an HTTPS URL).
-
-- `cookieName` - (string) Session token cookie name
-
- The `secureCookie` option is ignored if `cookieName` is explicitly specified.
-
-- `raw` - (boolean) Get raw token (not decoded)
-
- If set to `true` returns the raw token without decrypting or verifying it.
-
-:::note
-The JWT is stored in the Session Token cookie, the same cookie used for tokens with database sessions.
-:::
-
----
-
-### pages
-
-- **Default value**: `{}`
-- **Required**: _No_
-
-#### Description
-
-Specify URLs to be used if you want to create custom sign in, sign out and error pages.
-
-Pages specified will override the corresponding built-in page.
-
-_For example:_
-
-```js
-pages: {
- signIn: '/auth/signin',
- signOut: '/auth/signout',
- error: '/auth/error', // Error code passed in query string as ?error=
- verifyRequest: '/auth/verify-request', // (used for check email message)
- newUser: '/auth/new-user' // New users will be directed here on first sign in (leave the property out if not of interest)
-}
-```
-
-:::note
-When using this configuration, ensure that these pages actually exist. For example `error: '/auth/error'` refers to a page file at `pages/auth/error.js`.
-:::
-
-See the documentation for the [creating custom pages guide](/guides/basics/pages) for more information.
-
----
-
-### callbacks
-
-- **Default value**: `object`
-- **Required**: _No_
-
-#### Description
-
-Callbacks are asynchronous functions you can use to control what happens when an action is performed.
-
-Callbacks are extremely powerful, especially in scenarios involving JSON Web Tokens as they allow you to implement access controls without a database and to integrate with external databases or APIs.
-
-You can specify a handler for any of the callbacks below.
-
-```js
-callbacks: {
- async signIn({ user, account, profile, email, credentials }) {
- return true
- },
- async redirect({ url, baseUrl }) {
- return baseUrl
- },
- async session({ session, token, user }) {
- return session
- },
- async jwt({ token, user, account, profile, isNewUser }) {
- return token
- }
-}
-```
-
-See [our callbacks guide](/guides/basics/callbacks) for more information on how to use the callback functions.
-
----
-
-### events
-
-- **Default value**: `object`
-- **Required**: _No_
-
-#### Description
-
-Events are asynchronous functions that do not return a response, they are useful for audit logging.
-
-You can specify a handler for any of these events below - e.g. for debugging or to create an audit log.
-
-The content of the message object varies depending on the flow (e.g. OAuth or Email authentication flow, JWT or database sessions, etc). See the [events guide](/guides/basics/events) for more information on the form of each message object and how to use the events functions.
-
-```js
-events: {
- async signIn(message) { /* on successful sign in */ },
- async signOut(message) { /* on signout */ },
- async createUser(message) { /* user created */ },
- async updateUser(message) { /* user updated - e.g. their email was verified */ },
- async linkAccount(message) { /* account (e.g. Twitter) linked to a user */ },
- async session(message) { /* session is active */ },
-}
-```
-
----
-
-### adapter
-
-- **Default value**: none
-- **Required**: _No_
-
-#### Description
-
-By default Auth.js does not include an adapter any longer. If you would like to persist user / account data, please install one of the many available adapters. More information can be found in the [adapter documentation](/reference/adapters/overview).
-
----
-
-### debug
-
-- **Default value**: `false`
-- **Required**: _No_
-
-#### Description
-
-Set debug to `true` to enable debug messages for authentication and database operations.
-
----
-
-### logger
-
-- **Default value**: `console`
-- **Required**: _No_
-
-#### Description
-
-Override any of the logger levels (`undefined` levels will use the built-in logger), and intercept logs in NextAuth. You can use this to send NextAuth logs to a third-party logging service.
-
-The `code` parameter for `error` and `warn` are explained in the [Warnings](/reference/warnings) and [Errors](/reference/errors) pages respectively.
-
-Example:
-
-```js title="/pages/api/auth/[...nextauth].js"
-import log from "logging-service"
-
-export default NextAuth({
- ...
- logger: {
- error(code, metadata) {
- log.error(code, metadata)
- },
- warn(code) {
- log.warn(code)
- },
- debug(code, metadata) {
- log.debug(code, metadata)
- }
- }
- ...
-})
-```
-
-:::note
-If the `debug` level is defined by the user, it will be called regardless of the `debug: false` [option](#debug).
-:::
-
----
-
-### theme
-
-- **Default value**: `object`
-- **Required**: _No_
-
-#### Description
-
-Changes the color scheme theme of [pages](/reference/configuration/auth-config#pages) as well as allows some minor customization. Set `theme.colorScheme` to `"light"`, if you want to force pages to always be light. Set to `"dark"`, if you want to force pages to always be dark. Set to `"auto"`, (or leave this option out) if you want the pages to follow the preferred system theme. (Uses the [prefers-color-scheme](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme) media query.)
-
-In addition, you can define a logo URL in `theme.logo` which will be rendered above the main card in the default signin/signout/error/verify-request pages, as well as a `theme.brandColor` which will affect the accent color of these pages.
-
-```js
-theme: {
- colorScheme: "auto", // "auto" | "dark" | "light"
- brandColor: "", // Hex color code
- logo: "" // Absolute URL to image
-}
-```
-
----
-
-## Advanced Options
-
-Advanced options are passed the same way as basic options, but may have complex implications or side effects. You should try to avoid using advanced options unless you are very comfortable using them.
-
----
-
-### useSecureCookies
-
-- **Default value**: `true` for HTTPS sites / `false` for HTTP sites
-- **Required**: _No_
-
-#### Description
-
-When set to `true` (the default for all site URLs that start with `https://`) then all cookies set by Auth.js will only be accessible from HTTPS URLs.
-
-This option defaults to `false` on URLs that start with `http://` (e.g. `http://localhost:3000`) for developer convenience.
-
-:::note
-Properties on any custom `cookies` that are specified override this option.
-:::
-
-:::warning
-Setting this option to _false_ in production is a security risk and may allow sessions to be hijacked if used in production. It is intended to support development and testing. Using this option is not recommended.
-:::
-
----
-
-### cookies
-
-- **Default value**: `{}`
-- **Required**: _No_
-
-#### Description
-
-Cookies in Auth.js are chunked by default, meaning that once they reach the 4kb limit, we will create a new cookie with the `.{number}` suffix and reassemble the cookies in the correct order when parsing / reading them. This was introduced to avoid size constraints which can occur when users want to store additional data in their sessionToken, for example.
-
-You can override the default cookie names and options for any of the cookies used by Auth.js.
-
-This is an advanced option and using it is not recommended as you may break authentication or introduce security flaws into your application.
-
-You can specify one or more cookies with custom properties, but if you specify custom options for a cookie you must provide all the options for that cookie.
-
-If you use this feature, you will likely want to create conditional behaviour to support setting different cookies policies in development and production builds, as you will be opting out of the built-in dynamic policy.
-
-:::tip
-An example of a use case for this option is to support sharing session tokens across subdomains.
-:::
-
-#### Example
-
-```js
-cookies: {
- sessionToken: {
- name: `__Secure-next-auth.session-token`,
- options: {
- httpOnly: true,
- sameSite: 'lax',
- path: '/',
- secure: true
- }
- },
- callbackUrl: {
- name: `__Secure-next-auth.callback-url`,
- options: {
- sameSite: 'lax',
- path: '/',
- secure: true
- }
- },
- csrfToken: {
- name: `__Host-next-auth.csrf-token`,
- options: {
- httpOnly: true,
- sameSite: 'lax',
- path: '/',
- secure: true
- }
- },
- pkceCodeVerifier: {
- name: `${cookiePrefix}next-auth.pkce.code_verifier`,
- options: {
- httpOnly: true,
- sameSite: 'lax',
- path: '/',
- secure: useSecureCookies,
- maxAge: 900
- }
- },
- state: {
- name: `${cookiePrefix}next-auth.state`,
- options: {
- httpOnly: true,
- sameSite: "lax",
- path: "/",
- secure: useSecureCookies,
- maxAge: 900
- },
- },
-}
-```
-
-:::warning
-Using a custom cookie policy may introduce security flaws into your application and is intended as an option for advanced users who understand the implications. Using this option is not recommended.
-:::
diff --git a/docs/docs/reference/02-configuration/04-env.md b/docs/docs/reference/02-configuration/04-env.md
deleted file mode 100644
index 52d8273c..00000000
--- a/docs/docs/reference/02-configuration/04-env.md
+++ /dev/null
@@ -1,38 +0,0 @@
----
-title: Environment variables
-sidebar_label: Environment Variables
----
-
-## NEXTAUTH_URL
-
-When deploying to production, set the `NEXTAUTH_URL` environment variable to the canonical URL of your site.
-
-```
-NEXTAUTH_URL=https://example.com
-```
-
-If your Next.js application uses a custom base path, specify the route to the API endpoint in full.
-
-_e.g. `NEXTAUTH_URL=https://example.com/custom-route/api/auth`_
-
-:::note
-Using [System Environment Variables](https://vercel.com/docs/concepts/projects/environment-variables#system-environment-variables) we automatically detect when you deploy to [Vercel](https://vercel.com) so you don't have to define this variable. Make sure **Automatically expose System Environment Variables** is checked in your Project Settings.
-:::
-
----
-
-## NEXTAUTH_SECRET
-
-Used to encrypt the Auth.js JWT, and to hash [email verification tokens](/reference/adapters/models#verification-token). This is the default value for the [`secret`](/reference/configuration/auth-config#secret) option. The `secret` option might be removed in the future in favor of this.
-
-If you are using [Middleware](/reference/nextjs/#prerequisites) this environment variable must be set.
-
----
-
-## NEXTAUTH_URL_INTERNAL
-
-If provided, server-side calls will use this instead of `NEXTAUTH_URL`. Useful in environments when the server doesn't have access to the canonical URL of your site. Defaults to `NEXTAUTH_URL`.
-
-```
-NEXTAUTH_URL_INTERNAL=http://10.240.8.16
-```
diff --git a/docs/docs/reference/02-configuration/_category_.json b/docs/docs/reference/02-configuration/_category_.json
deleted file mode 100644
index 48eb56ab..00000000
--- a/docs/docs/reference/02-configuration/_category_.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "label": "Configuration",
- "collapsible": true,
- "collapsed": true
-}
diff --git a/docs/docs/reference/04-providers/02-oauth-builtin.mdx b/docs/docs/reference/04-providers/02-oauth-builtin.mdx
deleted file mode 100644
index b84d2201..00000000
--- a/docs/docs/reference/04-providers/02-oauth-builtin.mdx
+++ /dev/null
@@ -1,23 +0,0 @@
----
-title: Available OAuth providers
-sidebar_label: OAuth providers
----
-
-Authentication Providers in **Auth.js** are services that can be used to sign a user in.
-
-Auth.js comes with a set of built-in providers. You can find them [here](https://github.com/nextauthjs/next-auth/tree/main/packages/core/src/providers). Each built-in provider has its own documentation page:
-
-:::note
-Auth.js supports any **2.x** and **OpenID Connect (OIDC)** compliant providers and has built-in support for the most popular services.
-:::
-
-
diff --git a/docs/docs/reference/04-providers/02-oauth.mdx b/docs/docs/reference/04-providers/02-oauth.mdx
deleted file mode 100644
index 009f0d84..00000000
--- a/docs/docs/reference/04-providers/02-oauth.mdx
+++ /dev/null
@@ -1,193 +0,0 @@
----
-title: OAuth Provider Options
-sidebar_label: OAuth options
----
-
-## Provider Options
-
-Whenever you configure a custom or a built-in OAuth provider, you have the following options available:
-
-```ts
-interface OAuthConfig {
- /**
- * OpenID Connect (OIDC) compliant providers can configure
- * this instead of `authorize`/`token`/`userinfo` options
- * without further configuration needed in most cases.
- * You can still use the `authorize`/`token`/`userinfo`
- * options for advanced control.
- *
- * [Authorization Server Metadata](https://datatracker.ietf.org/doc/html/rfc8414#section-3)
- */
- wellKnown?: string
- /**
- * The login process will be initiated by sending the user to this URL.
- *
- * [Authorization endpoint](https://datatracker.ietf.org/doc/html/rfc6749#section-3.1)
- */
- authorization: EndpointHandler
- /**
- * Endpoint that returns OAuth 2/OIDC tokens and information about them.
- * This includes `access_token`, `id_token`, `refresh_token`, etc.
- *
- * [Token endpoint](https://datatracker.ietf.org/doc/html/rfc6749#section-3.2)
- */
- token: EndpointHandler<
- UrlParams,
- {
- /**
- * Parameters extracted from the request to the `/api/auth/callback/:providerId` endpoint.
- * Contains params like `state`.
- */
- params: CallbackParamsType
- /**
- * When using this custom flow, make sure to do all the necessary security checks.
- * This object contains parameters you have to match against the request to make sure it is valid.
- */
- checks: OAuthChecks
- },
- { tokens: TokenSet }
- >
- /**
- * When using an OAuth 2 provider, the user information must be requested
- * through an additional request from the userinfo endpoint.
- *
- * [Userinfo endpoint](https://www.oauth.com/oauth2-servers/signing-in-with-google/verifying-the-user-info)
- */
- userinfo?: EndpointHandler
- type: "oauth"
- /**
- * Used in URLs to refer to a certain provider.
- * @example /api/auth/callback/twitter // where the `id` is "twitter"
- */
- id: string
- version: string
- profile(profile: P, tokens: TokenSet): Awaitable
- checks?: ChecksType | ChecksType[]
- clientId: string
- clientSecret: string
- /**
- * If set to `true`, the user information will be extracted
- * from the `id_token` claims, instead of
- * making a request to the `userinfo` endpoint.
- *
- * `id_token` is usually present in OpenID Connect (OIDC) compliant providers.
- *
- * [`id_token` explanation](https://www.oauth.com/oauth2-servers/openid-connect/id-tokens)
- */
- idToken?: boolean
- region?: string
- issuer?: string
- client?: Partial
- allowDangerousEmailAccountLinking?: boolean
- /**
- * Object containing the settings for the styling of the providers sign-in buttons
- */
- style: ProviderStyleType
-}
-```
-
-### `authorization` option
-
-Configure how to construct the request to the [_Authorization endpoint_](https://datatracker.ietf.org/doc/html/rfc6749#section-3.1).
-
-There are two ways to use this option:
-
-1. You can either set `authorization` to be a full URL, like `"https://example.com/oauth/authorization?scope=email"`.
-2. Use an object with `url` and `params` like so
- ```js
- authorization: {
- url: "https://example.com/oauth/authorization",
- params: { scope: "email" }
- }
- ```
-
-:::tip
-If your Provider is OpenID Connect (OIDC) compliant, we recommend using the `wellKnown` option instead.
-:::
-
-### `token` option
-
-Configure how to construct the request to the [_Token endpoint_](https://datatracker.ietf.org/doc/html/rfc6749#section-3.2).
-
-There are three ways to use this option:
-
-1. You can either set `token` to be a full URL, like `"https://example.com/oauth/token?some=param"`.
-2. Use an object with `url` and `params` like so
- ```js
- token: {
- url: "https://example.com/oauth/token",
- params: { some: "param" }
- }
- ```
-3. Completely take control of the request:
- ```js
- token: {
- url: "https://example.com/oauth/token",
- async request(context) {
- // context contains useful properties to help you make the request.
- const tokens = await makeTokenRequest(context)
- return { tokens }
- }
- }
- ```
-
-:::warning
-Option 3. should not be necessary in most cases, but if your provider does not follow the spec, or you have some very unique constraints it can be useful. Try to avoid it, if possible.
-:::
-
-:::tip
-If your Provider is OpenID Connect (OIDC) compliant, we recommend using the `wellKnown` option instead.
-:::
-
-### `userinfo` option
-
-A `userinfo` endpoint returns information about the logged-in user. It is not part of the OAuth specification, but usually available for most providers.
-
-There are three ways to use this option:
-
-1. You can either set `userinfo` to be a full URL, like `"https://example.com/oauth/userinfo?some=param"`.
-2. Use an object with `url` and `params` like so
- ```js
- userinfo: {
- url: "https://example.com/oauth/userinfo",
- params: { some: "param" }
- }
- ```
-3. Completely take control of the request:
- ```js
- userinfo: {
- url: "https://example.com/oauth/userinfo",
- // The result of this method will be the input to the `profile` callback.
- async request(context) {
- // context contains useful properties to help you make the request.
- return await makeUserinfoRequest(context)
- }
- }
- ```
-
-:::warning
-Option 3. should not be necessary in most cases, but if your provider does not follow the spec, or you have some very unique constraints it can be useful. Try to avoid it, if possible.
-:::
-
-:::tip
-In the rare case you don't care about what this endpoint returns, or your provider does not have one, you could create a noop function:
-
-```js
-userinfo: {
- request: () => {}
-}
-```
-
-:::
-
-:::tip
-If your Provider is OpenID Connect (OIDC) compliant, we recommend using the `wellKnown` option instead. OIDC usually returns an `id_token` from the `token` endpoint. `next-auth` can decode the `id_token` to get the user information, instead of making an additional request to the `userinfo` endpoint. Just set `idToken: true` at the top-level of your provider configuration. If not set, `next-auth` will still try to contact this endpoint.
-:::
-
-### `client` option
-
-An advanced option, hopefully you won't need it in most cases. `next-auth` uses `openid-client` under the hood, see the docs on this option [here](https://github.com/panva/node-openid-client/blob/main/docs/README.md#new-clientmetadata-jwks-options).
-
-### `allowDangerousEmailAccountLinking` option
-
-Normally, when you sign in with an OAuth provider and another account with the same email address already exists, the accounts are not linked automatically. Automatic account linking on sign in is not secure between arbitrary providers and is disabled by default (see our [Security FAQ](https://authjs.dev/reference/faq#security)). However, it may be desirable to allow automatic account linking if you trust that the provider involved has securely verified the email address associated with the account. Just set `allowDangerousEmailAccountLinking: true` in your provider configuration to enable automatic account linking.
diff --git a/docs/docs/reference/04-providers/04-email.md b/docs/docs/reference/04-providers/04-email.md
deleted file mode 100644
index ec8279f7..00000000
--- a/docs/docs/reference/04-providers/04-email.md
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: Email Provider options
-sidebar_label: Email options
----
-
-| Name | Description | Type | Required |
-| :---------------------: | :---------------------------------------------------------------------------------: | :------------------------------: | :------: |
-| id | Unique ID for the provider | `string` | Yes |
-| name | Descriptive name for the provider | `string` | Yes |
-| type | Type of provider, in this case `email` | `"email"` | Yes |
-| server | Path or object pointing to the email server | `string` or `Object` | Yes |
-| sendVerificationRequest | Callback to execute when a verification request is sent | `(params) => Promise` | Yes |
-| from | The email address from which emails are sent, default: "" | `string` | No |
-| maxAge | How long until the e-mail can be used to log the user in seconds. Defaults to 1 day | `number` | No |
-
-See our guides on magic links authentication for further tips on how to customize this provider:
-
-- [Tutorial](/getting-started/email-tutorial)
-- [Guide deep-dive](/guides/providers/email)
diff --git a/docs/docs/reference/04-providers/05-credentials.md b/docs/docs/reference/04-providers/05-credentials.md
deleted file mode 100644
index a8b97ffa..00000000
--- a/docs/docs/reference/04-providers/05-credentials.md
+++ /dev/null
@@ -1,17 +0,0 @@
----
-title: Credentials Provider options
-sidebar_label: Credentials options
----
-
-| Name | Description | Type | Required |
-| :---------: | :-----------------------------------------------: | :-----------------------------------: | :------: |
-| id | Unique ID for the provider | `string` | Yes |
-| name | Descriptive name for the provider | `string` | Yes |
-| type | Type of provider, in this case `credentials` | `"credentials"` | Yes |
-| credentials | The credentials to sign-in with | `Object` | Yes |
-| authorize | Callback to execute once user is to be authorized | `(credentials, req) => Promise` | Yes |
-
-See our guides on credentials authentication for further tips on how to customize this provider:
-
-- [Tutorial](/getting-started/credentials-tutorial)
-- [Guide deep-dive](guides/providers/credentials)
diff --git a/docs/docs/reference/04-providers/_category_.json b/docs/docs/reference/04-providers/_category_.json
deleted file mode 100644
index 906e287d..00000000
--- a/docs/docs/reference/04-providers/_category_.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "label": "Providers",
- "collapsible": true,
- "collapsed": true
-}
diff --git a/docs/docs/reference/04-providers/index.md b/docs/docs/reference/04-providers/index.md
deleted file mode 100644
index b221dd67..00000000
--- a/docs/docs/reference/04-providers/index.md
+++ /dev/null
@@ -1,16 +0,0 @@
----
-title: Overview
----
-
-There's four ways a user can be signed in:
-
-- [Using a built-in OAuth Provider](/reference/providers/oauth-builtin) (e.g Github, Twitter, Google, etc...)
-- [Using a custom OAuth Provider](/guides/providers/custom-provider)
-- [Using Email](/getting-started/email-tutorial)
-- [Using Credentials](/getting-started/credentials-tutorial)
-
-In case you need further customization, see the options for each type of provider:
-
-- [Oauth options](/reference/providers/oauth)
-- [Email options](/reference/providers/email)
-- [Credentials options](/reference/providers/credentials)
diff --git a/docs/docs/reference/05-oauth-providers/42.md b/docs/docs/reference/05-oauth-providers/42.md
deleted file mode 100644
index e4a176ad..00000000
--- a/docs/docs/reference/05-oauth-providers/42.md
+++ /dev/null
@@ -1,38 +0,0 @@
----
-id: 42-school
-title: 42 School
----
-
-:::note
-42 returns a field on `Account` called `created_at` which is a number. See the [docs](https://api.intra.42.fr/apidoc/guides/getting_started#make-basic-requests). Make sure to add this field to your database schema, in case if you are using an [Adapter](/reference/adapters/overview).
-:::
-
-## Documentation
-
-https://api.intra.42.fr/apidoc/guides/web_application_flow
-
-## Configuration
-
-https://profile.intra.42.fr/oauth/applications/new
-
-## Options
-
-The **42 School Provider** comes with a set of default options:
-
-- [42 School Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/42-school.ts)
-
-You can override any of the options to suit your own use case.
-
-## Example
-
-```js
-import FortyTwoProvider from "next-auth/providers/42-school";
-...
-providers: [
- FortyTwoProvider({
- clientId: process.env.FORTY_TWO_CLIENT_ID,
- clientSecret: process.env.FORTY_TWO_CLIENT_SECRET
- })
-]
-...
-```
diff --git a/docs/docs/reference/05-oauth-providers/_category_.json b/docs/docs/reference/05-oauth-providers/_category_.json
deleted file mode 100644
index 83b2df8c..00000000
--- a/docs/docs/reference/05-oauth-providers/_category_.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "label": "OAuth Providers",
- "collapsible": true,
- "collapsed": true
-}
diff --git a/docs/docs/reference/05-oauth-providers/apple.md b/docs/docs/reference/05-oauth-providers/apple.md
deleted file mode 100644
index a3611e6a..00000000
--- a/docs/docs/reference/05-oauth-providers/apple.md
+++ /dev/null
@@ -1,137 +0,0 @@
----
-id: apple
-title: Apple
----
-
-## Documentation
-
-https://developer.apple.com/sign-in-with-apple/get-started/
-
-## Configuration
-
-https://developer.apple.com/account/resources/identifiers/list/serviceId
-
-## Options
-
-The **Apple Provider** comes with a set of default options:
-
-- [Apple Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/apple.ts)
-
-You can override any of the options to suit your own use case.
-
-### Generating a secret
-
-Apple requires the client secret to be a JWT. To generate one, you can use the following script: https://bal.so/apple-gen-secret.
-
-For more information, see the [Apple docs](https://developer.apple.com/documentation/sign_in_with_apple/generate_and_validate_tokens#3262048)
-
-Then, you can paste the result into your `.env.local` file under `APPLE_SECRET`, so you can refer to it from your code:
-
-```js
-import AppleProvider from "next-auth/providers/apple";
-...
-providers: [
- AppleProvider({
- clientId: process.env.APPLE_ID,
- clientSecret: process.env.APPLE_SECRET
- })
-]
-...
-```
-
-:::tip
-The TeamID is located on the top right after logging in.
-:::
-
-:::tip
-The KeyID is located after you create the key. Look for it before you download the k8 file.
-:::
-
-## Testing on a development server
-
-:::tip
-Apple requires all sites to run HTTPS (including local development instances).
-:::
-
-:::tip
-Apple doesn't allow you to use localhost in domains or subdomains.
-:::
-
-### Host name resolution
-
-Edit your host file and point your site to `127.0.0.1`.
-
-_Linux/macOS_
-
-```
-sudo echo '127.0.0.1 dev.example.com' >> /etc/hosts
-```
-
-_Windows_ (run PowerShell as administrator)
-
-```ps
-Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "127.0.0.1 dev.example.com" -Force
-```
-
-More info: [How to edit my host file?](https://phoenixnap.com/kb/how-to-edit-hosts-file-in-windows-mac-or-linux)
-
-### Create certificate
-
-Create a directory `certificates` and add the certificate files `localhost.key` and `localhost.crt`, which you generate using OpenSSL:
-
-_Linux/macOS_
-
-```bash
-openssl req -x509 -out localhost.crt -keyout localhost.key \
- -newkey rsa:2048 -nodes -sha256 \
- -subj "/CN=localhost" -extensions EXT -config <( \
- printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")
-```
-
-_Windows_
-
-The OpenSSL executable is distributed with [Git](https://git-scm.com/download/win) for Windows. Once installed you will find the openssl.exe file in `C:\Program Files\Git\mingw64\bin`, which you can add to the system PATH environment variable if it’s not already done.
-
-Add environment variable `OPENSSL_CONF=C:\Program Files\Git\mingw64\ssl\openssl.cnf`
-
-```cmd
- req -x509 -out localhost.crt -keyout localhost.key \
- -newkey rsa:2048 -nodes -sha256 \
- -subj "/CN=localhost"
-```
-
-### Deploy to server
-
-You can create a `server.js` in the root of your project and run it with `node server.js` to test Sign in with Apple integration locally:
-
-```js
-const { createServer } = require("https")
-const { parse } = require("url")
-const next = require("next")
-const fs = require("fs")
-
-const dev = process.env.NODE_ENV !== "production"
-const app = next({ dev })
-const handle = app.getRequestHandler()
-
-const httpsOptions = {
- key: fs.readFileSync("./certificates/localhost.key"),
- cert: fs.readFileSync("./certificates/localhost.crt"),
-}
-
-app.prepare().then(() => {
- createServer(httpsOptions, (req, res) => {
- const parsedUrl = parse(req.url, true)
- handle(req, res, parsedUrl)
- }).listen(3000, (err) => {
- if (err) throw err
- console.log("> Ready on https://localhost:3000")
- })
-})
-```
-
-### Helpful guides
-
-- [How to setup localhost with HTTPS with a Next.js app](https://medium.com/@anMagpie/secure-your-local-development-server-with-https-next-js-81ac6b8b3d68)
-
-- [Guide to configuring Sign in with Apple](https://developer.okta.com/blog/2019/06/04/what-the-heck-is-sign-in-with-apple)
diff --git a/docs/docs/reference/05-oauth-providers/atlassian.md b/docs/docs/reference/05-oauth-providers/atlassian.md
deleted file mode 100644
index 759a33bf..00000000
--- a/docs/docs/reference/05-oauth-providers/atlassian.md
+++ /dev/null
@@ -1,52 +0,0 @@
----
-id: atlassian
-title: Atlassian
----
-
-## Documentation
-
-https://developer.atlassian.com/cloud/jira/platform/oauth-2-authorization-code-grants-3lo-for-apps/#implementing-oauth-2-0--3lo-
-
-## Options
-
-The **Atlassian Provider** comes with a set of default options:
-
-- [Atlassian Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/atlassian.ts)
-
-You can override any of the options to suit your own use case.
-
-## Example
-
-```js
-import AtlassianProvider from "next-auth/providers/atlassian";
-...
-providers: [
- AtlassianProvider({
- clientId: process.env.ATLASSIAN_CLIENT_ID,
- clientSecret: process.env.ATLASSIAN_CLIENT_SECRET,
- authorization: {
- params: {
- scope: "write:jira-work read:jira-work read:jira-user offline_access read:me"
- }
- }
- })
-]
-...
-```
-
-## Instructions
-
-### Configuration
-
-:::tip
-An app can be created at https://developer.atlassian.com/apps/
-:::
-
-Under "Apis and features" in the side menu, configure the following for "OAuth 2.0 (3LO)":
-
-- Redirect URL
- - http://localhost:3000/api/auth/callback/atlassian
-
-:::warning
-To enable access to Jira Platform REST API you must enable User Identity API and add `read:me` to your provider scope option.
-:::
diff --git a/docs/docs/reference/05-oauth-providers/auth0.md b/docs/docs/reference/05-oauth-providers/auth0.md
deleted file mode 100644
index d3e5fc5a..00000000
--- a/docs/docs/reference/05-oauth-providers/auth0.md
+++ /dev/null
@@ -1,39 +0,0 @@
----
-id: auth0
-title: Auth0
----
-
-## Documentation
-
-https://auth0.com/docs/api/authentication#authorize-application
-
-## Configuration
-
-https://manage.auth0.com/dashboard
-
-## Options
-
-The **Auth0 Provider** comes with a set of default options:
-
-- [Auth0 Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/auth0.ts)
-
-You can override any of the options to suit your own use case.
-
-## Example
-
-```js
-import Auth0Provider from "next-auth/providers/auth0";
-...
-providers: [
- Auth0Provider({
- clientId: process.env.AUTH0_CLIENT_ID,
- clientSecret: process.env.AUTH0_CLIENT_SECRET,
- issuer: process.env.AUTH0_ISSUER
- })
-]
-...
-```
-
-:::note
-`issuer` should be the fully qualified URL – e.g. `https://dev-s6clz2lv.eu.auth0.com`
-:::
diff --git a/docs/docs/reference/05-oauth-providers/authentik.md b/docs/docs/reference/05-oauth-providers/authentik.md
deleted file mode 100644
index c1887318..00000000
--- a/docs/docs/reference/05-oauth-providers/authentik.md
+++ /dev/null
@@ -1,35 +0,0 @@
----
-id: authentik
-title: Authentik
----
-
-## Documentation
-
-https://goauthentik.io/docs/providers/oauth2
-
-## Options
-
-The **Authentik Provider** comes with a set of default options:
-
-- [Authentik Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/authentik.ts)
-
-You can override any of the options to suit your own use case.
-
-## Example
-
-```js
-import AuthentikProvider from "next-auth/providers/authentik";
-...
-providers: [
- AuthentikProvider({
- clientId: process.env.AUTHENTIK_ID,
- clientSecret: process.env.AUTHENTIK_SECRET,
- issuer: process.env.AUTHENTIK_ISSUER,
- })
-]
-...
-```
-
-:::note
-`issuer` should include the slug without a trailing slash – e.g., `https://my-authentik-domain.com/application/o/My_Slug`
-:::
diff --git a/docs/docs/reference/05-oauth-providers/azure-ad-b2c.md b/docs/docs/reference/05-oauth-providers/azure-ad-b2c.md
deleted file mode 100644
index da703643..00000000
--- a/docs/docs/reference/05-oauth-providers/azure-ad-b2c.md
+++ /dev/null
@@ -1,117 +0,0 @@
----
-id: azure-ad-b2c
-title: Azure Active Directory B2C
----
-
-:::note
-Azure AD B2C returns the following fields on `Account`:
-
-- `refresh_token_expires_in` (number)
-- `not_before` (number)
-- `id_token_expires_in` (number)
-- `profile_info` (string).
-
-See their [docs](https://docs.microsoft.com/en-us/azure/active-directory-b2c/access-tokens). Remember to add these fields to your database schema, in case if you are using an [Adapter](/reference/adapters/overview).
-:::
-
-## Documentation
-
-https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow
-
-## Configuration
-
-https://docs.microsoft.com/azure/active-directory-b2c/tutorial-create-tenant
-
-## Options
-
-The **Azure Active Directory Provider** comes with a set of default options:
-
-- [Azure Active Directory Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/azure-ad-b2c.ts)
-
-You can override any of the options to suit your own use case.
-
-## Configuration (Basic)
-
-Basic configuration sets up Azure AD B2C to return an ID Token. This should be done as a prerequisite prior to running through the Advanced configuration.
-
-Step 1: Azure AD B2C Tenant
-https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-create-tenant
-
-Step 2: App Registration
-https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-register-applications
-
-Step 3: User Flow
-https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-create-user-flows
-
-Note: For the step "User attributes and token claims" you might minimally:
-
-- Collect attribute:
- - Email Address
- - Display Name
- - Given Name
- - Surname
-- Return claim:
- - Email Addresses
- - Display Name
- - Given Name
- - Surname
- - Identity Provider
- - Identity Provider Access Token
- - User's Object ID
-
-## Example
-
-In `.env.local` create the following entries:
-
-```
-AZURE_AD_B2C_TENANT_NAME=
-AZURE_AD_B2C_CLIENT_ID=
-AZURE_AD_B2C_CLIENT_SECRET=
-AZURE_AD_B2C_PRIMARY_USER_FLOW=
-```
-
-In `pages/api/auth/[...nextauth].js` find or add the AZURE_AD_B2C entries:
-
-```js
-import AzureADB2CProvider from "next-auth/providers/azure-ad-b2c";
-...
-providers: [
- AzureADB2CProvider({
- tenantId: process.env.AZURE_AD_B2C_TENANT_NAME,
- clientId: process.env.AZURE_AD_B2C_CLIENT_ID,
- clientSecret: process.env.AZURE_AD_B2C_CLIENT_SECRET,
- primaryUserFlow: process.env.AZURE_AD_B2C_PRIMARY_USER_FLOW,
- authorization: { params: { scope: "offline_access openid" } },
- }),
-]
-...
-```
-
-## Configuration (Advanced)
-
-Advanced configuration sets up Azure AD B2C to return an Authorization Token. This builds on the steps completed in the Basic configuration above.
-
-Step 4: Add a Web API application
-https://docs.microsoft.com/en-us/azure/active-directory-b2c/tutorial-single-page-app-webapi?tabs=app-reg-ga
-
-Note: this is a second app registration (similar to Step 2) but with different setup and configuration.
-
-## Example
-
-Nothing in `.env.local` needs to change here. The only update is in `pages/api/auth/[...nextauth].js` where you will need to add the additional scopes that were created in Step 4 above:
-
-```js
-import AzureADB2CProvider from "next-auth/providers/azure-ad-b2c";
-...
-providers: [
- AzureADB2CProvider({
- tenantId: process.env.AZURE_AD_B2C_TENANT_NAME,
- clientId: process.env.AZURE_AD_B2C_CLIENT_ID,
- clientSecret: process.env.AZURE_AD_B2C_CLIENT_SECRET,
- primaryUserFlow: process.env.AZURE_AD_B2C_PRIMARY_USER_FLOW,
- authorization: { params: { scope: `https://${process.env.AZURE_AD_B2C_TENANT_NAME}.onmicrosoft.com/api/demo.read https://${process.env.AZURE_AD_B2C_TENANT_NAME}.onmicrosoft.com/api/demo.write offline_access openid` } },
- }),
-]
-...
-
-```
diff --git a/docs/docs/reference/05-oauth-providers/azure-ad.md b/docs/docs/reference/05-oauth-providers/azure-ad.md
deleted file mode 100644
index 82610041..00000000
--- a/docs/docs/reference/05-oauth-providers/azure-ad.md
+++ /dev/null
@@ -1,59 +0,0 @@
----
-id: azure-ad
-title: Azure Active Directory
----
-
-## Documentation
-
-https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-auth-code-flow
-
-## Configuration
-
-https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app
-
-## Example
-
-### To allow specific Active Directory users access:
-
-- In https://portal.azure.com/ search for "Azure Active Directory", and select your organization.
-- Next, go to "App Registration" in the left menu, and create a new one.
-- Pay close attention to "Who can use this application or access this API?"
- - This allows you to scope access to specific types of user accounts
- - Only your tenant, all azure tenants, or all azure tenants and public Microsoft accounts (Skype, Xbox, Outlook.com, etc.)
-- When asked for a redirection URL, use `https://yourapplication.com/api/auth/callback/azure-ad` or for development `http://localhost:3000/api/auth/callback/azure-ad`.
-- After your App Registration is created, under "Client Credential" create your Client secret.
-- Now copy your:
- - Application (client) ID
- - Directory (tenant) ID
- - Client secret (value)
-
-In `.env.local` create the following entries:
-
-```
-AZURE_AD_CLIENT_ID=
-AZURE_AD_CLIENT_SECRET=
-AZURE_AD_TENANT_ID=
-```
-
-That will default the tenant to use the `common` authorization endpoint. [For more details see here](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-v2-protocols#endpoints).
-
-:::note
-Azure AD returns the profile picture in an ArrayBuffer, instead of just a URL to the image, so our provider converts it to a base64 encoded image string and returns that instead. See: https://docs.microsoft.com/en-us/graph/api/profilephoto-get?view=graph-rest-1.0#examples. The default image size is 48x48 to avoid [running out of space](https://authjs.dev/concepts/faq#:~:text=What%20are%20the%20disadvantages%20of%20JSON%20Web%20Tokens%3F) in case the session is saved as a JWT.
-:::
-
-In `pages/api/auth/[...nextauth].js` find or add the `AzureAD` entries:
-
-```js
-import AzureADProvider from "next-auth/providers/azure-ad";
-
-...
-providers: [
- AzureADProvider({
- clientId: process.env.AZURE_AD_CLIENT_ID,
- clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
- tenantId: process.env.AZURE_AD_TENANT_ID,
- }),
-]
-...
-
-```
diff --git a/docs/docs/reference/05-oauth-providers/battlenet.md b/docs/docs/reference/05-oauth-providers/battlenet.md
deleted file mode 100644
index 69af1b00..00000000
--- a/docs/docs/reference/05-oauth-providers/battlenet.md
+++ /dev/null
@@ -1,46 +0,0 @@
----
-id: battle.net
-title: Battle.net
----
-
-## Documentation
-
-https://develop.battle.net/documentation/guides/using-oauth
-
-## Configuration
-
-https://develop.battle.net/access/clients
-
-## Options
-
-The **Battle.net Provider** comes with a set of default options:
-
-- [Battle.net Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/battlenet.ts)
-
-You can override any of the options to suit your own use case.
-
-## Example
-
-```js
-import BattleNetProvider from "next-auth/providers/battlenet";
-...
-providers: [
- BattleNetProvider({
- clientId: process.env.BATTLENET_CLIENT_ID,
- clientSecret: process.env.BATTLENET_CLIENT_SECRET,
- issuer: process.env.BATTLENET_ISSUER
- })
-]
-...
-```
-
-`issuer` must be one of these values, based on the [available regions](https://develop.battle.net/documentation/guides/regionality-and-apis):
-
-```ts
-type BattleNetIssuer =
- | "https://www.battlenet.com.cn/oauth"
- | "https://us.battle.net/oauth"
- | "https://eu.battle.net/oauth"
- | "https://kr.battle.net/oauth"
- | "https://tw.battle.net/oauth"
-```
diff --git a/docs/docs/reference/05-oauth-providers/box.md b/docs/docs/reference/05-oauth-providers/box.md
deleted file mode 100644
index c7ce0c9e..00000000
--- a/docs/docs/reference/05-oauth-providers/box.md
+++ /dev/null
@@ -1,34 +0,0 @@
----
-id: box
-title: Box
----
-
-## Documentation
-
-https://developer.box.com/reference/
-
-## Configuration
-
-https://developer.box.com/guides/sso-identities-and-app-users/connect-okta-to-app-users/configure-box/
-
-## Options
-
-The **Box Provider** comes with a set of default options:
-
-- [Box Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/box.js)
-
-You can override any of the options to suit your own use case.
-
-## Example
-
-```js
-import BoxProvider from "next-auth/providers/box";
-...
-providers: [
- BoxProvider({
- clientId: process.env.BOX_CLIENT_ID,
- clientSecret: process.env.BOX_CLIENT_SECRET
- })
-]
-...
-```
diff --git a/docs/docs/reference/05-oauth-providers/boxyhq-saml.md b/docs/docs/reference/05-oauth-providers/boxyhq-saml.md
deleted file mode 100644
index a2e67570..00000000
--- a/docs/docs/reference/05-oauth-providers/boxyhq-saml.md
+++ /dev/null
@@ -1,58 +0,0 @@
----
-id: boxyhq-saml
-title: BoxyHQ SAML
----
-
-## Documentation
-
-BoxyHQ SAML is an open source service that handles the SAML login flow as an OAuth 2.0 flow, abstracting away all the complexities of the SAML protocol.
-
-You can deploy BoxyHQ SAML as a separate service or embed it into your app using our NPM library. [Check out the documentation for more details](https://boxyhq.com/docs/jackson/deploy)
-
-## Configuration
-
-SAML login requires a configuration for every tenant of yours. One common method is to use the domain for an email address to figure out which tenant they belong to. You can also use a unique tenant ID (string) from your backend for this, typically some kind of account or organization ID.
-
-Check out the [documentation](https://boxyhq.com/docs/jackson/saml-flow#2-saml-config-api) for more details.
-
-## Options
-
-The **BoxyHQ SAML Provider** comes with a set of default options:
-
-- [BoxyHQ Provider options](https://github.com/nextauthjs/next-auth/tree/main/packages/next-auth/src/providers/boxyhq-saml.ts)
-
-You can override any of the options to suit your own use case.
-
-## Example
-
-```ts
-import BoxyHQSAMLProvider from "next-auth/providers/boxyhq-saml"
-...
-providers: [
- BoxyHQSAMLProvider({
- issuer: "http://localhost:5225",
- clientId: "dummy", // The dummy here is necessary since we'll pass tenant and product custom attributes in the client code
- clientSecret: "dummy", // The dummy here is necessary since we'll pass tenant and product custom attributes in the client code
- })
-}
-...
-```
-
-On the client side you'll need to pass additional parameters `tenant` and `product` to the `signIn` function. This will allow BoxyHQL SAML to figure out the right SAML configuration and take your user to the right SAML Identity Provider to sign them in.
-
-```tsx
-import { signIn } from "next-auth/react";
-...
-
- // Map your users's email to a tenant and product
- const tenant = email.split("@")[1];
- const product = 'my_awesome_product';
-...
-