mirror of
https://github.com/SrIzan10/next-auth.git
synced 2026-05-01 10:55:20 +00:00
Compare commits
218 Commits
@auth/soli
...
ndom91/doc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
623a6e97ca | ||
|
|
f7d964d0b9 | ||
|
|
dd4170cf08 | ||
|
|
b85b5aa5f6 | ||
|
|
d77b97c9fc | ||
|
|
e3cfef3c8f | ||
|
|
09402bf2fc | ||
|
|
e39a968a7b | ||
|
|
b03378be7f | ||
|
|
af415e9438 | ||
|
|
90eeeeab2f | ||
|
|
f0b475fc72 | ||
|
|
f4f8c4a0b3 | ||
|
|
6f2cb460c9 | ||
|
|
46f285f6f0 | ||
|
|
6bdb8af78d | ||
|
|
04e0637fd8 | ||
|
|
b5712448a1 | ||
|
|
605d15c3cc | ||
|
|
d1479125cb | ||
|
|
2e09bc0d19 | ||
|
|
843fc6ff8f | ||
|
|
6695ff8503 | ||
|
|
80c1f375b8 | ||
|
|
5a13288d47 | ||
|
|
26201e6271 | ||
|
|
d0d7b90ba1 | ||
|
|
874624dfbe | ||
|
|
4b5cd08800 | ||
|
|
1c104afef9 | ||
|
|
ff5b8ba8e2 | ||
|
|
42d5899efd | ||
|
|
b278975c3f | ||
|
|
997e595b5b | ||
|
|
527c25b128 | ||
|
|
0e2bbda537 | ||
|
|
7f3b35593f | ||
|
|
bce6b00c43 | ||
|
|
1bbd5d51d1 | ||
|
|
b24b02fe71 | ||
|
|
2c5c4d18c4 | ||
|
|
e3f9b398f0 | ||
|
|
ab13930020 | ||
|
|
f6bb16b264 | ||
|
|
a220245d03 | ||
|
|
7462e797de | ||
|
|
36286b1fae | ||
|
|
2e8e90a9be | ||
|
|
d06a552bf6 | ||
|
|
5cb8dd5f37 | ||
|
|
7c1a3b547e | ||
|
|
2534ae8801 | ||
|
|
14a120277b | ||
|
|
c49f484743 | ||
|
|
676b39d5b1 | ||
|
|
e27dbcab2f | ||
|
|
63805c7d75 | ||
|
|
5d1c35e8aa | ||
|
|
a77f557cbf | ||
|
|
657492d921 | ||
|
|
d1d63bddba | ||
|
|
99ac4899b5 | ||
|
|
50118f305a | ||
|
|
e250dceb38 | ||
|
|
0a1b6eb63b | ||
|
|
0c76c5a5a6 | ||
|
|
2130765a57 | ||
|
|
4079274aaf | ||
|
|
26e2f795d8 | ||
|
|
d5eade5ef4 | ||
|
|
3d7985fd6d | ||
|
|
331e0ce51e | ||
|
|
8af666a4cc | ||
|
|
fed0a67917 | ||
|
|
0332d86942 | ||
|
|
8b38d32430 | ||
|
|
1e5f840a26 | ||
|
|
5981712681 | ||
|
|
dd2b85c6a5 | ||
|
|
3c0475acae | ||
|
|
416881c4c9 | ||
|
|
b91167091c | ||
|
|
497dacff41 | ||
|
|
2a1e1d1cd2 | ||
|
|
00f65b3476 | ||
|
|
470e55f8db | ||
|
|
d722962206 | ||
|
|
cee1bddbd5 | ||
|
|
e0ae913e5c | ||
|
|
1db27fcd07 | ||
|
|
95407df289 | ||
|
|
22adc2eb3c | ||
|
|
725f976b39 | ||
|
|
28ae5d4639 | ||
|
|
0f4d43e9ad | ||
|
|
28583b8ab0 | ||
|
|
1e7538a955 | ||
|
|
4258857e52 | ||
|
|
e9d8805609 | ||
|
|
fb43c5da05 | ||
|
|
326eadf0ed | ||
|
|
a5e0db4bb3 | ||
|
|
334e23343a | ||
|
|
be046a6cb2 | ||
|
|
bdee262abe | ||
|
|
3f89e668ec | ||
|
|
2fab7d4cd1 | ||
|
|
533320eb94 | ||
|
|
dfe6509472 | ||
|
|
1bde7cc8df | ||
|
|
cef05d5e2d | ||
|
|
c0dea283ba | ||
|
|
0204766e0f | ||
|
|
a336ba762c | ||
|
|
681d53c2f8 | ||
|
|
06e891c0ea | ||
|
|
b9a84350b5 | ||
|
|
44c38247da | ||
|
|
9b9af4d5e5 | ||
|
|
fd2179bdca | ||
|
|
7bb037bb9d | ||
|
|
52f70e9f4f | ||
|
|
505f69b519 | ||
|
|
b21709db40 | ||
|
|
aff7b37ef9 | ||
|
|
daa85be1ad | ||
|
|
c31718ca10 | ||
|
|
fbcfedf0e8 | ||
|
|
bd032335eb | ||
|
|
128e0f3a10 | ||
|
|
557fb9d741 | ||
|
|
b4d6ed5f5f | ||
|
|
035836da98 | ||
|
|
294039a497 | ||
|
|
b2450ef625 | ||
|
|
a81bb3e51e | ||
|
|
177fa44a49 | ||
|
|
bb506f7eb9 | ||
|
|
92657bade3 | ||
|
|
87d9cc4244 | ||
|
|
581d37b50f | ||
|
|
1a928949ce | ||
|
|
d2e3b76031 | ||
|
|
c36834b3b0 | ||
|
|
8f222b2e56 | ||
|
|
01a78e1282 | ||
|
|
be481e6fe6 | ||
|
|
e1f5fe3e6d | ||
|
|
40f754fbca | ||
|
|
cf236c6bf3 | ||
|
|
b7a38ec7b1 | ||
|
|
db26a4c18d | ||
|
|
42b55f44f4 | ||
|
|
1d3761356a | ||
|
|
79147f1cf5 | ||
|
|
caf63f0eb4 | ||
|
|
7dec2eec71 | ||
|
|
8f7145801a | ||
|
|
fdce27b8ca | ||
|
|
4056dafa7a | ||
|
|
f0b61bd5fd | ||
|
|
866e42b343 | ||
|
|
6d4cde4b02 | ||
|
|
2377596bb6 | ||
|
|
3c7c25cefa | ||
|
|
c441f681af | ||
|
|
c05951f0f9 | ||
|
|
d142252499 | ||
|
|
700daec919 | ||
|
|
d8481f3825 | ||
|
|
3539a35601 | ||
|
|
3be7bb7a79 | ||
|
|
031cdd13b2 | ||
|
|
212b321f7e | ||
|
|
1ccb88b3f0 | ||
|
|
16d680b110 | ||
|
|
6e027811ef | ||
|
|
e5df406429 | ||
|
|
e4ddb533ff | ||
|
|
4e16b21a60 | ||
|
|
dd9f1b7421 | ||
|
|
4ebec5d385 | ||
|
|
c1f3cbda3c | ||
|
|
ba3ed049d1 | ||
|
|
9238294192 | ||
|
|
83c6bfe237 | ||
|
|
07109616c8 | ||
|
|
95c8f7930e | ||
|
|
8005f0cdb0 | ||
|
|
6e0ae59ed3 | ||
|
|
1b19aa39b8 | ||
|
|
69cda58707 | ||
|
|
b20a5f554a | ||
|
|
f8d77c4daf | ||
|
|
a3d23450a8 | ||
|
|
9abee0b2ee | ||
|
|
5cf580d10b | ||
|
|
00d495d9e3 | ||
|
|
5884574765 | ||
|
|
ae5360b028 | ||
|
|
7c963515b5 | ||
|
|
8cf4cc2ea9 | ||
|
|
9388a56efa | ||
|
|
3a75fb955a | ||
|
|
01bb91612a | ||
|
|
3b25935c83 | ||
|
|
394920dfd4 | ||
|
|
85dc5bede8 | ||
|
|
8f854c61d0 | ||
|
|
e8fbe58997 | ||
|
|
d2288ee4cc | ||
|
|
5a6f76bf2c | ||
|
|
15bed6260c | ||
|
|
1423733d61 | ||
|
|
77d8f47f51 | ||
|
|
3120d28299 | ||
|
|
e6a320bb0f | ||
|
|
7d4d436efe |
@@ -23,10 +23,14 @@ pnpm-lock.yaml
|
||||
|
||||
.docusaurus
|
||||
build
|
||||
docs/docs/reference/03-core
|
||||
docs/docs/reference/04-sveltekit
|
||||
docs/pages/reference/core
|
||||
docs/pages/reference/sveltekit
|
||||
docs/pages/reference/adapter
|
||||
static
|
||||
|
||||
# TODO: Enable
|
||||
docs-nextra
|
||||
|
||||
# --------------- Packages ---------------
|
||||
|
||||
coverage
|
||||
|
||||
10
.eslintrc.js
10
.eslintrc.js
@@ -34,11 +34,11 @@ module.exports = {
|
||||
extends: ["plugin:jest/recommended"],
|
||||
env: { jest: true },
|
||||
},
|
||||
{
|
||||
files: ["docs/**"],
|
||||
plugins: ["@docusaurus"],
|
||||
extends: ["plugin:@docusaurus/recommended"],
|
||||
},
|
||||
// {
|
||||
// files: ["docs/**"],
|
||||
// plugins: ["@docusaurus"],
|
||||
// extends: ["plugin:@docusaurus/recommended"],
|
||||
// },
|
||||
{
|
||||
// TODO: Expand to all packages
|
||||
files: ["packages/{core,sveltekit}/*.ts"],
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/1_bug_framework.yml
vendored
2
.github/ISSUE_TEMPLATE/1_bug_framework.yml
vendored
@@ -30,7 +30,7 @@ body:
|
||||
Run this command in your project's root folder and paste the result:
|
||||
|
||||
```sh
|
||||
npx envinfo --system --binaries --browsers --npmPackages "next,react,next-auth"
|
||||
npx envinfo --system --binaries --browsers --npmPackages "next,react,next-auth,@auth/*"
|
||||
```
|
||||
Alternatively, you can manually gather the version information from your package.json for these packages: "next", "react" and "next-auth". Please also mention your OS and Node.js version, as well as the browser you are using.
|
||||
validations:
|
||||
|
||||
5
.github/ISSUE_TEMPLATE/2_bug_provider.yml
vendored
5
.github/ISSUE_TEMPLATE/2_bug_provider.yml
vendored
@@ -25,12 +25,14 @@ body:
|
||||
- "Custom provider"
|
||||
- "42 School"
|
||||
- "Apple"
|
||||
- "Asgardeo"
|
||||
- "Atlassian"
|
||||
- "Auth0"
|
||||
- "Authentik"
|
||||
- "Azure Active Directory"
|
||||
- "Azure Active Directory B2C"
|
||||
- "Battlenet"
|
||||
- "Beyond Identity"
|
||||
- "Box"
|
||||
- "Bungie"
|
||||
- "Cognito"
|
||||
@@ -57,6 +59,7 @@ body:
|
||||
- "Medium"
|
||||
- "Naver"
|
||||
- "Netlify"
|
||||
- "Notion"
|
||||
- "Okta"
|
||||
- "OneLogin"
|
||||
- "Osso"
|
||||
@@ -87,7 +90,7 @@ body:
|
||||
Run this command in your project's root folder and paste the result:
|
||||
|
||||
```sh
|
||||
npx envinfo --system --binaries --browsers --npmPackages "next,react,next-auth"
|
||||
npx envinfo --system --binaries --browsers --npmPackages "next,react,next-auth,@auth/*"
|
||||
```
|
||||
Alternatively, you can manually gather the version information from your package.json for these packages: "next", "react" and "next-auth". Please also mention your OS and Node.js version, as well as the browser you are using.
|
||||
validations:
|
||||
|
||||
2
.github/ISSUE_TEMPLATE/3_bug_adapter.yml
vendored
2
.github/ISSUE_TEMPLATE/3_bug_adapter.yml
vendored
@@ -44,7 +44,7 @@ body:
|
||||
Run this command in your project's root folder and paste the result:
|
||||
|
||||
```sh
|
||||
npx envinfo --system --binaries --browsers --npmPackages "next,react,next-auth" && npx envinfo --npmPackages "@next-auth/*"
|
||||
npx envinfo --system --binaries --browsers --npmPackages "next,react,next-auth,@auth/*" && npx envinfo --npmPackages "@next-auth/*"
|
||||
```
|
||||
Alternatively, if the above command did not work, we need the version of the following packages from your package.json: "next", "react", "next-auth" and your adapter. Please also mention your OS and Node.js version, as well as the browser you are using.
|
||||
validations:
|
||||
|
||||
2
.github/actions/issue-validator/index.mjs
vendored
2
.github/actions/issue-validator/index.mjs
vendored
File diff suppressed because one or more lines are too long
4
.github/actions/issue-validator/repro.md
vendored
4
.github/actions/issue-validator/repro.md
vendored
@@ -14,9 +14,9 @@ Ensure the link is pointing to a codebase that is accessible (e.g. not a private
|
||||
|
||||
### **What happens if I don't provide a sufficient minimal reproduction?**
|
||||
|
||||
Issues with the `incomplete` label that receives no meaningful activity (e.g. new comments with a reproduction link) are automatically closed and locked after 30 days.
|
||||
Issues with the `incomplete` label that receives no meaningful activity (e.g. new comments with a reproduction link) are closed after 7 days.
|
||||
|
||||
If your issue has _not_ been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction.
|
||||
If your issue has _not_ been resolved in that time and it has been closed/locked, please open a new issue with the required reproduction. (It's less likely that we check back on already closed issues.)
|
||||
|
||||
### **I did not open this issue, but it is relevant to me, what can I do to help?**
|
||||
|
||||
|
||||
12
.github/actions/issue-validator/src/index.mjs
vendored
12
.github/actions/issue-validator/src/index.mjs
vendored
@@ -41,13 +41,7 @@ async function run() {
|
||||
label: { name: newLabel },
|
||||
} = payload
|
||||
|
||||
if (
|
||||
pull_request ||
|
||||
!issue?.body ||
|
||||
!process.env.GITHUB_TOKEN ||
|
||||
!process.env.GITHUB_ACTION_PATH
|
||||
)
|
||||
return
|
||||
if (pull_request || !issue?.body || !process.env.GITHUB_TOKEN) return
|
||||
|
||||
const labels = issue.labels.map((l) => l.name)
|
||||
// const isBugReport =
|
||||
@@ -78,7 +72,9 @@ async function run() {
|
||||
client.issues.createComment({
|
||||
...issueCommon,
|
||||
body: readFileSync(
|
||||
join(process.env.GITHUB_ACTION_PATH, "repro.md"),
|
||||
join(
|
||||
"/home/runner/work/next-auth/next-auth/.github/actions/issue-validator/repro.md"
|
||||
),
|
||||
"utf8"
|
||||
),
|
||||
}),
|
||||
|
||||
2
.github/pr-labeler.yml
vendored
2
.github/pr-labeler.yml
vendored
@@ -2,7 +2,7 @@
|
||||
adapters: ["packages/core/src/adapters.ts", "packages/adapter-*/**/*"]
|
||||
core: ["packages/core/src/**/*"]
|
||||
dgraph: ["packages/adapter-dgraph/**/*"]
|
||||
documentation: ["packages/docs/docs/**/*"]
|
||||
documentation: ["packages/docs/pages/**/*"]
|
||||
dynamodb: ["packages/adapter-dynamodb/**/*"]
|
||||
examples: ["apps/examples/**/*"]
|
||||
fauna: ["packages/adapter-fauna/**/*"]
|
||||
|
||||
15
.github/sync.yml
vendored
15
.github/sync.yml
vendored
@@ -7,15 +7,12 @@ nextauthjs/sveltekit-auth-example:
|
||||
- .github/FUNDING.yml
|
||||
- LICENSE
|
||||
|
||||
# FIXME: Should re-enable, but currently fails:
|
||||
# https://github.com/nextauthjs/next-auth/actions/runs/3811709391/jobs/6484533340
|
||||
# (issue seems to be the name of the target repo)
|
||||
# nextauthjs/solid-start-auth-example:
|
||||
# - source: "apps/examples/solid-start"
|
||||
# dest: .
|
||||
# deleteOrphaned: true
|
||||
# - .github/FUNDING.yml
|
||||
# - LICENSE
|
||||
nextauthjs/solid-start-auth-example:
|
||||
- source: "apps/examples/solid-start"
|
||||
dest: .
|
||||
deleteOrphaned: true
|
||||
- .github/FUNDING.yml
|
||||
- LICENSE
|
||||
|
||||
nextauthjs/next-auth-gatsby-example:
|
||||
- source: apps/playgrounds/gatsby
|
||||
|
||||
2
.github/workflows/issue-validator.yml
vendored
2
.github/workflows/issue-validator.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
||||
- uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
- name: "Run issue validator"
|
||||
- name: Run issue validator
|
||||
run: node /home/runner/work/next-auth/next-auth/.github/actions/issue-validator/index.mjs
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
27
.github/workflows/release.yml
vendored
27
.github/workflows/release.yml
vendored
@@ -3,10 +3,10 @@ name: Release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
- "beta"
|
||||
- "next"
|
||||
- "3.x"
|
||||
- main
|
||||
- beta
|
||||
- next
|
||||
- 3.x
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
@@ -24,7 +24,6 @@ jobs:
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: "pnpm"
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
- name: Run tests
|
||||
@@ -35,6 +34,22 @@ jobs:
|
||||
UPSTASH_REDIS_KEY: ${{ secrets.UPSTASH_REDIS_KEY }}
|
||||
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
# - name: Run E2E tests
|
||||
# if: github.repository == 'nextauthjs/next-auth'
|
||||
# run: pnpm e2e
|
||||
# timeout-minutes: 15
|
||||
# env:
|
||||
# AUTH0_USERNAME: ${{ secrets.AUTH0_USERNAME }}
|
||||
# AUTH0_PASSWORD: ${{ secrets.AUTH0_PASSWORD }}
|
||||
# TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
|
||||
# TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
|
||||
# - name: Upload E2E artifacts
|
||||
# if: github.repository == 'nextauthjs/next-auth'
|
||||
# uses: actions/upload-artifact@v3
|
||||
# with:
|
||||
# name: playwright-report
|
||||
# path: apps/dev/nextjs/playwright-report/
|
||||
# retention-days: 30
|
||||
# - name: Coverage
|
||||
# uses: codecov/codecov-action@v1
|
||||
# with:
|
||||
@@ -58,7 +73,6 @@ jobs:
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: "pnpm"
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
- name: Publish to npm and GitHub
|
||||
@@ -83,7 +97,6 @@ jobs:
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: "pnpm"
|
||||
- name: Install dependencies
|
||||
run: pnpm install
|
||||
- name: Determine version
|
||||
|
||||
6
.github/workflows/sync-examples.yml
vendored
6
.github/workflows/sync-examples.yml
vendored
@@ -11,9 +11,9 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Run GitHub File Sync
|
||||
# Can update to v1 when https://github.com/BetaHuhn/repo-file-sync-action/issues/168 is resolved
|
||||
uses: BetaHuhn/repo-file-sync-action@v1.16.5
|
||||
uses: balazsorban44/repo-file-sync-action@master
|
||||
with:
|
||||
GH_PAT: ${{ secrets.GH_PAT_CLASSIC }}
|
||||
GH_PAT: ${{ secrets.GH_PAT }}
|
||||
IS_FINE_GRAINED: true
|
||||
SKIP_PR: true
|
||||
ORIGINAL_MESSAGE: true
|
||||
|
||||
25
.gitignore
vendored
25
.gitignore
vendored
@@ -1,6 +1,5 @@
|
||||
# Misc
|
||||
.DS_Store
|
||||
.npmrc
|
||||
.eslintcache
|
||||
.env
|
||||
.env.local
|
||||
@@ -12,8 +11,9 @@ npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
firebase-debug.log
|
||||
ui-debug.log
|
||||
.pnpm-debug.log
|
||||
|
||||
.husky
|
||||
|
||||
# Dependencies
|
||||
node_modules
|
||||
@@ -34,13 +34,10 @@ packages/next-auth/utils
|
||||
packages/next-auth/core
|
||||
packages/next-auth/jwt
|
||||
packages/next-auth/react
|
||||
packages/next-auth/adapters.d.ts
|
||||
packages/next-auth/adapters.js
|
||||
packages/next-auth/index.d.ts
|
||||
packages/next-auth/index.js
|
||||
packages/next-auth/next
|
||||
packages/next-auth/middleware.d.ts
|
||||
packages/next-auth/middleware.js
|
||||
packages/*/*.js
|
||||
packages/*/*.d.ts
|
||||
packages/*/*.d.ts.map
|
||||
|
||||
# Development app
|
||||
apps/dev/src/css
|
||||
@@ -81,14 +78,11 @@ docs/.docusaurus
|
||||
docs/providers.json
|
||||
|
||||
# Core
|
||||
packages/core/*.js
|
||||
packages/core/*.d.ts
|
||||
packages/core/*.d.ts.map
|
||||
packages/core/src/providers/oauth-types.ts
|
||||
packages/core/lib
|
||||
packages/core/providers
|
||||
packages/core/src/lib/pages/styles.ts
|
||||
docs/docs/reference/03-core
|
||||
docs/docs/reference/04-sveltekit
|
||||
docs/pages/reference/core
|
||||
|
||||
|
||||
# SvelteKit
|
||||
@@ -98,3 +92,8 @@ packages/frameworks-sveltekit/.svelte-kit
|
||||
packages/frameworks-sveltekit/package
|
||||
packages/frameworks-sveltekit/vite.config.js.timestamp-*
|
||||
packages/frameworks-sveltekit/vite.config.ts.timestamp-*
|
||||
docs/pages/reference/sveltekit
|
||||
|
||||
# Adapters
|
||||
|
||||
docs/pages/reference/adapter
|
||||
@@ -13,16 +13,14 @@ pnpm-lock.yaml
|
||||
*.d.ts.map
|
||||
|
||||
.svelte-kit
|
||||
.next
|
||||
.nuxt
|
||||
|
||||
# --------------- Docs ---------------
|
||||
|
||||
.docusaurus
|
||||
build
|
||||
docs/docs/reference/03-core
|
||||
docs/docs/reference/04-sveltekit
|
||||
static
|
||||
.next
|
||||
docs/pages/reference/core
|
||||
docs/pages/reference/sveltekit
|
||||
docs/pages/reference/adapter
|
||||
docs/providers.json
|
||||
|
||||
# --------------- Packages ---------------
|
||||
|
||||
@@ -7,7 +7,7 @@ module.exports = {
|
||||
overrides: [
|
||||
{
|
||||
files: [
|
||||
"apps/dev/pages/api/auth/[...nextauth].ts",
|
||||
"apps/dev/nextjs/pages/api/auth/[...nextauth].ts",
|
||||
"docs/{sidebars,docusaurus.config}.js",
|
||||
],
|
||||
options: { printWidth: 150 },
|
||||
|
||||
@@ -9,20 +9,39 @@ NEXTAUTH_URL=http://localhost:3000
|
||||
# and/or verification tokens.
|
||||
NEXTAUTH_SECRET=secret
|
||||
|
||||
ASGARDEO_CLIENT_ID=
|
||||
ASGARDEO_CLIENT_SECRET=
|
||||
ASGARDEO_ISSUER=
|
||||
|
||||
AUTH0_ID=
|
||||
AUTH0_SECRET=
|
||||
AUTH0_ISSUER=
|
||||
|
||||
KEYCLOAK_ID=
|
||||
KEYCLOAK_SECRET=
|
||||
KEYCLOAK_ISSUER=
|
||||
# Beyond Identity Provider
|
||||
BEYOND_IDENTITY_CLIENT_ID=
|
||||
BEYOND_IDENTITY_CLIENT_SECRET=
|
||||
BEYOND_IDENTITY_ISSUER=
|
||||
|
||||
GITHUB_ID=
|
||||
GITHUB_SECRET=
|
||||
|
||||
NOTION_ID=
|
||||
NOTION_SECRET=
|
||||
NOTION_REDIRECT_URI=
|
||||
|
||||
IDS4_ID=
|
||||
IDS4_SECRET=
|
||||
IDS4_ISSUER=
|
||||
|
||||
GITHUB_ID=
|
||||
GITHUB_SECRET=
|
||||
KEYCLOAK_ID=
|
||||
KEYCLOAK_SECRET=
|
||||
KEYCLOAK_ISSUER=
|
||||
|
||||
LINE_ID=
|
||||
LINE_SECRET=
|
||||
|
||||
TRAKT_ID=
|
||||
TRAKT_SECRET=
|
||||
|
||||
TWITCH_ID=
|
||||
TWITCH_SECRET=
|
||||
@@ -30,11 +49,8 @@ TWITCH_SECRET=
|
||||
TWITTER_ID=
|
||||
TWITTER_SECRET=
|
||||
|
||||
LINE_ID=
|
||||
LINE_SECRET=
|
||||
|
||||
TRAKT_ID=
|
||||
TRAKT_SECRET=
|
||||
WIKIMEDIA_ID=
|
||||
WIKIMEDIA_SECRET=
|
||||
|
||||
# Example configuration for a Gmail account (will need SMTP enabled)
|
||||
EMAIL_SERVER=smtps://user@gmail.com:password@smtp.gmail.com:465
|
||||
@@ -47,12 +63,9 @@ EMAIL_FROM=user@gmail.com
|
||||
# MongoDB: DATABASE_URL=mongodb://nextauth:password@127.0.0.1:27017/nextauth?synchronize=true
|
||||
DATABASE_URL=
|
||||
|
||||
WIKIMEDIA_ID=
|
||||
WIKIMEDIA_SECRET=
|
||||
|
||||
# Supabase Example Configuration
|
||||
# Supabase Example Configuration
|
||||
# NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321
|
||||
# SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSJ9.vI9obAHOGyVVKa3pD--kJlyxp-Z2zV9UUMAhKpNLAcU
|
||||
# SUPABASE_JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long
|
||||
# NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs
|
||||
# NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24ifQ.625_WdcF3KHqz5amU0x2X5WWHP-OEs_4qj0ssLNHzTs
|
||||
|
||||
4
apps/dev/nextjs/.gitignore
vendored
Normal file
4
apps/dev/nextjs/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
node_modules/
|
||||
/test-results/
|
||||
/playwright-report/
|
||||
/playwright/.cache/
|
||||
@@ -1,5 +1,5 @@
|
||||
import Link from "next/link"
|
||||
import { signIn, signOut, useSession } from "next-auth/react"
|
||||
import { useSession } from "next-auth/react"
|
||||
import styles from "./header.module.css"
|
||||
|
||||
// The approach used in this component shows how to built a sign in and sign out
|
||||
@@ -24,14 +24,7 @@ export default function Header() {
|
||||
<span className={styles.notSignedInText}>
|
||||
You are not signed in
|
||||
</span>
|
||||
<a
|
||||
href="/api/auth/signin"
|
||||
className={styles.buttonPrimary}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
signIn()
|
||||
}}
|
||||
>
|
||||
<a href="/api/auth/signin" className={styles.buttonPrimary}>
|
||||
Sign in
|
||||
</a>
|
||||
</>
|
||||
@@ -47,14 +40,7 @@ export default function Header() {
|
||||
<strong>{session.user.email} </strong>
|
||||
{session.user.name ? `(${session.user.name})` : null}
|
||||
</span>
|
||||
<a
|
||||
href="/api/auth/signout"
|
||||
className={styles.button}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
signOut()
|
||||
}}
|
||||
>
|
||||
<a href="/api/auth/signout" className={styles.button}>
|
||||
Sign out
|
||||
</a>
|
||||
</>
|
||||
|
||||
@@ -9,10 +9,12 @@
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"email": "fake-smtp-server",
|
||||
"start:email": "pnpm email"
|
||||
"start:email": "pnpm email",
|
||||
"e2e": "pnpm dlx playwright test"
|
||||
},
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@auth/core": "workspace:*",
|
||||
"@next-auth/fauna-adapter": "workspace:*",
|
||||
"@next-auth/prisma-adapter": "workspace:*",
|
||||
"@next-auth/supabase-adapter": "workspace:*",
|
||||
@@ -22,15 +24,16 @@
|
||||
"faunadb": "^4",
|
||||
"next": "13.1.1",
|
||||
"next-auth": "workspace:*",
|
||||
"@auth/core": "workspace:*",
|
||||
"nodemailer": "^6",
|
||||
"react": "^18",
|
||||
"react-dom": "^18"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.29.2",
|
||||
"@types/jsonwebtoken": "^8.5.5",
|
||||
"@types/react": "^18.0.15",
|
||||
"@types/react-dom": "^18.0.6",
|
||||
"dotenv": "^16.0.3",
|
||||
"fake-smtp-server": "^0.8.0",
|
||||
"pg": "^8.7.3",
|
||||
"prisma": "^3",
|
||||
|
||||
@@ -2,9 +2,11 @@ import { Auth, type AuthConfig } from "@auth/core"
|
||||
|
||||
// Providers
|
||||
import Apple from "@auth/core/providers/apple"
|
||||
import Asgardeo from "@auth/core/providers/asgardeo"
|
||||
import Auth0 from "@auth/core/providers/auth0"
|
||||
import AzureAD from "@auth/core/providers/azure-ad"
|
||||
import AzureB2C from "@auth/core/providers/azure-ad-b2c"
|
||||
import BeyondIdentity from "@auth/core/providers/beyondidentity"
|
||||
import BoxyHQSAML from "@auth/core/providers/boxyhq-saml"
|
||||
// import Cognito from "@auth/core/providers/cognito"
|
||||
import Credentials from "@auth/core/providers/credentials"
|
||||
@@ -23,6 +25,7 @@ import Instagram from "@auth/core/providers/instagram"
|
||||
import Line from "@auth/core/providers/line"
|
||||
import LinkedIn from "@auth/core/providers/linkedin"
|
||||
import Mailchimp from "@auth/core/providers/mailchimp"
|
||||
import Notion from "@auth/core/providers/notion"
|
||||
// import Okta from "@auth/core/providers/okta"
|
||||
import Osu from "@auth/core/providers/osu"
|
||||
import Patreon from "@auth/core/providers/patreon"
|
||||
@@ -68,7 +71,7 @@ import WorkOS from "@auth/core/providers/workos"
|
||||
|
||||
export const authConfig: AuthConfig = {
|
||||
// adapter,
|
||||
// debug: process.env.NODE_ENV !== "production",
|
||||
debug: process.env.NODE_ENV !== "production",
|
||||
theme: {
|
||||
logo: "https://next-auth.js.org/img/logo/logo-sm.png",
|
||||
brandColor: "#1786fb",
|
||||
@@ -82,6 +85,7 @@ export const authConfig: AuthConfig = {
|
||||
},
|
||||
}),
|
||||
Apple({ clientId: process.env.APPLE_ID, clientSecret: process.env.APPLE_SECRET }),
|
||||
Asgardeo({ clientId: process.env.ASGARDEO_CLIENT_ID, clientSecret: process.env.ASGARDEO_CLIENT_SECRET, issuer: process.env.ASGARDEO_ISSUER }),
|
||||
Auth0({ clientId: process.env.AUTH0_ID, clientSecret: process.env.AUTH0_SECRET, issuer: process.env.AUTH0_ISSUER }),
|
||||
AzureAD({
|
||||
clientId: process.env.AZURE_AD_CLIENT_ID,
|
||||
@@ -89,6 +93,7 @@ export const authConfig: AuthConfig = {
|
||||
tenantId: process.env.AZURE_AD_TENANT_ID,
|
||||
}),
|
||||
AzureB2C({ clientId: process.env.AZURE_B2C_ID, clientSecret: process.env.AZURE_B2C_SECRET, issuer: process.env.AZURE_B2C_ISSUER }),
|
||||
BeyondIdentity({ clientId: process.env.BEYOND_IDENTITY_CLIENT_ID, clientSecret: process.env.BEYOND_IDENTITY_CLIENT_SECRET, issuer: process.env.BEYOND_IDENTITY_ISSUER }),
|
||||
BoxyHQSAML({ issuer: "https://jackson-demo.boxyhq.com", clientId: "tenant=boxyhq.com&product=saml-demo.boxyhq.com", clientSecret: "dummy" }),
|
||||
// Cognito({ clientId: process.env.COGNITO_ID, clientSecret: process.env.COGNITO_SECRET, issuer: process.env.COGNITO_ISSUER }),
|
||||
Discord({ clientId: process.env.DISCORD_ID, clientSecret: process.env.DISCORD_SECRET }),
|
||||
@@ -105,6 +110,7 @@ export const authConfig: AuthConfig = {
|
||||
Line({ clientId: process.env.LINE_ID, clientSecret: process.env.LINE_SECRET }),
|
||||
LinkedIn({ clientId: process.env.LINKEDIN_ID, clientSecret: process.env.LINKEDIN_SECRET }),
|
||||
Mailchimp({ clientId: process.env.MAILCHIMP_ID, clientSecret: process.env.MAILCHIMP_SECRET }),
|
||||
Notion({ clientId: process.env.NOTION_ID, clientSecret: process.env.NOTION_SECRET, redirectUri: process.env.NOTION_REDIRECT_URI }),
|
||||
// Okta({ clientId: process.env.OKTA_ID, clientSecret: process.env.OKTA_SECRET, issuer: process.env.OKTA_ISSUER }),
|
||||
Osu({ clientId: process.env.OSU_CLIENT_ID, clientSecret: process.env.OSU_CLIENT_SECRET }),
|
||||
Patreon({ clientId: process.env.PATREON_ID, clientSecret: process.env.PATREON_SECRET }),
|
||||
|
||||
107
apps/dev/nextjs/playwright.config.ts
Normal file
107
apps/dev/nextjs/playwright.config.ts
Normal file
@@ -0,0 +1,107 @@
|
||||
import type { PlaywrightTestConfig } from '@playwright/test';
|
||||
import { devices } from '@playwright/test';
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
* https://github.com/motdotla/dotenv
|
||||
*/
|
||||
require('dotenv').config();
|
||||
|
||||
/**
|
||||
* See https://playwright.dev/docs/test-configuration.
|
||||
*/
|
||||
const config: PlaywrightTestConfig = {
|
||||
testDir: './tests',
|
||||
/* Maximum time one test can run for. */
|
||||
timeout: 30 * 1000,
|
||||
expect: {
|
||||
/**
|
||||
* Maximum time expect() should wait for the condition to be met.
|
||||
* For example in `await expect(locator).toHaveText();`
|
||||
*/
|
||||
timeout: 5000
|
||||
},
|
||||
/* Run tests in files in parallel */
|
||||
fullyParallel: true,
|
||||
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
||||
forbidOnly: !!process.env.CI,
|
||||
/* Retry on CI only */
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
/* Opt out of parallel tests on CI. */
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
||||
reporter: 'html',
|
||||
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
|
||||
use: {
|
||||
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
|
||||
actionTimeout: 0,
|
||||
/* Base URL to use in actions like `await page.goto('/')`. */
|
||||
// baseURL: 'http://localhost:3000',
|
||||
|
||||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
||||
trace: 'on-first-retry',
|
||||
},
|
||||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: 'firefox',
|
||||
use: {
|
||||
...devices['Desktop Firefox'],
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
name: 'webkit',
|
||||
use: {
|
||||
...devices['Desktop Safari'],
|
||||
},
|
||||
},
|
||||
|
||||
/* Test against mobile viewports. */
|
||||
// {
|
||||
// name: 'Mobile Chrome',
|
||||
// use: {
|
||||
// ...devices['Pixel 5'],
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile Safari',
|
||||
// use: {
|
||||
// ...devices['iPhone 12'],
|
||||
// },
|
||||
// },
|
||||
|
||||
/* Test against branded browsers. */
|
||||
// {
|
||||
// name: 'Microsoft Edge',
|
||||
// use: {
|
||||
// channel: 'msedge',
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: 'Google Chrome',
|
||||
// use: {
|
||||
// channel: 'chrome',
|
||||
// },
|
||||
// },
|
||||
],
|
||||
|
||||
/* Folder for test artifacts such as screenshots, videos, traces, etc. */
|
||||
// outputDir: 'test-results/',
|
||||
|
||||
/* Run your local dev server before starting the tests */
|
||||
// webServer: {
|
||||
// command: 'npm run start',
|
||||
// port: 3000,
|
||||
// },
|
||||
};
|
||||
|
||||
export default config;
|
||||
39
apps/dev/nextjs/tests/signin.spec.ts
Normal file
39
apps/dev/nextjs/tests/signin.spec.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { test, expect } from "@playwright/test"
|
||||
|
||||
test("Sign in with Auth0", async ({ page }) => {
|
||||
// Go to NextAuth example app
|
||||
await page.goto("https://next-auth-example.vercel.app")
|
||||
|
||||
// Click 'Sign In'
|
||||
await page.click("#__next > header > div > p > a")
|
||||
|
||||
// Auth0 Login Provider
|
||||
await page.click('body > div > div form[action*="auth0"] > button')
|
||||
|
||||
// Enter Credentials (Username/Password Login) on Auth0 Widget
|
||||
await page.type("#username", process.env.AUTH0_USERNAME!)
|
||||
await page.type("#password", process.env.AUTH0_PASSWORD!)
|
||||
|
||||
// Snap a screenshot
|
||||
// await page.screenshot({ path: "1-auth0-login.png", fullPage: true })
|
||||
|
||||
// Press submit on Auth0 form
|
||||
await page.click('body > div > main > section > div button[type="submit"]')
|
||||
|
||||
// Wait for next-auth example page login status header to appear
|
||||
await page.waitForTimeout(2000)
|
||||
|
||||
// Snap a screenshot
|
||||
// await page.screenshot({
|
||||
// path: "2-next-auth-redirect-result.png",
|
||||
// fullPage: false,
|
||||
// })
|
||||
|
||||
// Check session object after successful login
|
||||
const response = await page.goto(
|
||||
"https://next-auth-example.vercel.app/api/auth/session"
|
||||
)
|
||||
const session = await response?.json()
|
||||
expect(session?.user?.email).toBe(process.env.AUTH0_USERNAME)
|
||||
// TODO: Check whole object with .toEqual()
|
||||
})
|
||||
@@ -19,8 +19,8 @@
|
||||
"vite": "4.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/core": "latest",
|
||||
"@auth/sveltekit": "latest"
|
||||
"@auth/core": "workspace:*",
|
||||
"@auth/sveltekit": "workspace:*"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
> The example repository is maintained from a [monorepo](https://github.com/nextauthjs/next-auth/tree/main/apps/example-nextjs). Pull Requests should be opened against [`nextauthjs/next-auth`](https://github.com/nextauthjs/next-auth).
|
||||
> The example repository is maintained from a [monorepo](https://github.com/nextauthjs/next-auth/tree/main/apps/examples/nextjs). Pull Requests should be opened against [`nextauthjs/next-auth`](https://github.com/nextauthjs/next-auth).
|
||||
|
||||
<p align="center">
|
||||
<br/>
|
||||
<a href="https://next-auth.js.org" target="_blank"><img width="150px" src="https://next-auth.js.org/img/logo/logo-sm.png" /></a>
|
||||
<h3 align="center">NextAuth.js Example App</h3>
|
||||
<a href="https://authjs.dev" target="_blank">
|
||||
<img height="64" src="https://authjs.dev/img/logo/logo-sm.png" />
|
||||
</a>
|
||||
<a href="https://nextjs.org" target="_blank">
|
||||
<img height="64" src="https://nextjs.org/static/favicon/android-chrome-192x192.png" />
|
||||
</a>
|
||||
<h3 align="center"><b>NextAuth.js</b> - Example App</h3>
|
||||
<p align="center">
|
||||
Open Source. Full Stack. Own Your Data.
|
||||
</p>
|
||||
@@ -25,20 +30,14 @@
|
||||
|
||||
## Overview
|
||||
|
||||
NextAuth.js is a complete open source authentication solution.
|
||||
NextAuth.js is a complete open-source authentication solution.
|
||||
|
||||
This is an example application that shows how `next-auth` is applied to a basic Next.js app.
|
||||
|
||||
The deployed version can be found at [`next-auth-example.vercel.app`](https://next-auth-example.vercel.app)
|
||||
|
||||
### About NextAuth.js
|
||||
|
||||
NextAuth.js is an easy to implement, full-stack (client/server) open source authentication library originally designed for [Next.js](https://nextjs.org) and [Serverless](https://vercel.com). Our goal is to [support even more frameworks](https://github.com/nextauthjs/next-auth/issues/2294) in the future.
|
||||
|
||||
Go to [next-auth.js.org](https://next-auth.js.org) for more information and documentation.
|
||||
|
||||
> _NextAuth.js is not officially associated with Vercel or Next.js._
|
||||
|
||||
## Getting Started
|
||||
|
||||
### 1. Clone the repository and install dependencies
|
||||
@@ -98,15 +97,13 @@ npm run start
|
||||
|
||||
### 5. Preparing for Production
|
||||
|
||||
Follow the [Deployment documentation](https://next-auth.js.org/deployment)
|
||||
Follow the [Deployment documentation](https://authjs.dev/guides/basics/deployment) or deploy the example instantly using [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=next-auth-example)
|
||||
|
||||
[](https://vercel.com/new/git/external?repository-url=https://github.com/nextauthjs/next-auth-example&project-name=next-auth-example&repository-name=next-auth-example)
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
<a href="https://vercel.com?utm_source=nextauthjs&utm_campaign=oss">
|
||||
<img width="170px" src="https://raw.githubusercontent.com/nextauthjs/next-auth/canary/www/static/img/powered-by-vercel.svg" alt="Powered By Vercel" />
|
||||
<img width="170px" src="https://raw.githubusercontent.com/nextauthjs/next-auth/main/docs/static/img/powered-by-vercel.svg" alt="Powered By Vercel" />
|
||||
</a>
|
||||
<p align="left">Thanks to Vercel sponsoring this project by allowing it to be deployed for free for the entire NextAuth.js Team</p>
|
||||
|
||||
## License
|
||||
|
||||
ISC
|
||||
<p align="left">Thanks to Vercel sponsoring this project by allowing it to be deployed for free for the entire Auth.js Team</p>
|
||||
@@ -3,9 +3,10 @@ import { authOptions } from "./api/auth/[...nextauth]"
|
||||
import Layout from "../components/layout"
|
||||
|
||||
import type { GetServerSidePropsContext } from "next"
|
||||
import type { Session } from "next-auth"
|
||||
import { useSession } from "next-auth/react"
|
||||
|
||||
export default function ServerSidePage({ session }: { session: Session }) {
|
||||
export default function ServerSidePage() {
|
||||
const { data: session } = useSession()
|
||||
// As this page uses Server Side Rendering, the `session` will be already
|
||||
// populated on render without needing to go through a loading stage.
|
||||
return (
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# Create JD App
|
||||
|
||||
This project was created using [Create JD App](https://github.com/OrJDev/create-jd-app)
|
||||
|
||||
## Deploying To Vercel
|
||||
|
||||
### Installing
|
||||
|
||||
```bash
|
||||
npm install solid-start-vercel@latest -D
|
||||
```
|
||||
|
||||
### Adding to vite config
|
||||
|
||||
```ts
|
||||
import solid from "solid-start/vite";
|
||||
import dotenv from "dotenv";
|
||||
import { defineConfig } from "vite";
|
||||
// @ts-expect-error no typing
|
||||
import vercel from "solid-start-vercel";
|
||||
|
||||
export default defineConfig(() => {
|
||||
dotenv.config();
|
||||
return {
|
||||
plugins: [solid({ ssr: true, adapter: vercel({ edge: false }) })],
|
||||
};
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
### Enviroment Variables
|
||||
|
||||
- `ENABLE_VC_BUILD`=`1` .
|
||||
|
||||
### You Are Done
|
||||
|
||||
Create a github repo and push your code to it, then deploy it to vercel (:
|
||||
85
apps/examples/solid-start/README.md
Normal file
85
apps/examples/solid-start/README.md
Normal file
@@ -0,0 +1,85 @@
|
||||
> The example repository is maintained from a [monorepo](https://github.com/nextauthjs/next-auth/tree/main/apps/examples/solid-start). Pull Requests should be opened against [`nextauthjs/next-auth`](https://github.com/nextauthjs/next-auth).
|
||||
|
||||
<p align="center">
|
||||
<br/>
|
||||
<a href="https://authjs.dev" target="_blank">
|
||||
<img height="64" src="https://authjs.dev/img/logo/logo-sm.png" />
|
||||
</a>
|
||||
<a href="https://start.solidjs.com" target="_blank">
|
||||
<img height="64" src="https://www.solidjs.com/assets/logo-123b04bc.svg" />
|
||||
</a>
|
||||
<h3 align="center"><b>SolidStart Auth</b> - Example App</h3>
|
||||
<p align="center">
|
||||
Open Source. Full Stack. Own Your Data.
|
||||
</p>
|
||||
<p align="center" style="align: center;">
|
||||
<a href="https://npm.im/@auth/solid-start">
|
||||
<img alt="npm" src="https://img.shields.io/npm/v/@auth/solid-start?color=green&label=@auth/solid-start&style=flat-square">
|
||||
</a>
|
||||
<a href="https://bundlephobia.com/result?p=@auth/solid-start">
|
||||
<img src="https://img.shields.io/bundlephobia/minzip/@auth/solid-start?label=size&style=flat-square" alt="Bundle Size"/>
|
||||
</a>
|
||||
<a href="https://www.npmtrends.com/@auth/solid-start">
|
||||
<img src="https://img.shields.io/npm/dm/@auth/solid-start?label=downloads&style=flat-square" alt="Downloads" />
|
||||
</a>
|
||||
<a href="https://npm.im/@auth/solid-start">
|
||||
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
|
||||
</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
## Overview
|
||||
|
||||
This is the official SolidStart Auth example for [Auth.js](https://authjs.dev).
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
You can follow the guide below, or click the following button to deploy this example to [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=solid-start-auth-example).
|
||||
|
||||
[](https://vercel.com/new/git/external?repository-url=https://github.com/nextauthjs/solid-start-auth-example&project-name=solid-start-auth-example&repository-name=solid-start-auth-example)
|
||||
|
||||
### Installing
|
||||
|
||||
```sh
|
||||
pnpm add -D solid-start-vercel
|
||||
```
|
||||
```sh
|
||||
npm i -D solid-start-vercel
|
||||
```
|
||||
```sh
|
||||
yarn add -D solid-start-vercel
|
||||
```
|
||||
|
||||
### Adding to Vite config
|
||||
|
||||
```ts
|
||||
import solid from "solid-start/vite";
|
||||
import dotenv from "dotenv";
|
||||
import { defineConfig } from "vite";
|
||||
// @ts-expect-error no typing
|
||||
import vercel from "solid-start-vercel";
|
||||
|
||||
export default defineConfig(() => {
|
||||
dotenv.config();
|
||||
return {
|
||||
plugins: [solid({ ssr: true, adapter: vercel({ edge: false }) })],
|
||||
};
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
### Environment Variables
|
||||
|
||||
- `ENABLE_VC_BUILD`=`1` .
|
||||
|
||||
### Finishing up
|
||||
|
||||
Create a GitHub repo and push the code to it, then deploy it to Vercel.
|
||||
|
||||
## Acknowledgements
|
||||
|
||||
<a href="https://vercel.com?utm_source=nextauthjs&utm_campaign=oss">
|
||||
<img width="170px" src="https://raw.githubusercontent.com/nextauthjs/next-auth/main/docs/static/img/powered-by-vercel.svg" alt="Powered By Vercel" />
|
||||
</a>
|
||||
<p align="left">Thanks to Vercel sponsoring this project by allowing it to be deployed for free for the entire Auth.js Team</p>
|
||||
@@ -17,7 +17,7 @@
|
||||
"vite": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/core": "^0.1.4",
|
||||
"@auth/core": "latest",
|
||||
"@solid-auth/next": "^0.0.19",
|
||||
"@solidjs/meta": "^0.28.0",
|
||||
"@solidjs/router": "^0.6.0",
|
||||
|
||||
@@ -29,7 +29,7 @@ const Home: ParentComponent = () => {
|
||||
</A>{" "}
|
||||
with{" "}
|
||||
<A
|
||||
href="https://authjs.dev/reference/solid-start/modules/main"
|
||||
href="https://authjs.dev/reference/solidstart"
|
||||
class="text-blue-500 underline font-bold"
|
||||
>
|
||||
SolidStart Auth
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Protected } from "~/components";
|
||||
export const { routeData, Page } = Protected((session) => {
|
||||
return (
|
||||
<main class="flex flex-col gap-2 items-center">
|
||||
<h1>This is a proteced route</h1>
|
||||
<h1>This is a protected route</h1>
|
||||
</main>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
> The example repository is maintained from a [monorepo](https://github.com/nextauthjs/next-auth/tree/main/apps/example-sveltekit). Pull Requests should be opened against [`nextauthjs/next-auth`](https://github.com/nextauthjs/next-auth).
|
||||
> The example repository is maintained from a [monorepo](https://github.com/nextauthjs/next-auth/tree/main/apps/examples/sveltekit). Pull Requests should be opened against [`nextauthjs/next-auth`](https://github.com/nextauthjs/next-auth).
|
||||
|
||||
<p align="center">
|
||||
<br/>
|
||||
<a href="https://authjs.dev" target="_blank"><img width="150px" src="https://authjs.dev/img/logo/logo-sm.png" /></a>
|
||||
<h3 align="center">Auth.js Example App with <a href="https://kit.svelte.dev">SvelteKit</a></h3>
|
||||
<a href="https://authjs.dev" target="_blank">
|
||||
<img height="64" src="https://authjs.dev/img/logo/logo-sm.png" />
|
||||
</a>
|
||||
<a href="https://kit.svelte.dev" target="_blank">
|
||||
<img height="64" src="https://upload.wikimedia.org/wikipedia/commons/1/1b/Svelte_Logo.svg" />
|
||||
</a>
|
||||
<h3 align="center"><b>SvelteKit Auth</b> - Example App</h3>
|
||||
<p align="center">
|
||||
Open Source. Full Stack. Own Your Data.
|
||||
</p>
|
||||
@@ -11,18 +16,24 @@
|
||||
<a href="https://npm.im/@auth/sveltekit">
|
||||
<img alt="npm" src="https://img.shields.io/npm/v/@auth/sveltekit?color=green&label=@auth/sveltekit&style=flat-square">
|
||||
</a>
|
||||
<a href="https://bundlephobia.com/result?p=sveltekit-auth-example">
|
||||
<a href="https://bundlephobia.com/result?p=@auth/sveltekit">
|
||||
<img src="https://img.shields.io/bundlephobia/minzip/@auth/sveltekit?label=size&style=flat-square" alt="Bundle Size"/>
|
||||
</a>
|
||||
<a href="https://www.npmtrends.com/@auth/sveltekit">
|
||||
<img src="https://img.shields.io/npm/dm/@auth/sveltekit?label=%20downloads&style=flat-square" alt="Downloads" />
|
||||
<img src="https://img.shields.io/npm/dm/@auth/sveltekit?label=downloads&style=flat-square" alt="Downloads" />
|
||||
</a>
|
||||
<a href="https://npm.im/next-auth">
|
||||
<a href="https://npm.im/@auth/sveltekit">
|
||||
<img src="https://img.shields.io/badge/TypeScript-blue?style=flat-square" alt="TypeScript" />
|
||||
</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
# Documentation
|
||||
## Overview
|
||||
|
||||
- [sveltekit.authjs.dev](https://sveltekit.authjs.dev)
|
||||
This is the official SvelteKit Auth example for [Auth.js](https://sveltekit.authjs.dev).
|
||||
|
||||
## Getting started
|
||||
|
||||
You can instantly deploy this example to [Vercel](https://vercel.com?utm_source=github&utm_medium=readme&utm_campaign=sveltekit-auth-example) by clicking the following button.
|
||||
|
||||
[](https://vercel.com/new/git/external?repository-url=https://github.com/nextauthjs/sveltekit-auth-example&project-name=sveltekit-auth-example&repository-name=sveltekit-auth-example)
|
||||
|
||||
@@ -20,10 +20,10 @@
|
||||
$page.data.session.user?.name}</strong
|
||||
>
|
||||
</span>
|
||||
<a href="/auth/signout" class="button">Sign out</a>
|
||||
<a href="/auth/signout" class="button" data-sveltekit-preload-data="off">Sign out</a>
|
||||
{:else}
|
||||
<span class="notSignedInText">You are not signed in</span>
|
||||
<a href="/auth/signin" class="buttonPrimary">Sign in</a>
|
||||
<a href="/auth/signin" class="buttonPrimary" data-sveltekit-preload-data="off">Sign in</a>
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
## Overview
|
||||
|
||||
Auth.js is a complete open source authentication solution.
|
||||
Auth.js is a complete open-source authentication solution.
|
||||
|
||||
This is an example application that shows how `@auth/core` is applied to a basic Gatsby app. We are showing how to configure the backend both as a [Vercel Function](https://vercel.com/docs/concepts/functions/introduction) for deployment to Vercel, and also for [Gatsby Functions](https://www.gatsbyjs.com/docs/reference/functions) for other platforms.
|
||||
|
||||
@@ -30,7 +30,7 @@ The deployed version can be found at [`next-auth-gatsby-example.vercel.app`](htt
|
||||
|
||||
### About Auth.js
|
||||
|
||||
Auth.js is an easy to implement, full-stack (client/server) open source authentication library originally designed for [Next.js](https://nextjs.org) and [Serverless](https://vercel.com), but this example shows how to use it in a Gatsby project. Our goal is to [support even more frameworks](https://github.com/nextauthjs/next-auth/issues/2294) in the future.
|
||||
Auth.js is an easy-to-implement, full-stack (client/server) open-source authentication library originally designed for [Next.js](https://nextjs.org) and [Serverless](https://vercel.com), but this example shows how to use it in a Gatsby project. Our goal is to [support even more frameworks](https://github.com/nextauthjs/next-auth/issues/2294) in the future.
|
||||
|
||||
Go to [authjs.dev](https://authjs.dev) for more information and documentation.
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
"dependencies": {
|
||||
"dotenv": "^16.0.0",
|
||||
"gatsby": "next",
|
||||
"next-auth": "latest",
|
||||
"next-auth": "workspace:*",
|
||||
"react": "^18",
|
||||
"react-dom": "^18"
|
||||
},
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
"name": "playground-nuxt",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "nuxt build",
|
||||
"dev": "export NODE_OPTIONS='--no-experimental-fetch' && nuxt dev",
|
||||
"build": "nuxt prepare && nuxt build",
|
||||
"dev": "nuxt prepare && export NODE_OPTIONS='--no-experimental-fetch' && nuxt dev",
|
||||
"generate": "nuxt generate",
|
||||
"preview": "nuxt preview",
|
||||
"postinstall": "nuxt prepare"
|
||||
"preview": "nuxt preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nuxt/eslint-config": "^0.1.1",
|
||||
|
||||
3
docs/.eslintrc
Normal file
3
docs/.eslintrc
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "next/core-web-vitals"
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
<p align="center">
|
||||
<br/>
|
||||
<a href="https://authjs.dev" target="_blank"><img width="150px" src="https://authjs.dev/img/logo/logo-sm.png" /></a>
|
||||
<h3 align="center">Auth.js</h3>
|
||||
<p align="center">Authentication for Next.js</p>
|
||||
<p align="center">
|
||||
Open Source. Full Stack. Own Your Data.
|
||||
</p>
|
||||
<p align="center" style="align: center;">
|
||||
<a href="https://github.com/nextauthjs/next-auth/actions/workflows/release.yml?query=workflow%3ARelease">
|
||||
<img src="https://github.com/nextauthjs/next-auth/actions/workflows/release.yml/badge.svg" alt="Release" />
|
||||
</a>
|
||||
<a href="https://packagephobia.com/result?p=@auth/core">
|
||||
<img src="https://packagephobia.com/badge?p=@auth/core" alt="Bundle Size"/>
|
||||
</a>
|
||||
<a href="https://www.npmtrends.com/@auth/core">
|
||||
<img src="https://img.shields.io/npm/dm/@auth/core" alt="Downloads" />
|
||||
</a>
|
||||
<a href="https://github.com/nextauthjs/next-auth/stargazers">
|
||||
<img src="https://img.shields.io/github/stars/nextauthjs/next-auth" alt="Github Stars" />
|
||||
</a>
|
||||
<a href="https://www.npmjs.com/package/@auth/core">
|
||||
<img src="https://img.shields.io/github/v/release/nextauthjs/next-auth?label=latest" alt="Github Stable Release" />
|
||||
</a>
|
||||
</p>
|
||||
</p>
|
||||
|
||||
## Overview
|
||||
|
||||
This is the repository for the documentation page for Auth.js!
|
||||
|
||||
NextAuth.js is a complete open source authentication solution for [Next.js](http://nextjs.org/) applications.
|
||||
|
||||
This documentation site is based on the [Docusaurus](https://docusaurus.io) framework.
|
||||
|
||||
## Getting Started
|
||||
|
||||
To start a local environment of this project, please do the following.
|
||||
|
||||
1. Clone the repository.
|
||||
|
||||
```bash
|
||||
$ git clone https://github.com/nextauthjs/docs.git
|
||||
```
|
||||
|
||||
2. Install dependencies
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
3. Start the development server
|
||||
|
||||
```bash
|
||||
$ npm start
|
||||
```
|
||||
|
||||
And thats all! Now you should have a local copy of this docs site running at [localhost:3000](http://localhost:3000)!
|
||||
|
||||
## 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
|
||||
19
docs/assets/img/blobs/blob1.svg
Normal file
19
docs/assets/img/blobs/blob1.svg
Normal file
@@ -0,0 +1,19 @@
|
||||
<!-- <svg width="1077" height="990" viewBox="0 0 1077 990" fill="none" xmlns="http://www.w3.org/2000/svg"> -->
|
||||
<!-- <path d="M909.079 176.687C486.468 1429.32 94.8519 797.145 -245.666 989.191L-273.518 122.311C-98.0847 109.104 255.784 81.3405 267.79 75.9479C282.798 69.2072 1153.31 -485.661 1071.51 -140.889C1022.28 -26.4819 1001.45 -97.0987 909.079 176.687Z" fill="url(#paint0_linear_228_76)" fill-opacity="1" /> -->
|
||||
<!-- <defs> -->
|
||||
<!-- <linearGradient id="paint0_linear_228_76" x1="588.47" y1="791.265" x2="238.137" y2="497.91" gradientUnits="userSpaceOnUse"> -->
|
||||
<!-- <stop stop-color="#FF4400"/> -->
|
||||
<!-- <stop offset="1" stop-color="#111" /> -->
|
||||
<!-- </linearGradient> -->
|
||||
<!-- </defs> -->
|
||||
<!-- </svg> -->
|
||||
<svg width="1056" height="855" viewBox="0 0 1056 855" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M888.078 42.3027C465.467 1294.94 73.851 662.761 -266.667 854.807L-294.519 -12.0732C-119.086 -25.2807 234.783 -53.0438 246.789 -58.4364C261.797 -65.1771 1132.31 -620.045 1050.51 -275.273C1001.28 -160.866 980.447 -231.483 888.078 42.3027Z" fill="url(#paint0_radial_228_76)"/>
|
||||
<defs>
|
||||
<radialGradient id="paint0_radial_228_76" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(666.999 571.116) rotate(-129.513) scale(513.947 862.777)">
|
||||
<stop stop-color="#FF4400"/>
|
||||
<stop offset="1" stop-color="#111111"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
20
docs/assets/img/blobs/blob2.svg
Normal file
20
docs/assets/img/blobs/blob2.svg
Normal file
@@ -0,0 +1,20 @@
|
||||
<!-- <svg width="1405" height="1025" viewBox="0 0 1405 1025" fill="none" xmlns="http://www.w3.org/2000/svg"> -->
|
||||
<!-- <path d="M1180.05 977.4C483.802 708.04 103.247 143.506 0 -105.091L1102.61 -196C1418.53 307.367 1876.29 1246.76 1180.05 977.4Z" fill="url(#paint0_linear_228_83)" fill-opacity="0.44"/> -->
|
||||
<!-- <defs> -->
|
||||
<!-- <linearGradient id="paint0_linear_228_83" x1="185.171" y1="460.565" x2="641.405" y2="-62.9701" gradientUnits="userSpaceOnUse"> -->
|
||||
<!-- <stop stop-color="#BB44CC"/> -->
|
||||
<!-- <stop offset="1" stop-color="#BB44CC" stop-opacity="0"/> -->
|
||||
<!-- </linearGradient> -->
|
||||
<!-- </defs> -->
|
||||
<!-- </svg> -->
|
||||
|
||||
<svg width="1405" height="1025" viewBox="0 0 1405 1025" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M1180.05 977.4C483.802 708.04 103.247 143.506 0 -105.091L1102.61 -196C1418.53 307.367 1876.29 1246.76 1180.05 977.4Z" fill="url(#paint0_radial_228_83)"/>
|
||||
<defs>
|
||||
<radialGradient id="paint0_radial_228_83" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(498 619) rotate(-46.5881) scale(548.572 1194.34)">
|
||||
<stop stop-color="#BB44CC"/>
|
||||
<stop offset="1" stop-color="#111111"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
|
After Width: | Height: | Size: 1.1 KiB |
20
docs/assets/img/blobs/blob3.svg
Normal file
20
docs/assets/img/blobs/blob3.svg
Normal file
@@ -0,0 +1,20 @@
|
||||
<!-- <svg width="2402" height="275" viewBox="0 0 2402 275" fill="none" xmlns="http://www.w3.org/2000/svg"> -->
|
||||
<!-- <path d="M305.668 155.376C1150.52 -387.169 3270.85 708.01 2011.14 262.274L1847.48 804.627C1613.84 721.267 1142.31 553.804 1125.29 550.832C1104 547.117 -168.361 431.431 18.8067 264.119C109.949 220.108 121.011 273.958 305.668 155.376Z" fill="url(#paint0_linear_228_78)" fill-opacity="0.66"/> -->
|
||||
<!-- <defs> -->
|
||||
<!-- <linearGradient id="paint0_linear_228_78" x1="869.047" y1="-51.7999" x2="921.583" y2="353.448" gradientUnits="userSpaceOnUse"> -->
|
||||
<!-- <stop stop-color="#44BBCC"/> -->
|
||||
<!-- <stop offset="1" stop-color="#44BBCC" stop-opacity="0.12"/> -->
|
||||
<!-- </linearGradient> -->
|
||||
<!-- </defs> -->
|
||||
<!-- </svg> -->
|
||||
|
||||
<svg width="2402" height="275" viewBox="0 0 2402 275" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M305.668 155.376C1150.52 -387.169 3270.85 708.01 2011.14 262.274L1847.48 804.627C1613.84 721.267 1142.31 553.804 1125.29 550.832C1104 547.117 -168.361 431.431 18.8067 264.119C109.949 220.108 121.011 273.958 305.668 155.376Z" fill="url(#paint0_radial_228_78)"/>
|
||||
<defs>
|
||||
<radialGradient id="paint0_radial_228_78" cx="0" cy="0" r="1" gradientUnits="userSpaceOnUse" gradientTransform="translate(883.5 -66) rotate(93.0267) scale(757.557 879.417)">
|
||||
<stop stop-color="#44BBCC"/>
|
||||
<stop offset="1" stop-color="#111111"/>
|
||||
</radialGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
||||
|
After Width: | Height: | Size: 1.4 KiB |
66
docs/components/marquee.jsx
Normal file
66
docs/components/marquee.jsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import { useState, useEffect } from "react"
|
||||
import { motion } from "framer-motion"
|
||||
|
||||
const clamp = (num, min, max) => Math.min(Math.max(num, min), max)
|
||||
|
||||
export default function Marquee({ files }) {
|
||||
const [{ width, height }, setSize] = useState({ height: 0, width: 0 })
|
||||
useEffect(() => {
|
||||
setSize({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
})
|
||||
}, [])
|
||||
|
||||
if (width === 0) return
|
||||
|
||||
return (
|
||||
<div className="absolute w-full h-full top-0 left-0 dark:opacity-5 opacity-20 saturate-0 brightness-75 dark:brightness-[1000] -z-20 overflow-hidden flex flex-col marquee-wrapper">
|
||||
{files.map((name) => (
|
||||
<MarqueeItem key={name} name={name} width={width} height={height} />
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function MarqueeItem({ name, width, height }) {
|
||||
const [y] = useState(height * Math.random())
|
||||
const [reset, setReset] = useState(false)
|
||||
const [duration] = useState(clamp(Math.random() * 25, 20, 25))
|
||||
const offset = Math.random() * width
|
||||
useEffect(() => {
|
||||
const timeout =
|
||||
setTimeout(() => {
|
||||
setReset(true)
|
||||
}, (1000 * (width - offset)) / duration) - 2000
|
||||
return () => clearTimeout(timeout)
|
||||
}, [duration, width, offset])
|
||||
return (
|
||||
<motion.span
|
||||
key={name + reset}
|
||||
className="absolute flex items-center justify-center"
|
||||
initial={{ x: reset ? 0 : offset, y }}
|
||||
animate={{ x: width }}
|
||||
transition={{
|
||||
repeat: Infinity,
|
||||
duration: reset ? duration : (width - offset) / duration,
|
||||
ease: "linear",
|
||||
}}
|
||||
>
|
||||
<motion.img
|
||||
src={`/img/providers/${name}`}
|
||||
alt={name}
|
||||
className="relative w-12 drop-shadow-xl"
|
||||
initial={{ opacity: 0, scale: 0.5 }}
|
||||
animate={{ opacity: 1, scale: 1 }}
|
||||
transition={{
|
||||
delay: reset ? 0 : Math.random() * 5,
|
||||
duration: 1,
|
||||
type: "spring",
|
||||
|
||||
stiffness: 150,
|
||||
}}
|
||||
/>
|
||||
</motion.span>
|
||||
)
|
||||
}
|
||||
85
docs/components/triangle.jsx
Normal file
85
docs/components/triangle.jsx
Normal file
@@ -0,0 +1,85 @@
|
||||
export default function Triangle({ className }) {
|
||||
return (
|
||||
<svg
|
||||
id="triangle"
|
||||
viewBox="0 0 445 379"
|
||||
className={className}
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<style jsx>
|
||||
{`
|
||||
@media (prefers-color-scheme: light) {
|
||||
#triangle-0 {
|
||||
fill: #000;
|
||||
}
|
||||
#triangle-1 {
|
||||
fill: #ff4400;
|
||||
}
|
||||
#triangle-2 {
|
||||
fill: #bb44cc;
|
||||
}
|
||||
#triangle-3 {
|
||||
fill: #44bbcc;
|
||||
}
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
<path
|
||||
id="triangle-0"
|
||||
d="M334.033 238.33L222.692 46.7201L111.352 238.33H334.033Z"
|
||||
fill="#fff"
|
||||
/>
|
||||
<path
|
||||
id="triangle-1"
|
||||
d="M198.174 1.12812L4.62255 51.2473C1.37638 52.0878 -0.550786 55.4258 0.344333 58.6574L53.7157 251.338C55.1362 256.466 62.0336 257.344 64.6942 252.736L204.874 9.93656C207.535 5.32834 203.325 -0.205751 198.174 1.12812Z"
|
||||
fill="url(#triangle-1-gradient)"
|
||||
/>
|
||||
<path
|
||||
id="triangle-2"
|
||||
d="M246.294 1.12825L439.846 51.2473C443.092 52.0879 445.019 55.4259 444.124 58.6574L390.753 251.338C389.332 256.466 382.435 257.344 379.774 252.736L239.594 9.93665C236.933 5.32844 241.143 -0.205634 246.294 1.12825Z"
|
||||
fill="url(#triangle-2-gradient)"
|
||||
/>
|
||||
<path
|
||||
id="triangle-3"
|
||||
d="M361.388 286.577L225.585 377.959C223.559 379.322 220.91 379.322 218.885 377.959L83.0814 286.577C78.1672 283.27 80.5079 275.599 86.4311 275.599H358.039C363.962 275.599 366.303 283.27 361.388 286.577Z"
|
||||
fill="url(#triangle-3-gradient)"
|
||||
/>
|
||||
<defs>
|
||||
<linearGradient
|
||||
id="triangle-1-gradient"
|
||||
x1="-1.28386"
|
||||
y1="52.7769"
|
||||
x2="134.785"
|
||||
y2="131.336"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#992900" />
|
||||
<stop offset="1" stopColor="#FF4400" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="triangle-2-gradient"
|
||||
x1="445.753"
|
||||
y1="52.7769"
|
||||
x2="309.684"
|
||||
y2="131.336"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#6D2178" />
|
||||
<stop offset="1" stopColor="#BB44CC" />
|
||||
</linearGradient>
|
||||
<linearGradient
|
||||
id="triangle-3-gradient"
|
||||
x1="222.236"
|
||||
y1="380.213"
|
||||
x2="222.236"
|
||||
y2="275.599"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
<stop stopColor="#1B5B64" />
|
||||
<stop offset="1" stopColor="#44BBCC" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
)
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Concepts",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
---
|
||||
title: Databases
|
||||
---
|
||||
|
||||
Auth.js offers multiple database adapters. Check our guides on:
|
||||
|
||||
- [using a database adapter](/guides/adapters/using-a-database-adapter)
|
||||
- [creating your own](/guides/adapters/creating-a-database-adapter)
|
||||
|
||||
> As of **v4** Auth.js no longer ships with an adapter included by default. If you would like to persist any information, you need to install one of the many available adapters yourself. See the individual adapter documentation pages for more details.
|
||||
|
||||
To learn more about databases in Auth.js and how they are used, check out [databases in the FAQ](/concepts/faq#databases).
|
||||
|
||||
---
|
||||
|
||||
## How to use a database
|
||||
|
||||
See the [documentation for adapters](/reference/adapters/overview) for more information on advanced configuration, including how to use Auth.js with other databases using a [custom adapter](/guides/adapters/creating-a-database-adapter).
|
||||
@@ -1,612 +0,0 @@
|
||||
---
|
||||
title: Upgrade Guide (v4)
|
||||
---
|
||||
|
||||
Auth.js version 4 includes a few breaking changes from the last major version (3.x). So we're here to help you upgrade your applications as smoothly as possible. It should be possible to upgrade from any version of 3.x to the latest 4 release by following the next few migration steps.
|
||||
|
||||
:::note
|
||||
Version 4 has been released to GA 🚨
|
||||
|
||||
We encourage users to try it out and report any and all issues they come across.
|
||||
:::
|
||||
|
||||
You can upgrade to the new version by running:
|
||||
|
||||
```bash npm2yarn
|
||||
npm install next-auth
|
||||
```
|
||||
|
||||
## `next-auth/jwt`
|
||||
|
||||
We no longer have a default export in `next-auth/jwt`.
|
||||
To comply with this, change the following:
|
||||
|
||||
```diff
|
||||
- import jwt from "next-auth/jwt"
|
||||
+ import { getToken } from "next-auth/jwt"
|
||||
```
|
||||
|
||||
## `next-auth/react`
|
||||
|
||||
We've renamed the client-side import source to `next-auth/react`. To comply with this change, you will simply have to rename anywhere you were using `next-auth/client`.
|
||||
|
||||
For example:
|
||||
|
||||
```diff
|
||||
- import { useSession } from "next-auth/client"
|
||||
+ import { useSession } from "next-auth/react"
|
||||
```
|
||||
|
||||
We've also made the following changes to the names of the exports:
|
||||
|
||||
- `setOptions`: Not exposed anymore, use [`SessionProvider` props](/reference/react/#sessionprovider)
|
||||
- `options`: Not exposed anymore, [use `SessionProvider` props](/reference/react/#sessionprovider)
|
||||
- `session`: Renamed to `getSession`
|
||||
- `providers`: Renamed to `getProviders`
|
||||
- `csrfToken`: Renamed to `getCsrfToken`
|
||||
- `signin`: Renamed to `signIn`
|
||||
- `signout`: Renamed to `signOut`
|
||||
- `Provider`: Renamed to `SessionProvider`
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.12
|
||||
|
||||
## `SessionProvider`
|
||||
|
||||
Version 4 makes using the `SessionProvider` mandatory. This means that you will have to wrap any part of your application using `useSession` in this provider, if you were not doing so already. The `SessionProvider` has also undergone a few further changes:
|
||||
|
||||
- `Provider` is renamed to `SessionProvider`
|
||||
- The options prop is now flattened as the props of SessionProvider.
|
||||
- `keepAlive` has been renamed to `refetchInterval`.
|
||||
- `clientMaxAge` has been removed in favor of `refetchInterval`, as they overlap in functionality, with the difference that `refetchInterval` will keep re-fetching the session periodically in the background.
|
||||
|
||||
The best practice for wrapping your app in Providers is to do so in your `pages/_app.jsx` file.
|
||||
|
||||
An example use-case with these new changes:
|
||||
|
||||
```jsx
|
||||
import { SessionProvider } from "next-auth/react"
|
||||
|
||||
export default function App({
|
||||
Component,
|
||||
pageProps: { session, ...pageProps },
|
||||
}) {
|
||||
return (
|
||||
// `session` comes from `getServerSideProps` or `getInitialProps`.
|
||||
// Avoids flickering/session loading on first load.
|
||||
<SessionProvider session={session} refetchInterval={5 * 60}>
|
||||
<Component {...pageProps} />
|
||||
</SessionProvider>
|
||||
)
|
||||
}
|
||||
```
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.12
|
||||
|
||||
## Providers
|
||||
|
||||
Providers now need to be imported individually.
|
||||
|
||||
```diff
|
||||
- import Provider from "next-auth/providers"
|
||||
- Providers.Auth0({...})
|
||||
- Providers.Google({...})
|
||||
+ import Auth0Provider from "next-auth/providers/auth0"
|
||||
+ import GoogleProvider from "next-auth/providers/google"
|
||||
+ Auth0Provider({...})
|
||||
+ GoogleProvider({...})
|
||||
```
|
||||
|
||||
1. The `AzureADB2C` provider has been renamed `AzureAD`.
|
||||
2. The `Basecamp` provider has been removed, see explanation [here](https://github.com/basecamp/api/blob/master/sections/authentication.md#on-authenticating-users-via-oauth).
|
||||
3. The GitHub provider by default now will not request full write access to user profiles. If you need this scope, please add `user` to the scope option manually.
|
||||
|
||||
The following new options are available when defining your Providers in the configuration:
|
||||
|
||||
1. `authorization` (replaces `authorizationUrl`, `authorizationParams`, `scope`)
|
||||
2. `token` replaces (`accessTokenUrl`, `headers`, `params`)
|
||||
3. `userinfo` (replaces `profileUrl`)
|
||||
4. `issuer`(replaces `domain`)
|
||||
|
||||
For more details on their usage, please see [options](/reference/providers/oauth) section of the OAuth Provider documentation.
|
||||
|
||||
When submitting a new OAuth provider to the repository, the `profile` callback is expected to only return these fields from now on: `id`, `name`, `email`, and `image`. If any of these are missing values, they should be set to `null`.
|
||||
|
||||
Also worth noting is that `id` is expected to be returned as a `string` type (For example if your provider returns it as a number, you can cast it by using the `.toString()` method). This makes the returned profile object comply across all providers/accounts/adapters, and hopefully cause less confusion in the future.
|
||||
|
||||
Implemented in: https://github.com/nextauthjs/next-auth/pull/2411
|
||||
Introduced in https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.20
|
||||
|
||||
## `useSession` Hook
|
||||
|
||||
The `useSession` hook has been updated to return an object. This allows you to test states much more cleanly with the new `status` option.
|
||||
|
||||
```diff
|
||||
- const [ session, loading ] = useSession()
|
||||
+ const { data: session, status } = useSession()
|
||||
+ const loading = status === "loading"
|
||||
```
|
||||
|
||||
[Check the docs](/reference/react/#usesession) for the possible values of both `session.status` and `session.data`.
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.18
|
||||
|
||||
## Named Parameters
|
||||
|
||||
We have changed the arguments to our callbacks to the named parameters pattern. This way you don't have to use dummy `_` placeholders or other tricks.
|
||||
|
||||
### Callbacks
|
||||
|
||||
The signatures for the callback methods now look like this:
|
||||
|
||||
```diff
|
||||
- signIn(user, account, profileOrEmailOrCredentials)
|
||||
+ signIn({ user, account, profile, email, credentials })
|
||||
```
|
||||
|
||||
```diff
|
||||
- redirect(url, baseUrl)
|
||||
+ redirect({ url, baseUrl })
|
||||
```
|
||||
|
||||
```diff
|
||||
- session(session, tokenOrUser)
|
||||
+ session({ session, token, user })
|
||||
```
|
||||
|
||||
```diff
|
||||
- jwt(token, user, account, OAuthProfile, isNewUser)
|
||||
+ jwt({ token, user, account, profile, isNewUser })
|
||||
```
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.17
|
||||
|
||||
### Events
|
||||
|
||||
Two event signatures have changed to also use the named parameters pattern, `signOut` and `updateUser`.
|
||||
|
||||
```diff
|
||||
// [...nextauth].js
|
||||
...
|
||||
events: {
|
||||
- signOut(tokenOrSession),
|
||||
+ signOut({ token, session }), // token if using JWT, session if DB persisted sessions.
|
||||
- updateUser(user)
|
||||
+ updateUser({ user })
|
||||
}
|
||||
```
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.20
|
||||
|
||||
## JWT configuration
|
||||
|
||||
We have removed some of the [configuration options](/reference/configuration/auth-config) when using JSON Web Tokens, [here's the PR](https://github.com/nextauthjs/next-auth/pull/3039) for more context.
|
||||
|
||||
```diff
|
||||
export default NextAuth({
|
||||
// ...
|
||||
jwt: {
|
||||
secret,
|
||||
maxAge,
|
||||
- encryptionKey
|
||||
- signingKey
|
||||
- encryptionKey
|
||||
- verificationOptions
|
||||
encode({
|
||||
token
|
||||
secret
|
||||
maxAge
|
||||
- signingKey
|
||||
- signingOptions
|
||||
- encryptionKey
|
||||
- encryptionOptions
|
||||
- encryption
|
||||
}) {},
|
||||
decode({
|
||||
token
|
||||
secret
|
||||
- maxAge
|
||||
- signingKey
|
||||
- verificationKey
|
||||
- verificationOptions
|
||||
- encryptionKey
|
||||
- decryptionKey
|
||||
- decryptionOptions
|
||||
- encryption
|
||||
}) {}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Logger API
|
||||
|
||||
The logger API has been simplified to use at most two parameters, where the second is usually an object (`metadata`) containing an `error` object. If you are not using the logger settings you can ignore this change.
|
||||
|
||||
```diff
|
||||
// [...Auth.js]
|
||||
import log from "some-logger-service"
|
||||
...
|
||||
logger: {
|
||||
- error(code, ...message) {},
|
||||
+ error(code, metadata) {},
|
||||
- warn(code, ...message) {},
|
||||
+ warn(code) {}
|
||||
- debug(code, ...message) {}
|
||||
+ debug(code, metadata) {}
|
||||
}
|
||||
```
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.19
|
||||
|
||||
## `nodemailer`
|
||||
|
||||
Like `typeorm` and `prisma`, [`nodemailer`](https://npmjs.com/package/nodemailer) is no longer included as a dependency by default. If you are using the Email provider you must install it in your project manually, or use any other Email library in the [`sendVerificationRequest`](/reference/providers/email) callback. This reduces bundle size for those not actually using the Email provider. Remember, when using the Email provider, it is mandatory to also use a database adapter due to the fact that verification tokens need to be persisted longer term for the magic link functionality to work.
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.2
|
||||
|
||||
## Theme
|
||||
|
||||
We have added some basic customization options to our built-in pages like `signin`, `signout`, etc.
|
||||
|
||||
These can be set under the `theme` configuration key. This used to be a string which only controlled the color scheme option. Now it is an object with the following options:
|
||||
|
||||
```js
|
||||
theme: {
|
||||
colorScheme: "auto", // "auto" | "dark" | "light"
|
||||
brandColor: "", // Hex color value
|
||||
logo: "" // Absolute URL to logo image
|
||||
}
|
||||
```
|
||||
|
||||
The hope is that with some minimal configuration / customization options, users won't immediately feel the need to replace the built-in pages with their own.
|
||||
|
||||
More details and screenshots of the new theme options can be found under [custom pages tutorial](/guides/basics/pages).
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/pull/2788
|
||||
|
||||
## Session
|
||||
|
||||
The `session.jwt: boolean` option has been renamed to `session.strategy: "jwt" | "database"`. The goal is to make the user's options more intuitive:
|
||||
|
||||
1. No adapter, `strategy: "jwt"`: This is the default. The session is saved in a cookie and never persisted anywhere.
|
||||
2. With Adapter, `strategy: "database"`: If an Adapter is defined, this will be the implicit setting. No user config is needed.
|
||||
3. With Adapter, `strategy: "jwt"`: The user can explicitly instruct `next-auth` to use JWT even if a database is available. This can result in faster lookups in compromise of lowered security. Read more about: https://authjs.dev/concepts/faq#json-web-tokens
|
||||
|
||||
Example:
|
||||
|
||||
```diff
|
||||
session: {
|
||||
- jwt: true,
|
||||
+ strategy: "jwt",
|
||||
}
|
||||
```
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/pull/3144
|
||||
|
||||
## Adapters
|
||||
|
||||
Most importantly, the core `next-auth` package no longer ships with `typeorm` or any other database adapter by default. This brings the default bundle size down significantly for those not needing to persist user data to a database.
|
||||
|
||||
You can find the official Adapters in the `packages` directory in the primary monorepo ([nextauthjs/next-auth](https://github.com/nextauthjs/next-auth)). Although you can still [create your own](/guides/adapters/creating-a-database-adapter) with a new, [simplified Adapter API](https://github.com/nextauthjs/next-auth/pull/2361).
|
||||
|
||||
If you have a database that was created with a `3.x.x` or earlier version of Auth.js, you will need to run a migration to update the schema to the new version 4 database model. See the bottom of this migration guide for database specific migration examples.
|
||||
|
||||
1. If you use the built-in TypeORM or Prisma adapters, these have been removed from the core `next-auth` package. Thankfully the migration is easy; you just need to install the external packages for your database and change the import in your `[...nextauth].js`.
|
||||
|
||||
The `database` option has been removed, you must now do the following instead:
|
||||
|
||||
```diff
|
||||
// [...nextauth].js
|
||||
import NextAuth from "next-auth"
|
||||
+ import { TypeORMLegacyAdapter } from "@next-auth/typeorm-legacy-adapter"
|
||||
|
||||
...
|
||||
export default NextAuth({
|
||||
- database: "yourconnectionstring",
|
||||
+ adapter: TypeORMLegacyAdapter("yourconnectionstring")
|
||||
})
|
||||
```
|
||||
|
||||
2. The `prisma-legacy` adapter has been removed, please use the [`@next-auth/prisma-adapter`](https://npmjs.com/package/@next-auth/prisma-adapter) instead.
|
||||
|
||||
3. The `typeorm-legacy` adapter has been upgraded to use the newer adapter API, but has retained the `typeorm-legacy` name. We aim to migrate this to individual lighter weight adapters for each database type in the future, or switch out `typeorm`.
|
||||
|
||||
4. MongoDB has been moved to its own adapter under `@next-auth/mongodb-adapter`. See the [MongoDB Adapter docs](/reference/adapters/mongodb).
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.8 and https://github.com/nextauthjs/next-auth/pull/2361
|
||||
|
||||
### Adapter API
|
||||
|
||||
**This does not require any changes from the user - these are adapter specific changes only**
|
||||
|
||||
The Adapter API has been rewritten and significantly simplified in NextAuth v4. The adapters now have less work to do as some functionality has been migrated to the core of NextAuth, like hashing the [verification token](/reference/adapters/models/#verification-token).
|
||||
|
||||
If you are an adapter maintainer or are interested in writing your own adapter, you can find more information about this change in https://github.com/nextauthjs/next-auth/pull/2361 and release https://github.com/nextauthjs/next-auth/releases/tag/v4.0.0-next.22.
|
||||
|
||||
### Schema changes
|
||||
|
||||
The way we save data with adapters have slightly changed. With the new Adapter API, we wanted to make it easier to extend your database with additional fields. For example if your User needs an extra `phone` field, it should be enough to add that to your database's schema, and no changes will be necessary in your adapter.
|
||||
|
||||
- `created_at`/`createdAt` and `updated_at`/`updatedAt` fields are removed from all Models.
|
||||
- `user_id`/`userId` consistently named `userId`.
|
||||
- `compound_id`/`compoundId` is removed from Account.
|
||||
- `access_token`/`accessToken` is removed from Session.
|
||||
- `email_verified`/`emailVerified` on User is consistently named `emailVerified`.
|
||||
- `provider_id`/`providerId` renamed to `provider` on Account
|
||||
- `provider_type`/`providerType` renamed to `type` on Account
|
||||
- `provider_account_id`/`providerAccountId` on Account is consistently named `providerAccountId`
|
||||
- `access_token_expires`/`accessTokenExpires` on Account renamed to `expires_at`
|
||||
- New fields on Account: `token_type`, `scope`, `id_token`, `session_state`
|
||||
- `verification_requests` table has been renamed to `verification_tokens`
|
||||
|
||||
<!-- REVIEW: Would something like this below be helpful? -->
|
||||
<details>
|
||||
<summary>
|
||||
See the changes
|
||||
</summary>
|
||||
<pre>
|
||||
|
||||
```diff
|
||||
User {
|
||||
id
|
||||
name
|
||||
email
|
||||
- emailVerified
|
||||
+ email_verified
|
||||
image
|
||||
- created_at
|
||||
- updated_at
|
||||
}
|
||||
|
||||
Account {
|
||||
id
|
||||
- compound_id
|
||||
- user_id
|
||||
+ userId
|
||||
- provider_type
|
||||
+ type
|
||||
- provider_id
|
||||
+ provider
|
||||
- provider_account_id
|
||||
+ providerAccountId
|
||||
refresh_token
|
||||
access_token
|
||||
- access_token_expires
|
||||
+ expires_in
|
||||
+ expires_at
|
||||
+ token_type
|
||||
+ scope
|
||||
+ id_token
|
||||
+ session_state
|
||||
- created_at
|
||||
- updated_at
|
||||
}
|
||||
|
||||
Session {
|
||||
id
|
||||
userId
|
||||
expires
|
||||
sessionToken
|
||||
- access_token
|
||||
- created_at
|
||||
- updated_at
|
||||
}
|
||||
|
||||
VerificationToken {
|
||||
id
|
||||
token
|
||||
expires
|
||||
identifier
|
||||
- created_at
|
||||
- updated_at
|
||||
}
|
||||
```
|
||||
|
||||
</pre>
|
||||
</details>
|
||||
|
||||
For more info, see the [Models page](/reference/adapters/models).
|
||||
|
||||
### Database migration
|
||||
|
||||
Auth.js v4 has a slightly different database schema compared to v3. If you're using any of our adapters and want to upgrade, you can use on of the below schemas.
|
||||
|
||||
They are designed to be run directly against the database itself. So instead of having one in Prisma syntax, one in TypeORM syntax, etc. we've decided to just make one for each underlying database type. i.e. one for Postgres, one for MySQL, one for MongoDB, etc.
|
||||
|
||||
#### MySQL
|
||||
|
||||
```sql
|
||||
/* ACCOUNT */
|
||||
ALTER TABLE accounts
|
||||
CHANGE "access_token_expires" "expires_at" int
|
||||
CHANGE "user_id" "userId" varchar(255)
|
||||
ADD CONSTRAINT fk_user_id FOREIGN KEY (userId) REFERENCES users(id)
|
||||
RENAME COLUMN "provider_id" "provider"
|
||||
RENAME COLUMN "provider_account_id" "providerAccountId"
|
||||
DROP COLUMN "provider_type"
|
||||
DROP COLUMN "compound_id"
|
||||
/* The following two timestamp columns have never been necessary for Auth.js to function, but can be kept if you want */
|
||||
DROP COLUMN "created_at"
|
||||
DROP COLUMN "updated_at"
|
||||
|
||||
ADD COLUMN "token_type" varchar(255) NULL
|
||||
ADD COLUMN "scope" varchar(255) NULL
|
||||
ADD COLUMN "id_token" varchar(255) NULL
|
||||
ADD COLUMN "session_state" varchar(255) NULL
|
||||
|
||||
/* Note: These are only needed if you're going to be using the old Twitter OAuth 1.0 provider. */
|
||||
ADD COLUMN "oauth_token_secret" varchar(255) NULL
|
||||
ADD COLUMN "oauth_token" varchar(255) NULL
|
||||
|
||||
/* USER */
|
||||
ALTER TABLE users
|
||||
RENAME COLUMN "email_verified" "emailVerified"
|
||||
/* The following two timestamp columns have never been necessary for Auth.js to function, but can be kept if you want */
|
||||
DROP COLUMN "created_at"
|
||||
DROP COLUMN "updated_at"
|
||||
|
||||
/* SESSION */
|
||||
ALTER TABLE sessions
|
||||
RENAME COLUMN "session_token" "sessionToken"
|
||||
CHANGE "user_id" "userId" varchar(255)
|
||||
ADD CONSTRAINT fk_user_id FOREIGN KEY (userId) REFERENCES users(id)
|
||||
DROP COLUMN "access_token"
|
||||
/* The following two timestamp columns have never been necessary for Auth.js to function, but can be kept if you want */
|
||||
DROP COLUMN "created_at"
|
||||
DROP COLUMN "updated_at"
|
||||
|
||||
/* VERIFICATION REQUESTS */
|
||||
ALTER TABLE verification_requests RENAME verification_tokens
|
||||
ALTER TABLE verification_tokens
|
||||
DROP COLUMN id
|
||||
/* The following two timestamp columns have never been necessary for Auth.js to function, but can be kept if you want */
|
||||
DROP COLUMN "created_at"
|
||||
DROP COLUMN "updated_at"
|
||||
```
|
||||
|
||||
#### Postgres
|
||||
|
||||
```sql
|
||||
/* ACCOUNT */
|
||||
ALTER TABLE accounts RENAME COLUMN "user_id" TO "userId";
|
||||
ALTER TABLE accounts RENAME COLUMN "provider_id" TO "provider";
|
||||
ALTER TABLE accounts RENAME COLUMN "provider_account_id" TO "providerAccountId";
|
||||
ALTER TABLE accounts RENAME COLUMN "access_token_expires" TO "expires_at";
|
||||
ALTER TABLE accounts RENAME COLUMN "provider_type" TO "type";
|
||||
|
||||
/* Do conversion of TIMESTAMPTZ to BIGINT */
|
||||
ALTER TABLE accounts ALTER COLUMN "expires_at" TYPE TEXT USING CAST(extract(epoch FROM "expires_at") AS BIGINT)*1000;
|
||||
|
||||
/* Keep id as SERIAL with autoincrement when using ORM. Using new v4 uuid format won't work because of incompatibility */
|
||||
/* ALTER TABLE accounts ALTER COLUMN "id" TYPE TEXT; */
|
||||
/* ALTER TABLE accounts ALTER COLUMN "userId" TYPE TEXT; */
|
||||
ALTER TABLE accounts ALTER COLUMN "type" TYPE TEXT;
|
||||
ALTER TABLE accounts ALTER COLUMN "provider" TYPE TEXT;
|
||||
ALTER TABLE accounts ALTER COLUMN "providerAccountId" TYPE TEXT;
|
||||
|
||||
ALTER TABLE accounts ADD CONSTRAINT fk_user_id FOREIGN KEY ("userId") REFERENCES users(id);
|
||||
ALTER TABLE accounts
|
||||
DROP COLUMN IF EXISTS "compound_id";
|
||||
/* The following two timestamp columns have never been necessary for Auth.js to function, but can be kept if you want */
|
||||
ALTER TABLE accounts
|
||||
DROP COLUMN IF EXISTS "created_at",
|
||||
DROP COLUMN IF EXISTS "updated_at";
|
||||
|
||||
ALTER TABLE accounts
|
||||
ADD COLUMN IF NOT EXISTS "token_type" TEXT NULL,
|
||||
ADD COLUMN IF NOT EXISTS "scope" TEXT NULL,
|
||||
ADD COLUMN IF NOT EXISTS "id_token" TEXT NULL,
|
||||
ADD COLUMN IF NOT EXISTS "session_state" TEXT NULL;
|
||||
/* Note: These are only needed if you're going to be using the old Twitter OAuth 1.0 provider. */
|
||||
/* ALTER TABLE accounts
|
||||
ADD COLUMN IF NOT EXISTS "oauth_token_secret" TEXT NULL,
|
||||
ADD COLUMN IF NOT EXISTS "oauth_token" TEXT NULL; */
|
||||
|
||||
/* USER */
|
||||
ALTER TABLE users RENAME COLUMN "email_verified" TO "emailVerified";
|
||||
|
||||
/* Keep id as SERIAL with autoincrement when using ORM. Using new v4 uuid format won't work because of incompatibility */
|
||||
/* ALTER TABLE users ALTER COLUMN "id" TYPE TEXT; */
|
||||
ALTER TABLE users ALTER COLUMN "name" TYPE TEXT;
|
||||
ALTER TABLE users ALTER COLUMN "email" TYPE TEXT;
|
||||
ALTER TABLE users ALTER COLUMN "image" TYPE TEXT;
|
||||
/* Do conversion of TIMESTAMPTZ to BIGINT and then TEXT */
|
||||
ALTER TABLE users ALTER COLUMN "emailVerified" TYPE TEXT USING CAST(CAST(extract(epoch FROM "emailVerified") AS BIGINT)*1000 AS TEXT);
|
||||
/* The following two timestamp columns have never been necessary for Auth.js to function, but can be kept if you want */
|
||||
ALTER TABLE users
|
||||
DROP COLUMN IF EXISTS "created_at",
|
||||
DROP COLUMN IF EXISTS "updated_at";
|
||||
|
||||
/* SESSION */
|
||||
ALTER TABLE sessions RENAME COLUMN "session_token" TO "sessionToken";
|
||||
ALTER TABLE sessions RENAME COLUMN "user_id" TO "userId";
|
||||
|
||||
/* Keep id as SERIAL with autoincrement when using ORM. Using new v4 uuid format won't work because of incompatibility */
|
||||
/* ALTER TABLE sessions ALTER COLUMN "id" TYPE TEXT; */
|
||||
/* ALTER TABLE sessions ALTER COLUMN "userId" TYPE TEXT; */
|
||||
ALTER TABLE sessions ALTER COLUMN "sessionToken" TYPE TEXT;
|
||||
ALTER TABLE sessions ADD CONSTRAINT fk_user_id FOREIGN KEY ("userId") REFERENCES users(id);
|
||||
/* Do conversion of TIMESTAMPTZ to BIGINT and then TEXT */
|
||||
ALTER TABLE sessions ALTER COLUMN "expires" TYPE TEXT USING CAST(CAST(extract(epoch FROM "expires") AS BIGINT)*1000 AS TEXT);
|
||||
ALTER TABLE sessions DROP COLUMN IF EXISTS "access_token";
|
||||
/* The following two timestamp columns have never been necessary for Auth.js to function, but can be kept if you want */
|
||||
ALTER TABLE sessions
|
||||
DROP COLUMN IF EXISTS "created_at",
|
||||
DROP COLUMN IF EXISTS "updated_at";
|
||||
|
||||
/* VERIFICATION REQUESTS */
|
||||
ALTER TABLE verification_requests RENAME TO verification_tokens;
|
||||
/* Keep id as ORM needs it */
|
||||
/* ALTER TABLE verification_tokens DROP COLUMN IF EXISTS id; */
|
||||
ALTER TABLE verification_tokens ALTER COLUMN "identifier" TYPE TEXT;
|
||||
ALTER TABLE verification_tokens ALTER COLUMN "token" TYPE TEXT;
|
||||
/* Do conversion of TIMESTAMPTZ to BIGINT and then TEXT */
|
||||
ALTER TABLE verification_tokens ALTER COLUMN "expires" TYPE TEXT USING CAST(CAST(extract(epoch FROM "expires") AS BIGINT)*1000 AS TEXT);
|
||||
/* The following two timestamp columns have never been necessary for Auth.js to function, but can be kept if you want */
|
||||
ALTER TABLE verification_tokens
|
||||
DROP COLUMN IF EXISTS "created_at",
|
||||
DROP COLUMN IF EXISTS "updated_at";
|
||||
```
|
||||
|
||||
#### MongoDB
|
||||
|
||||
MongoDB is a document database and as such new fields will be automatically populated. You do, however, need to update the names of existing fields which are going to be reused.
|
||||
|
||||
```mongo
|
||||
db.getCollection('accounts').updateMany({}, {
|
||||
$rename: {
|
||||
"provider_id": "provider",
|
||||
"provider_account_id": "providerAccountId",
|
||||
"user_id": "userId",
|
||||
"access_token_expires": "expires_at"
|
||||
}
|
||||
})
|
||||
db.getCollection('users').updateMany({}, {
|
||||
$rename: {
|
||||
"email_verified": "emailVerified"
|
||||
}
|
||||
})
|
||||
db.getCollection('sessions').updateMany({}, {
|
||||
$rename: {
|
||||
"session_token": "sessionToken",
|
||||
"user_id": "userId"
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## Missing `secret`
|
||||
|
||||
Auth.js used to generate a secret for convenience, when the user did not define one. This might have been useful in development, but can be a concern in production. We have always been clear about that in the docs, but from now on, if you forget to define a `secret` property in production, we will show the user an error page. Read more about this option [here](/reference/configuration/auth-config#secret)
|
||||
|
||||
You can generate a secret to be placed in the `secret` configuration option via the following command:
|
||||
|
||||
```bash
|
||||
$ openssl rand -base64 32
|
||||
```
|
||||
|
||||
Therefore, your Auth.js config should look something like this:
|
||||
|
||||
```javascript title="/pages/api/auth/[...nextauth].js"
|
||||
...
|
||||
export default NextAuth({
|
||||
...
|
||||
providers: [...],
|
||||
secret: "LlKq6ZtYbr+hTC073mAmAh9/h2HwMfsFo4hrfCx5mLg=",
|
||||
...
|
||||
})
|
||||
```
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/issues/3143
|
||||
|
||||
## Session `strategy`
|
||||
|
||||
We have always supported two different session strategies. The first being our most popular and default strategy - the JWT based one. The second is the database adapter persisted session strategy. Both have their advantages/disadvantages, you can learn more about them on the [FAQ](/concepts/faq) page.
|
||||
|
||||
Previously, the way you configured this was through the `jwt: boolean` flag in the `session` option. The names `session` and `jwt` might have been a bit overused in the options, and so for a clearer message, we renamed this option to `strategy: "jwt" | "database"`, it is still in the `session` object. This will hopefully better indicate the purpose of this option as well as make very explicit which type of session you are going to use.
|
||||
|
||||
See the [`session` option docs](/reference/configuration/auth-config#session) for more details.
|
||||
|
||||
Introduced in https://github.com/nextauthjs/next-auth/pull/3144
|
||||
|
||||
## Summary
|
||||
|
||||
We hope this migration goes smoothly for each and every one of you! If you have any questions or get stuck anywhere, feel free to create [a new issue](https://github.com/nextauthjs/next-auth/issues/new) on GitHub.
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Getting Started",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Basics",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
---
|
||||
title: Refresh token rotation
|
||||
---
|
||||
|
||||
While Auth.js doesn't automatically handle access token rotation for [OAuth providers](/reference/providers/oauth-builtin) yet, this functionality can be implemented using [callbacks](/guides/basics/callbacks).
|
||||
|
||||
## Source Code
|
||||
|
||||
A working example can be accessed [here](https://github.com/nextauthjs/next-auth-refresh-token-example).
|
||||
|
||||
## Implementation
|
||||
|
||||
### Server Side
|
||||
|
||||
Using a [JWT callback](https://authjs.dev/guides/basics/callbacks#jwt-callback) and a [session callback](https://authjs.dev/guides/basics/callbacks#session-callback), we can persist OAuth tokens and refresh them when they expire.
|
||||
|
||||
Below is a sample implementation using Google's Identity Provider. Please note that the OAuth 2.0 request in the `refreshAccessToken()` function will vary between different providers, but the core logic should remain similar.
|
||||
|
||||
```js title="pages/api/auth/[...nextauth].js"
|
||||
import NextAuth from "next-auth"
|
||||
import GoogleProvider from "next-auth/providers/google"
|
||||
|
||||
const GOOGLE_AUTHORIZATION_URL =
|
||||
"https://accounts.google.com/o/oauth2/v2/auth?" +
|
||||
new URLSearchParams({
|
||||
prompt: "consent",
|
||||
access_type: "offline",
|
||||
response_type: "code",
|
||||
})
|
||||
|
||||
/**
|
||||
* Takes a token, and returns a new token with updated
|
||||
* `accessToken` and `accessTokenExpires`. If an error occurs,
|
||||
* returns the old token and an error property
|
||||
*/
|
||||
async function refreshAccessToken(token) {
|
||||
try {
|
||||
const url =
|
||||
"https://oauth2.googleapis.com/token?" +
|
||||
new URLSearchParams({
|
||||
client_id: process.env.GOOGLE_CLIENT_ID,
|
||||
client_secret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
grant_type: "refresh_token",
|
||||
refresh_token: token.refreshToken,
|
||||
})
|
||||
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
},
|
||||
method: "POST",
|
||||
})
|
||||
|
||||
const refreshedTokens = await response.json()
|
||||
|
||||
if (!response.ok) {
|
||||
throw refreshedTokens
|
||||
}
|
||||
|
||||
return {
|
||||
...token,
|
||||
accessToken: refreshedTokens.access_token,
|
||||
accessTokenExpires: Date.now() + refreshedTokens.expires_at * 1000,
|
||||
refreshToken: refreshedTokens.refresh_token ?? token.refreshToken, // Fall back to old refresh token
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error)
|
||||
|
||||
return {
|
||||
...token,
|
||||
error: "RefreshAccessTokenError",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default NextAuth({
|
||||
providers: [
|
||||
GoogleProvider({
|
||||
clientId: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
authorization: GOOGLE_AUTHORIZATION_URL,
|
||||
}),
|
||||
],
|
||||
callbacks: {
|
||||
async jwt({ token, user, account }) {
|
||||
// Initial sign in
|
||||
if (account && user) {
|
||||
return {
|
||||
accessToken: account.access_token,
|
||||
accessTokenExpires: Date.now() + account.expires_at * 1000,
|
||||
refreshToken: account.refresh_token,
|
||||
user,
|
||||
}
|
||||
}
|
||||
|
||||
// Return previous token if the access token has not expired yet
|
||||
if (Date.now() < token.accessTokenExpires) {
|
||||
return token
|
||||
}
|
||||
|
||||
// Access token has expired, try to update it
|
||||
return refreshAccessToken(token)
|
||||
},
|
||||
async session({ session, token }) {
|
||||
session.user = token.user
|
||||
session.accessToken = token.accessToken
|
||||
session.error = token.error
|
||||
|
||||
return session
|
||||
},
|
||||
},
|
||||
})
|
||||
```
|
||||
|
||||
### Client Side
|
||||
|
||||
The `RefreshAccessTokenError` error that is caught in the `refreshAccessToken()` method is passed all the way to the client. This means that you can direct the user to the sign in flow if we cannot refresh their token.
|
||||
|
||||
We can handle this functionality as a side effect:
|
||||
|
||||
```js title="pages/home.js"
|
||||
import { signIn, useSession } from "next-auth/react";
|
||||
import { useEffect } from "react";
|
||||
|
||||
const HomePage() {
|
||||
const { data: session } = useSession();
|
||||
|
||||
useEffect(() => {
|
||||
if (session?.error === "RefreshAccessTokenError") {
|
||||
signIn(); // Force sign in to hopefully resolve error
|
||||
}
|
||||
}, [session]);
|
||||
|
||||
return (...)
|
||||
}
|
||||
```
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Providers",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Adapters",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Testing",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Corporate proxies",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Other",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
---
|
||||
id: resources
|
||||
title: Community resources
|
||||
---
|
||||
|
||||
> These tutorials are contributed by the community.
|
||||
> **New submissions and edits are welcome!**
|
||||
|
||||
## Basics
|
||||
|
||||
#### [Introduction to Auth.js](https://www.youtube.com/watch?v=npZsJxWntJM) <svg role="img" viewBox="0 0 24 24" height="24" width="24" style={{ marginLeft: '5px', marginBottom:'-6px'}} xmlns="http://www.w3.org/2000/svg"><title>YouTube</title><path fill="#ff0000" d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg>
|
||||
|
||||
- This is an introductory video to Auth.js for beginners. In this video, it is explained how to set up authentication in a few easy steps and add different configurations to make it more robust and secure.
|
||||
|
||||
#### [Authentication patterns for Next.js](https://nextjs.org/docs/authentication) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title><path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- Next.js supports multiple patterns for authentication, each designed for different use cases. This guide will allow you to choose your adventure based on your constraints. By Lee Robinson.
|
||||
|
||||
#### [Adding Authentication to an existing Next.js Application in no time!](https://dev.to/ndom91/adding-authentication-to-an-existing-serverless-next-js-app-in-no-time-with-nextauth-js-192h) <svg style={{ marginLeft: '5px', marginBottom:'-6px'}} width="30" height="25" viewBox="0 0 50 40" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="50" height="40" rx="3" style={{ fill: '#000' }}></rect><path d="M19.099 23.508c0 1.31-.423 2.388-1.27 3.234-.838.839-1.942 1.258-3.312 1.258h-4.403V12.277h4.492c1.31 0 2.385.423 3.224 1.27.846.838 1.269 1.912 1.269 3.223v6.738zm-2.808 0V16.77c0-.562-.187-.981-.562-1.258-.374-.285-.748-.427-1.122-.427h-1.685v10.107h1.684c.375 0 .75-.138 1.123-.415.375-.285.562-.708.562-1.27zM28.185 28h-5.896c-.562 0-1.03-.187-1.404-.561-.375-.375-.562-.843-.562-1.404V14.243c0-.562.187-1.03.562-1.404.374-.375.842-.562 1.404-.562h5.896v2.808H23.13v3.65h3.088v2.808h-3.088v3.65h5.054V28zm7.12 0c-.936 0-1.684-.655-2.246-1.965l-3.65-13.758h3.089l2.807 10.804 2.808-10.804H41.2l-3.65 13.758C36.99 27.345 36.241 28 35.305 28z" style={{ fill: '#fff' }}></path></svg>
|
||||
|
||||
- This tutorial walks one through adding Auth.js to an existing project. Including setting up the OAuth client id and secret, adding the API routes for authentication, protecting pages and API routes behind that authentication, etc.
|
||||
|
||||
#### [Adding social authentication support to a Next.js app](https://getstarted.sh/bulletproof-next/add-social-authentication) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- A tutorial by Arunoda Susirpiala. Checkout [GetStarted](https://getstarted.sh/) for more examples.
|
||||
|
||||
#### [How to Authenticate Next.js Apps with Twitter & Auth.js](https://spacejelly.dev/posts/how-to-authenticate-next-js-apps-with-twitter-nextauth-js/) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- Learn how to add Twitter authentication and login to a Next.js app both client-side and server-side with Auth.js.
|
||||
|
||||
#### [NextJS Authentication Crash Course with Auth.js](https://youtu.be/o_wZIVmWteQ) <svg role="img" viewBox="0 0 24 24" height="24" width="24" style={{ marginLeft: '5px', marginBottom:'-6px'}} xmlns="http://www.w3.org/2000/svg"><title>YouTube</title><path fill="#ff0000" d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg>
|
||||
|
||||
- This tutorial dives into the ins and outs of NextAuth, including using the Email, Github, Twitter and Auth0 providers in under an hour.
|
||||
|
||||
#### [Create your own Auth.js Login Pages](https://youtu.be/kB6YNYZ63fw) <svg role="img" viewBox="0 0 24 24" height="24" width="24" style={{ marginLeft: '5px', marginBottom:'-6px'}} xmlns="http://www.w3.org/2000/svg"><title>YouTube</title><path fill="#ff0000" d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg>
|
||||
|
||||
- This tutorial shows you how to jump in and create your own custom login pages versus using the ones provided by Auth.js
|
||||
|
||||
#### [Passwordless Authentication with next-auth](https://www.youtube.com/watch?v=GPBD3acOx_M) <svg role="img" viewBox="0 0 24 24" height="24" width="24" style={{ marginLeft: '5px', marginBottom:'-6px'}} xmlns="http://www.w3.org/2000/svg"><title>YouTube</title><path fill="#ff0000" d="M23.498 6.186a3.016 3.016 0 0 0-2.122-2.136C19.505 3.545 12 3.545 12 3.545s-7.505 0-9.377.505A3.017 3.017 0 0 0 .502 6.186C0 8.07 0 12 0 12s0 3.93.502 5.814a3.016 3.016 0 0 0 2.122 2.136c1.871.505 9.376.505 9.376.505s7.505 0 9.377-.505a3.015 3.015 0 0 0 2.122-2.136C24 15.93 24 12 24 12s0-3.93-.502-5.814zM9.545 15.568V8.432L15.818 12l-6.273 3.568z"/></svg>
|
||||
|
||||
- A video tutorial by Xiaoru Li from Prisma.
|
||||
|
||||
#### [How to authenticate Next.js Apps with Sign-In With Ethereum (SIWE) & Auth.js](https://docs.login.xyz/integrations/Auth.js) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- Learn how to use Sign-In With Ethereum to authenticate your users with their existing Ethereum wallets - identifiers they personally control.
|
||||
- Example application: [spruceid/siwe-next-auth-example](https://github.com/spruceid/siwe-next-auth-example)
|
||||
|
||||
#### [Next.js Authentication with Okta and Auth.js 4.0](https://thetombomb.com/posts/nextjs-nextauth-okta) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- Learn how to perform authentication with an OIDC Application in Okta and Auth.js.
|
||||
|
||||
## Fullstack
|
||||
|
||||
#### [Build a FullStack App with Next.js, Auth.js, Supabase & Prisma](https://themodern.dev/courses/build-a-fullstack-app-with-nextjs-supabase-and-prisma-322389284337222224) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
In this [free course](https://themodern.dev/courses/build-a-fullstack-app-with-nextjs-supabase-and-prisma-322389284337222224), you'll learn how to build a full-stack app using the following technologies:
|
||||
|
||||
- **Next.js** - The React framework for building the UI of the app and the REST API
|
||||
- **Auth.js** - For implementing passwordless and OAuth authentication
|
||||
- **Supabase** - For persisting the app data into a PostgreSQL database and storing media files
|
||||
- **Prisma** - For making it easy to read and write data from our app from and to the database
|
||||
|
||||
The app that we'll work on in this course is called **_SupaVacation_**. It is an online marketplace for vacation rentals where users can browse through all the properties for rent, bookmark their favorite ones, and even rent their own properties.
|
||||
|
||||
> Here's [a live demo](https://supa-vacation.vercel.app/) of the app's final version. It is what your app should look likes after completing this course. Feel free to play with it to get an overview of all the features you'll be working on.
|
||||
|
||||
#### [Magic Link Authentication in Next.js with NextAuth and Fauna](https://alterclass.io/tutorials/magic-link-authentication-in-nextjs-with-nextauth-and-fauna) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
Learn how to implement passwordless/magic link authentication with database storage in your Next.js projects using NextAuth and Fauna DB.
|
||||
|
||||
> The final version of the project's code can be found on [Github](https://github.com/AlterClassIO/magic-next-auth). You can use it as a starting point for any Next.js app that requires passwordless authentication.
|
||||
|
||||
> You can also preview the example live [here](https://magic-next-auth.vercel.app/).
|
||||
|
||||
This tutorial covers:
|
||||
|
||||
- Configuring Next.js, Auth.js, and Fauna to work together seamlessly
|
||||
- Using Next.js dynamic API routes to handle authentication requests
|
||||
- Using Fauna and the Fauna Adapter for `next-auth` to persist users, email sign in tokens, and sessions
|
||||
- Creating custom login and confirmation pages with React + Tailwind CSS
|
||||
- Customizing the sign-in email and sending a welcome email to new users
|
||||
|
||||
#### [Passwordless Authentication with Next.js, Prisma, and next-auth](https://dev.to/prisma/passwordless-authentication-with-next-js-prisma-and-next-auth-5g8g) <svg style={{ marginLeft: '5px', marginBottom:'-6px'}} width="30" height="25" viewBox="0 0 50 40" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="50" height="40" rx="3" style={{ fill: '#000' }}></rect><path d="M19.099 23.508c0 1.31-.423 2.388-1.27 3.234-.838.839-1.942 1.258-3.312 1.258h-4.403V12.277h4.492c1.31 0 2.385.423 3.224 1.27.846.838 1.269 1.912 1.269 3.223v6.738zm-2.808 0V16.77c0-.562-.187-.981-.562-1.258-.374-.285-.748-.427-1.122-.427h-1.685v10.107h1.684c.375 0 .75-.138 1.123-.415.375-.285.562-.708.562-1.27zM28.185 28h-5.896c-.562 0-1.03-.187-1.404-.561-.375-.375-.562-.843-.562-1.404V14.243c0-.562.187-1.03.562-1.404.374-.375.842-.562 1.404-.562h5.896v2.808H23.13v3.65h3.088v2.808h-3.088v3.65h5.054V28zm7.12 0c-.936 0-1.684-.655-2.246-1.965l-3.65-13.758h3.089l2.807 10.804 2.808-10.804H41.2l-3.65 13.758C36.99 27.345 36.241 28 35.305 28z" style={{ fill: '#fff' }}></path></svg>
|
||||
|
||||
- In this post, you'll learn how to add passwordless authentication to your Next.js app using Prisma and next-auth. By the end of this tutorial, your users will be able to log in to your app with either their GitHub account or a Slack-styled magic link sent right to their Email inbox. By Xiaoru Li.
|
||||
|
||||
#### [Fullstack Authentication Example with Next.js and Auth.js](https://github.com/prisma/prisma-examples/tree/latest/typescript/rest-nextjs-api-routes-auth) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- This example shows how to implement a full-stack app in TypeScript with Next.js using Prisma Client as a backend. It also demonstrates how to implement authentication using Auth.js. By Nikolas Burk at Prisma.
|
||||
|
||||
## Advanced
|
||||
|
||||
#### [Add auth support to a Next.js app with a custom backend](https://arunoda.me/blog/add-auth-support-to-a-next-js-app-with-a-custom-backend) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- A tutorial by Arunoda Susirpiala.
|
||||
|
||||
#### [How to Configure Azure AD B2C Authentication with Next.js](https://benjaminwfox.com/blog/tech/how-to-configure-azure-b2c-with-nextjs) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- Configuring authentication with Azure B2C in Next.js is not a particularly straight forward process. We'll look at how to facilitate this using the Auth.js library. By Ben Fox.
|
||||
|
||||
#### [Sign in with Apple in NextJS](https://thesiddd.com/blog/apple-auth) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- This tutorial walks step by step on how to get sign in with Apple working (both locally and on a deployed website) using Auth.js.
|
||||
|
||||
#### [Using Auth.js with Magic links](https://dev.to/narciero/using-nextauth-js-with-magic-links-df4) <svg style={{ marginLeft: '5px', marginBottom:'-6px'}} width="30" height="25" viewBox="0 0 50 40" fill="none" xmlns="http://www.w3.org/2000/svg"><rect width="50" height="40" rx="3" style={{ fill: '#000' }}></rect><path d="M19.099 23.508c0 1.31-.423 2.388-1.27 3.234-.838.839-1.942 1.258-3.312 1.258h-4.403V12.277h4.492c1.31 0 2.385.423 3.224 1.27.846.838 1.269 1.912 1.269 3.223v6.738zm-2.808 0V16.77c0-.562-.187-.981-.562-1.258-.374-.285-.748-.427-1.122-.427h-1.685v10.107h1.684c.375 0 .75-.138 1.123-.415.375-.285.562-.708.562-1.27zM28.185 28h-5.896c-.562 0-1.03-.187-1.404-.561-.375-.375-.562-.843-.562-1.404V14.243c0-.562.187-1.03.562-1.404.374-.375.842-.562 1.404-.562h5.896v2.808H23.13v3.65h3.088v2.808h-3.088v3.65h5.054V28zm7.12 0c-.936 0-1.684-.655-2.246-1.965l-3.65-13.758h3.089l2.807 10.804 2.808-10.804H41.2l-3.65 13.758C36.99 27.345 36.241 28 35.305 28z" style={{ fill: '#fff' }}></path></svg>
|
||||
|
||||
- Learn how to use [Magic.Link](https://magic.link) authentication with [Auth.js](https://authjs.dev) to enable passwordless authentication without a database.
|
||||
|
||||
## Database
|
||||
|
||||
#### [Create a Auth.js Custom Adapter with HarperDB & Next.js](https://spacejelly.dev/posts/how-to-create-a-nextauth-js-custom-adapter-with-harperdb-next-js/) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- Use a custom database in a Custom Adapter for persisted Auth.js sessions using HarperDB as an example.
|
||||
- Video tutorial also available: <https://www.youtube.com/watch?v=pu7xBv7sZ8s>
|
||||
|
||||
#### [Using Auth.js with Prisma and PlanetScale serverless databases](https://github.com/planetscale/nextjs-planetscale-starter) <svg xmlns="http://www.w3.org/2000/svg" style={{ marginLeft: '5px', marginBottom:'-6px'}} height="20" width="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"><title>External</title> <path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" /> </svg>
|
||||
|
||||
- How to set up a PlanetScale database to fetch and store user / account data with the Prisma adapter.
|
||||
@@ -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.
|
||||
:::
|
||||
@@ -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
|
||||
```
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Configuration",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "Providers",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -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
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"label": "OAuth Providers",
|
||||
"collapsible": true,
|
||||
"collapsed": true
|
||||
}
|
||||
@@ -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)
|
||||
@@ -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.
|
||||
:::
|
||||
@@ -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`
|
||||
:::
|
||||
@@ -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`
|
||||
:::
|
||||
@@ -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=<copy the B2C tenant name here from Step 1>
|
||||
AZURE_AD_B2C_CLIENT_ID=<copy Application (client) ID here from Step 2>
|
||||
AZURE_AD_B2C_CLIENT_SECRET=<copy generated secret value here from Step 2>
|
||||
AZURE_AD_B2C_PRIMARY_USER_FLOW=<copy the name of the signin user flow you created from Step 3>
|
||||
```
|
||||
|
||||
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` } },
|
||||
}),
|
||||
]
|
||||
...
|
||||
|
||||
```
|
||||
@@ -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=<copy Application (client) ID here>
|
||||
AZURE_AD_CLIENT_SECRET=<copy generated client secret value here>
|
||||
AZURE_AD_TENANT_ID=<copy the tenant id here>
|
||||
```
|
||||
|
||||
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,
|
||||
}),
|
||||
]
|
||||
...
|
||||
|
||||
```
|
||||
@@ -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.js)
|
||||
|
||||
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"
|
||||
```
|
||||
@@ -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
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -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';
|
||||
...
|
||||
<Button
|
||||
onClick={async (event) => {
|
||||
event.preventDefault();
|
||||
|
||||
signIn("boxyhq-saml", {}, { tenant, product });
|
||||
}}>
|
||||
...
|
||||
```
|
||||
@@ -1,137 +0,0 @@
|
||||
---
|
||||
id: bungie
|
||||
title: Bungie
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://github.com/Bungie-net/api/wiki/OAuth-Documentation
|
||||
|
||||
## Configuration
|
||||
|
||||
https://www.bungie.net/en/Application
|
||||
|
||||
## Options
|
||||
|
||||
The **Bungie Provider** comes with a set of default options:
|
||||
|
||||
- [Bungie Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/bungie.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import BungieProvider from "next-auth/providers/bungie";
|
||||
...
|
||||
providers: [
|
||||
BungieProvider({
|
||||
clientId: process.env.BUNGIE_CLIENT_ID,
|
||||
clientSecret: process.env.BUNGIE_SECRET,
|
||||
headers: {
|
||||
"X-API-Key": process.env.BUNGIE_API_KEY
|
||||
}
|
||||
}),
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
### Configuration
|
||||
|
||||
:::tip
|
||||
Bungie require all sites to run HTTPS (including local development instances).
|
||||
:::
|
||||
|
||||
:::tip
|
||||
Bungie doesn't allow you to use localhost as the website URL, instead you need to use https://127.0.0.1:3000
|
||||
:::
|
||||
|
||||
Navigate to https://www.bungie.net/en/Application and fill in the required details:
|
||||
|
||||
- Application name
|
||||
- Application Status
|
||||
- Website
|
||||
- OAuth Client Type
|
||||
- Confidential
|
||||
- Redirect URL
|
||||
- https://localhost:3000/api/auth/callback/bungie
|
||||
- Scope
|
||||
- `Access items like your Bungie.net notifications, memberships, and recent Bungie.Net forum activity.`
|
||||
- Origin Header
|
||||
|
||||
The following guide may be helpful:
|
||||
|
||||
- [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)
|
||||
|
||||
### Example server
|
||||
|
||||
You will need to edit your host file and point your site at `127.0.0.1`
|
||||
|
||||
[How to edit my host file?](https://phoenixnap.com/kb/how-to-edit-hosts-file-in-windows-mac-or-linux)
|
||||
|
||||
On Windows (Run Powershell as administrator)
|
||||
|
||||
```ps
|
||||
Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "127.0.0.1`tdev.example.com" -Force
|
||||
```
|
||||
|
||||
```
|
||||
127.0.0.1 dev.example.com
|
||||
```
|
||||
|
||||
#### Create certificate
|
||||
|
||||
Creating a certificate for localhost is easy with openssl. Just put the following command in the terminal. The output will be two files: localhost.key and localhost.crt.
|
||||
|
||||
```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")
|
||||
```
|
||||
|
||||
:::tip
|
||||
**Windows**
|
||||
|
||||
The OpenSSL executable is distributed with [Git](https://git-scm.com/download/win]9) 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`
|
||||
|
||||
```bash
|
||||
req -x509 -out localhost.crt -keyout localhost.key \
|
||||
-newkey rsa:2048 -nodes -sha256 \
|
||||
-subj "/CN=localhost"
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
Create directory `certificates` and place `localhost.key` and `localhost.crt`
|
||||
|
||||
You can create a `server.js` in the root of your project and run it with `node server.js` to test Sign in with Bungie 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")
|
||||
})
|
||||
})
|
||||
```
|
||||
@@ -1,49 +0,0 @@
|
||||
---
|
||||
id: cognito
|
||||
title: Amazon Cognito
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-userpools-server-contract-reference.html
|
||||
|
||||
## Configuration
|
||||
|
||||
https://console.aws.amazon.com/cognito/users/
|
||||
|
||||
You need to select your AWS region to go the the Cognito dashboard.
|
||||
|
||||
## Options
|
||||
|
||||
The **Amazon Cognito Provider** comes with a set of default options:
|
||||
|
||||
- [Amazon Cognito Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/cognito.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import CognitoProvider from "next-auth/providers/cognito";
|
||||
...
|
||||
providers: [
|
||||
CognitoProvider({
|
||||
clientId: process.env.COGNITO_CLIENT_ID,
|
||||
clientSecret: process.env.COGNITO_CLIENT_SECRET,
|
||||
issuer: process.env.COGNITO_ISSUER,
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
:::tip
|
||||
The issuer is a URL, that looks like this: `https://cognito-idp.{region}.amazonaws.com/{PoolId}`
|
||||
:::
|
||||
|
||||
`PoolId` is from `General Settings` in Cognito, not to be confused with the App Client ID.
|
||||
|
||||
:::warning
|
||||
Make sure you select all the appropriate client settings or the OAuth flow will not work.
|
||||
:::
|
||||
|
||||

|
||||
@@ -1,38 +0,0 @@
|
||||
---
|
||||
id: coinbase
|
||||
title: Coinbase
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.coinbase.com/api/v2
|
||||
|
||||
## Configuration
|
||||
|
||||
https://www.coinbase.com/settings/api
|
||||
|
||||
## Options
|
||||
|
||||
The **Coinbase Provider** comes with a set of default options:
|
||||
|
||||
- [Coinbase Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/coinbase.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import CoinbaseProvider from "next-auth/providers/coinbase";
|
||||
...
|
||||
providers: [
|
||||
CoinbaseProvider({
|
||||
clientId: process.env.COINBASE_CLIENT_ID,
|
||||
clientSecret: process.env.COINBASE_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
:::tip
|
||||
This Provider template has a 2 hour access token to it. A refresh token is also returned.
|
||||
:::
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
id: discord
|
||||
title: Discord
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://discord.com/developers/docs/topics/oauth2
|
||||
|
||||
## Configuration
|
||||
|
||||
https://discord.com/developers/applications
|
||||
|
||||
## Options
|
||||
|
||||
The **Discord Provider** comes with a set of default options:
|
||||
|
||||
- [Discord Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/discord.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import DiscordProvider from "next-auth/providers/discord";
|
||||
...
|
||||
providers: [
|
||||
DiscordProvider({
|
||||
clientId: process.env.DISCORD_CLIENT_ID,
|
||||
clientSecret: process.env.DISCORD_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
id: dropbox
|
||||
title: Dropbox
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.dropbox.com/oauth-guide
|
||||
|
||||
## Configuration
|
||||
|
||||
https://www.dropbox.com/developers/apps
|
||||
|
||||
## Options
|
||||
|
||||
The **Dropbox Provider** comes with a set of default options:
|
||||
|
||||
- [Dropbox Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/dropbox.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import DropboxProvider from "next-auth/providers/dropbox";
|
||||
...
|
||||
providers: [
|
||||
DropboxProvider({
|
||||
clientId: process.env.DROPBOX_CLIENT_ID,
|
||||
clientSecret: process.env.DROPBOX_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,51 +0,0 @@
|
||||
---
|
||||
id: eveonline
|
||||
title: EVE Online
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.eveonline.com/blog/article/sso-to-authenticated-calls
|
||||
|
||||
## Configuration
|
||||
|
||||
https://developers.eveonline.com/
|
||||
|
||||
## Options
|
||||
|
||||
The **EVE Online Provider** comes with a set of default options:
|
||||
|
||||
- [EVE Online Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/eveonline.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import EVEOnlineProvider from "next-auth/providers/eveonline";
|
||||
...
|
||||
providers: [
|
||||
EVEOnlineProvider({
|
||||
clientId: process.env.EVE_CLIENT_ID,
|
||||
clientSecret: process.env.EVE_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
:::tip When creating your application, make sure to select `Authentication Only` as the connection type.
|
||||
|
||||
:::tip If using JWT for the session, you can add the `CharacterID` to the JWT token and session. Example:
|
||||
|
||||
```js
|
||||
...
|
||||
options: {
|
||||
callbacks: {
|
||||
session: async ({ session, token }) => {
|
||||
session.user.id = token.id;
|
||||
return session;
|
||||
}
|
||||
}
|
||||
}
|
||||
...
|
||||
```
|
||||
@@ -1,42 +0,0 @@
|
||||
---
|
||||
id: facebook
|
||||
title: Facebook
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.facebook.com/docs/facebook-login/manually-build-a-login-flow/
|
||||
|
||||
## Configuration
|
||||
|
||||
https://developers.facebook.com/apps/
|
||||
|
||||
## Options
|
||||
|
||||
The **Facebook Provider** comes with a set of default options:
|
||||
|
||||
- [Facebook Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/facebook.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import FacebookProvider from "next-auth/providers/facebook";
|
||||
...
|
||||
providers: [
|
||||
FacebookProvider({
|
||||
clientId: process.env.FACEBOOK_CLIENT_ID,
|
||||
clientSecret: process.env.FACEBOOK_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
:::tip
|
||||
Production applications cannot use localhost URLs to sign in with Facebook. You need to use a dedicated development application in Facebook to use **localhost** callback URLs.
|
||||
:::
|
||||
|
||||
:::tip
|
||||
Email address may not be returned for accounts created on mobile.
|
||||
:::
|
||||
@@ -1,38 +0,0 @@
|
||||
---
|
||||
id: faceit
|
||||
title: FACEIT
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://cdn.faceit.com/third_party/docs/FACEIT_Connect_3.0.pdf
|
||||
|
||||
## Configuration
|
||||
|
||||
https://developers.faceit.com/apps
|
||||
|
||||
Grant type: `Authorization Code`
|
||||
|
||||
Scopes to have basic infos (email, nickname, guid and avatar) : `openid`, `email`, `profile`
|
||||
|
||||
## Options
|
||||
|
||||
The **FACEIT Provider** comes with a set of default options:
|
||||
|
||||
- [FACEIT Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/faceit.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import FaceItProvider from "next-auth/providers/faceit";
|
||||
...
|
||||
providers: [
|
||||
FaceItProvider({
|
||||
clientId: process.env.FACEIT_CLIENT_ID,
|
||||
clientSecret: process.env.FACEIT_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,39 +0,0 @@
|
||||
---
|
||||
id: foursquare
|
||||
title: Foursquare
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developer.foursquare.com/docs/places-api/authentication/#web-applications
|
||||
|
||||
## Configuration
|
||||
|
||||
https://developer.foursquare.com/
|
||||
|
||||
:::warning
|
||||
Foursquare requires an additional `apiVersion` parameter in [`YYYYMMDD` format](https://developer.foursquare.com/docs/places-api/versioning/), which essentially states "I'm prepared for API changes up to this date".
|
||||
:::
|
||||
|
||||
## Options
|
||||
|
||||
The **Foursquare Provider** comes with a set of default options:
|
||||
|
||||
- [Foursquare Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/foursquare.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import FourSquareProvider from "next-auth/providers/foursquare";
|
||||
...
|
||||
providers: [
|
||||
FourSquareProvider({
|
||||
clientId: process.env.FOURSQUARE_CLIENT_ID,
|
||||
clientSecret: process.env.FOURSQUARE_CLIENT_SECRET,
|
||||
apiVersion: "YYYYMMDD"
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
id: freshbooks
|
||||
title: Freshbooks
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://www.freshbooks.com/api/authenticating-with-oauth-2-0-on-the-new-freshbooks-api
|
||||
|
||||
## Configuration
|
||||
|
||||
https://my.freshbooks.com/#/developer
|
||||
|
||||
## Options
|
||||
|
||||
The Freshbooks Provider comes with a set of default options:
|
||||
|
||||
https://www.freshbooks.com/api/start
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import FreshbooksProvider from "next-auth/providers/freshbooks";
|
||||
...
|
||||
providers: [
|
||||
FreshbooksProvider({
|
||||
clientId: process.env.FRESHBOOKS_CLIENT_ID,
|
||||
clientSecret: process.env.FRESHBOOKS_CLIENT_SECRET,
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,59 +0,0 @@
|
||||
---
|
||||
id: fusionauth
|
||||
title: FusionAuth
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://fusionauth.io/docs/v1/tech/oauth/
|
||||
|
||||
## Options
|
||||
|
||||
The **FusionAuth Provider** comes with a set of default options:
|
||||
|
||||
- [FusionAuth Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/fusionauth.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import FusionAuthProvider from "next-auth/providers/fusionauth";
|
||||
...
|
||||
providers: [
|
||||
FusionAuthProvider({
|
||||
id: "fusionauth",
|
||||
name: "FusionAuth",
|
||||
issuer: process.env.FUSIONAUTH_ISSUER,
|
||||
clientId: process.env.FUSIONAUTH_CLIENT_ID,
|
||||
clientSecret: process.env.FUSIONAUTH_SECRET,
|
||||
tenantId: process.env.FUSIONAUTH_TENANT_ID // Only required if you're using multi-tenancy
|
||||
}),
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
:::warning
|
||||
If you're using multi-tenancy, you need to pass in the `tenantId` option to apply the proper theme.
|
||||
:::
|
||||
|
||||
## Instructions
|
||||
|
||||
### Configuration
|
||||
|
||||
:::tip
|
||||
An application can be created at https://your-fusionauth-server-url/admin/application.
|
||||
|
||||
For more information, follow the [FusionAuth 5-minute setup guide](https://fusionauth.io/docs/v1/tech/5-minute-setup-guide).
|
||||
:::
|
||||
|
||||
In the OAuth settings for your application, configure the following.
|
||||
|
||||
- Redirect URL
|
||||
- https://localhost:3000/api/auth/callback/fusionauth
|
||||
- Enabled grants
|
||||
- Make sure _Authorization Code_ is enabled.
|
||||
|
||||
If using JSON Web Tokens, you need to make sure the signing algorithm is RS256, you can create an RS256 key pair by
|
||||
going to Settings, Key Master, generate RSA and choosing SHA-256 as algorithm. After that, go to the JWT settings of
|
||||
your application and select this key as Access Token signing key and Id Token signing key.
|
||||
@@ -1,46 +0,0 @@
|
||||
---
|
||||
id: github
|
||||
title: GitHub
|
||||
---
|
||||
|
||||
:::note
|
||||
GitHub returns a field on `Account` called `refresh_token_expires_in` which is a number. See their [docs](https://docs.github.com/en/developers/apps/building-github-apps/refreshing-user-to-server-access-tokens#response). Remember to add this field to your database schema, in case if you are using an [Adapter](/reference/adapters/overview).
|
||||
:::
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developer.github.com/apps/building-oauth-apps/authorizing-oauth-apps
|
||||
|
||||
## Configuration
|
||||
|
||||
https://github.com/settings/apps
|
||||
|
||||
## Options
|
||||
|
||||
The **GitHub Provider** comes with a set of default options:
|
||||
|
||||
- [GitHub Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/github.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import GitHubProvider from "next-auth/providers/github";
|
||||
...
|
||||
providers: [
|
||||
GitHubProvider({
|
||||
clientId: process.env.GITHUB_ID,
|
||||
clientSecret: process.env.GITHUB_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
:::warning
|
||||
Only allows one callback URL per Client ID / Client Secret.
|
||||
:::
|
||||
|
||||
:::tip
|
||||
Email address is always returned, even if the user doesn't have a public email address on their profile.
|
||||
:::
|
||||
@@ -1,38 +0,0 @@
|
||||
---
|
||||
id: gitlab
|
||||
title: GitLab
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://docs.gitlab.com/ee/api/oauth2.html
|
||||
|
||||
## Configuration
|
||||
|
||||
https://gitlab.com/-/profile/applications
|
||||
|
||||
## Options
|
||||
|
||||
The **Gitlab Provider** comes with a set of default options:
|
||||
|
||||
- [Gitlab Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/gitlab.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import GitlabProvider from "next-auth/providers/gitlab";
|
||||
...
|
||||
providers: [
|
||||
GitlabProvider({
|
||||
clientId: process.env.GITLAB_CLIENT_ID,
|
||||
clientSecret: process.env.GITLAB_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
:::tip
|
||||
Enable the _"read_user"_ option in scope if you want to save the users email address on sign up.
|
||||
:::
|
||||
@@ -1,93 +0,0 @@
|
||||
---
|
||||
id: google
|
||||
title: Google
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.google.com/identity/protocols/oauth2
|
||||
|
||||
## Configuration
|
||||
|
||||
https://console.developers.google.com/apis/credentials
|
||||
|
||||
The "Authorized redirect URIs" used when creating the credentials must include your full domain and end in the callback path. For example;
|
||||
|
||||
- For production: `https://{YOUR_DOMAIN}/api/auth/callback/google`
|
||||
- For development: `http://localhost:3000/api/auth/callback/google`
|
||||
|
||||
## Options
|
||||
|
||||
The **Google Provider** comes with a set of default options:
|
||||
|
||||
- [Google Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/google.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import GoogleProvider from "next-auth/providers/google";
|
||||
...
|
||||
providers: [
|
||||
GoogleProvider({
|
||||
clientId: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
:::warning
|
||||
Google only provides Refresh Token to an application the first time a user signs in.
|
||||
|
||||
To force Google to re-issue a Refresh Token, the user needs to remove the application from their account and sign in again:
|
||||
https://myaccount.google.com/permissions
|
||||
|
||||
Alternatively, you can also pass options in the `params` object of `authorization` which will force the Refresh Token to always be provided on sign in, however this will ask all users to confirm if they wish to grant your application access every time they sign in.
|
||||
|
||||
If you need access to the RefreshToken or AccessToken for a Google account and you are not using a database to persist user accounts, this may be something you need to do.
|
||||
|
||||
```js
|
||||
const options = {
|
||||
...
|
||||
providers: [
|
||||
GoogleProvider({
|
||||
clientId: process.env.GOOGLE_ID,
|
||||
clientSecret: process.env.GOOGLE_SECRET,
|
||||
authorization: {
|
||||
params: {
|
||||
prompt: "consent",
|
||||
access_type: "offline",
|
||||
response_type: "code"
|
||||
}
|
||||
}
|
||||
})
|
||||
],
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
:::
|
||||
|
||||
:::tip
|
||||
Google also returns a `email_verified` boolean property in the OAuth profile.
|
||||
|
||||
You can use this property to restrict access to people with verified accounts at a particular domain.
|
||||
|
||||
```js
|
||||
const options = {
|
||||
...
|
||||
callbacks: {
|
||||
async signIn({ account, profile }) {
|
||||
if (account.provider === "google") {
|
||||
return profile.email_verified && profile.email.endsWith("@example.com")
|
||||
}
|
||||
return true // Do different verification for other providers that don't have `email_verified`
|
||||
},
|
||||
}
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
:::
|
||||
@@ -1,61 +0,0 @@
|
||||
---
|
||||
id: identity-server4
|
||||
title: IdentityServer4
|
||||
---
|
||||
|
||||
:::warning
|
||||
[IdentityServer4 is discontinued](https://identityserver4.readthedocs.io/en/latest/#:~:text=until%20November%202022.) and only releases security updates until November 2022. You should consider an alternative provider.
|
||||
:::
|
||||
|
||||
## Documentation
|
||||
|
||||
https://identityserver4.readthedocs.io/en/latest/
|
||||
|
||||
## Options
|
||||
|
||||
The **IdentityServer4 Provider** comes with a set of default options:
|
||||
|
||||
- [IdentityServer4 Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/identity-server4.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import IdentityServer4Provider from "next-auth/providers/identity-server4";
|
||||
...
|
||||
providers: [
|
||||
IdentityServer4Provider({
|
||||
id: "identity-server4",
|
||||
name: "IdentityServer4",
|
||||
issuer: process.env.IdentityServer4_Issuer,
|
||||
clientId: process.env.IdentityServer4_CLIENT_ID,
|
||||
clientSecret: process.env.IdentityServer4_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
## Demo IdentityServer
|
||||
|
||||
The configuration below is for the demo server at https://demo.identityserver.io/
|
||||
|
||||
If you want to try it out, you can copy and paste the configuration below.
|
||||
|
||||
You can sign in to the demo service with either <b>bob/bob</b> or <b>alice/alice</b>.
|
||||
|
||||
```js
|
||||
import IdentityServer4Provider from `next-auth/providers/identity-server4`
|
||||
...
|
||||
providers: [
|
||||
IdentityServer4Provider({
|
||||
id: "demo-identity-server",
|
||||
name: "Demo IdentityServer4",
|
||||
authorization: { params: { scope: "openid profile email api offline_access" } },
|
||||
issuer: "https://demo.identityserver.io/",
|
||||
clientId: "interactive.confidential",
|
||||
clientSecret: "secret",
|
||||
})
|
||||
}
|
||||
...
|
||||
```
|
||||
@@ -1,50 +0,0 @@
|
||||
---
|
||||
id: instagram
|
||||
title: Instagram
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.facebook.com/docs/instagram-basic-display-api/getting-started
|
||||
|
||||
## Configuration
|
||||
|
||||
https://developers.facebook.com/apps/
|
||||
|
||||
## Options
|
||||
|
||||
The **Instagram Provider** comes with a set of default options:
|
||||
|
||||
- [Instagram Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/instagram.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```jsx
|
||||
// pages/api/auth/[...nextauth].js
|
||||
import InstagramProvider from "next-auth/providers/instagram";
|
||||
...
|
||||
providers: [
|
||||
InstagramProvider({
|
||||
clientId: process.env.INSTAGRAM_CLIENT_ID,
|
||||
clientSecret: process.env.INSTAGRAM_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
// pages/index.jsx
|
||||
import { signIn } from "next-auth/react"
|
||||
...
|
||||
<button onClick={() => signIn("instagram")}>
|
||||
Sign in
|
||||
</button>
|
||||
...
|
||||
```
|
||||
|
||||
:::warning
|
||||
Email address is not returned by the Instagram API.
|
||||
:::
|
||||
|
||||
:::tip
|
||||
Instagram display app required callback URL to be configured in your Facebook app and Facebook required you to use **https** even for localhost! In order to do that, you either need to [add an SSL to your localhost](https://www.freecodecamp.org/news/how-to-get-https-working-on-your-local-development-environment-in-5-minutes-7af615770eec/) or use a proxy such as [ngrok](https://ngrok.com/docs).
|
||||
:::
|
||||
@@ -1,40 +0,0 @@
|
||||
---
|
||||
id: kakao
|
||||
title: Kakao
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.kakao.com/product/kakaoLogin
|
||||
|
||||
## Configuration
|
||||
|
||||
https://developers.kakao.com/docs/latest/en/kakaologin/common
|
||||
|
||||
## Options
|
||||
|
||||
The **Kakao Provider** comes with a set of default options:
|
||||
|
||||
- [Kakao Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/kakao.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import KakaoProvider from "next-auth/providers/kakao";
|
||||
...
|
||||
providers: [
|
||||
KakaoProvider({
|
||||
clientId: process.env.KAKAO_CLIENT_ID,
|
||||
clientSecret: process.env.KAKAO_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
## Instructions
|
||||
|
||||
### Configuration
|
||||
|
||||
Create a provider and a Kakao application at `https://developers.kakao.com/console/app`. In the settings of the app under Kakao Login, activate web app, change consent items and configure callback URL.
|
||||
@@ -1,41 +0,0 @@
|
||||
---
|
||||
id: keycloak
|
||||
title: Keycloak
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://www.keycloak.org/docs/latest/server_admin/#_oidc_clients
|
||||
|
||||
## Configuration
|
||||
|
||||
:::tip
|
||||
Create an openid-connect client in Keycloak with "confidential" as the "Access Type".
|
||||
:::
|
||||
|
||||
## Options
|
||||
|
||||
The **Keycloak Provider** comes with a set of default options:
|
||||
|
||||
- [Keycloak Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/keycloak.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import KeycloakProvider from "next-auth/providers/keycloak";
|
||||
...
|
||||
providers: [
|
||||
KeycloakProvider({
|
||||
clientId: process.env.KEYCLOAK_ID,
|
||||
clientSecret: process.env.KEYCLOAK_SECRET,
|
||||
issuer: process.env.KEYCLOAK_ISSUER,
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
:::note
|
||||
`issuer` should include the realm – e.g. `https://my-keycloak-domain.com/realms/My_Realm`
|
||||
:::
|
||||
@@ -1,47 +0,0 @@
|
||||
---
|
||||
id: line
|
||||
title: LINE
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.line.biz/en/docs/line-login/integrate-line-login/
|
||||
|
||||
## Configuration
|
||||
|
||||
https://developers.line.biz/console/
|
||||
|
||||
## Options
|
||||
|
||||
The **Line Provider** comes with a set of default options:
|
||||
|
||||
- [Line Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/line.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import LineProvider from "next-auth/providers/line";
|
||||
...
|
||||
providers: [
|
||||
LineProvider({
|
||||
clientId: process.env.LINE_CLIENT_ID,
|
||||
clientSecret: process.env.LINE_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
|
||||
## Instructions
|
||||
|
||||
### Configuration
|
||||
|
||||
Create a provider and a LINE login channel at `https://developers.line.biz/console/`. In the settings of the channel under LINE Login, activate web app and configure the following:
|
||||
|
||||
- Callback URL
|
||||
- http://localhost:3000/api/auth/callback/line
|
||||
|
||||
:::tip
|
||||
To retrieve email address, you need to apply for Email address permission. Open [Line Developer Console](https://developers.line.biz/console/), go to your Login Channel. Scroll down bottom to find **OpenID Connect** -> **Email address permission**. Click **Apply** and follow the instruction.
|
||||
:::
|
||||
@@ -1,38 +0,0 @@
|
||||
---
|
||||
id: linkedin
|
||||
title: LinkedIn
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://docs.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow
|
||||
|
||||
## Configuration
|
||||
|
||||
https://www.linkedin.com/developers/apps/
|
||||
|
||||
From the Auth tab get the client ID and client secret. On the same tab, add redirect URLs such as http://localhost:3000/api/auth/callback/linkedin so LinkedIn can correctly redirect back to your application. Finally, head over to the Products tab and enable the "Sign In with LinkedIn" product. The LinkedIn team will review and approve your request before you can test it out.
|
||||
|
||||

|
||||
|
||||
## Options
|
||||
|
||||
The **LinkedIn Provider** comes with a set of default options:
|
||||
|
||||
- [LinkedIn Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/linkedin.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import LinkedInProvider from "next-auth/providers/linkedin";
|
||||
...
|
||||
providers: [
|
||||
LinkedInProvider({
|
||||
clientId: process.env.LINKEDIN_CLIENT_ID,
|
||||
clientSecret: process.env.LINKEDIN_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
id: mailchimp
|
||||
title: Mailchimp
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://mailchimp.com/developer/marketing/guides/access-user-data-oauth-2/
|
||||
|
||||
## Configuration
|
||||
|
||||
https://admin.mailchimp.com/account/oauth2/client/
|
||||
|
||||
## Options
|
||||
|
||||
The **Mailchimp Provider** comes with a set of default options:
|
||||
|
||||
- [Mailchimp Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/mailchimp.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import MailchimpProvider from "next-auth/providers/mailchimp";
|
||||
...
|
||||
providers: [
|
||||
MailchimpProvider({
|
||||
clientId: process.env.MAILCHIMP_CLIENT_ID,
|
||||
clientSecret: process.env.MAILCHIMP_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
id: mailru
|
||||
title: Mail.ru
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://o2.mail.ru/docs
|
||||
|
||||
## Configuration
|
||||
|
||||
https://o2.mail.ru/app/
|
||||
|
||||
## Options
|
||||
|
||||
The **Mail.ru Provider** comes with a set of default options:
|
||||
|
||||
- [Mail.ru Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/mailru.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import MailRuProvider from "next-auth/providers/mailru";
|
||||
...
|
||||
providers: [
|
||||
MailRuProvider({
|
||||
clientId: process.env.MAILRU_CLIENT_ID,
|
||||
clientSecret: process.env.MAILRU_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,38 +0,0 @@
|
||||
---
|
||||
id: medium
|
||||
title: Medium
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://github.com/Medium/medium-api-docs
|
||||
|
||||
## Configuration
|
||||
|
||||
https://medium.com/me/applications
|
||||
|
||||
## Options
|
||||
|
||||
The **Medium Provider** comes with a set of default options:
|
||||
|
||||
- [Medium Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/medium.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import MediumProvider from "next-auth/providers/medium";
|
||||
...
|
||||
providers: [
|
||||
MediumProvider({
|
||||
clientId: process.env.MEDIUM_CLIENT_ID,
|
||||
clientSecret: process.env.MEDIUM_CLIENT_SECRET
|
||||
})
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
:::warning
|
||||
Email address is not returned by the Medium API.
|
||||
:::
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
id: naver
|
||||
title: Naver
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.naver.com/docs/login/overview/overview.md
|
||||
|
||||
## Configuration
|
||||
|
||||
https://developers.naver.com/docs/login/api/api.md
|
||||
|
||||
## Options
|
||||
|
||||
The **Naver Provider** comes with a set of default options:
|
||||
|
||||
- [Naver Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/naver.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import NaverProvider from "next-auth/providers/naver";
|
||||
...
|
||||
providers: [
|
||||
NaverProvider({
|
||||
clientId: process.env.NAVER_CLIENT_ID,
|
||||
clientSecret: process.env.NAVER_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,34 +0,0 @@
|
||||
---
|
||||
id: netlify
|
||||
title: Netlify
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://www.netlify.com/blog/2016/10/10/integrating-with-netlify-oauth2/
|
||||
|
||||
## Configuration
|
||||
|
||||
https://github.com/netlify/netlify-oauth-example
|
||||
|
||||
## Options
|
||||
|
||||
The **Netlify Provider** comes with a set of default options:
|
||||
|
||||
- [Netlify Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/netlify.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import NetlifyProvider from "next-auth/providers/netlify";
|
||||
...
|
||||
providers: [
|
||||
NetlifyProvider({
|
||||
clientId: process.env.NETLIFY_CLIENT_ID,
|
||||
clientSecret: process.env.NETLIFY_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
id: okta
|
||||
title: Okta
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developer.okta.com/docs/reference/api/oidc
|
||||
|
||||
## Options
|
||||
|
||||
The **Okta Provider** comes with a set of default options:
|
||||
|
||||
- [Okta Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/okta.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import OktaProvider from "next-auth/providers/okta";
|
||||
...
|
||||
providers: [
|
||||
OktaProvider({
|
||||
clientId: process.env.OKTA_CLIENT_ID,
|
||||
clientSecret: process.env.OKTA_CLIENT_SECRET,
|
||||
issuer: process.env.OKTA_ISSUER
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,35 +0,0 @@
|
||||
---
|
||||
id: onelogin
|
||||
title: OneLogin
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://developers.onelogin.com/openid-connect
|
||||
|
||||
## Configuration
|
||||
|
||||
https://developers.onelogin.com/openid-connect/connect-to-onelogin
|
||||
|
||||
## Options
|
||||
|
||||
The **OneLogin Provider** comes with a set of default options:
|
||||
|
||||
- [OneLogin Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/onelogin.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import OneLoginProvider from "next-auth/providers/onelogin";
|
||||
...
|
||||
providers: [
|
||||
OneLoginProvider({
|
||||
clientId: process.env.ONELOGIN_CLIENT_ID,
|
||||
clientSecret: process.env.ONELOGIN_CLIENT_SECRET,
|
||||
issuer: process.env.ONELOGIN_ISSUER
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
@@ -1,47 +0,0 @@
|
||||
---
|
||||
id: osso
|
||||
title: Osso
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
Osso is an open source service that handles SAML authentication against Identity Providers, normalizes profiles, and makes those profiles available to you in an OAuth 2.0 code grant flow.
|
||||
|
||||
If you don't yet have an Osso instance, you can use [Osso's Demo App](https://demo.ossoapp.com) for your testing purposes. For documentation on deploying an Osso instance, see https://ossoapp.com/docs/deploy/overview/
|
||||
|
||||
## Configuration
|
||||
|
||||
You can configure your OAuth Clients on your Osso Admin UI, i.e. https://demo.ossoapp.com/admin/config - you'll need to get a Client ID and Secret and allow-list your redirect URIs.
|
||||
|
||||
[SAML SSO differs a bit from OAuth](https://ossoapp.com/blog/saml-vs-oauth) - for every tenant who wants to sign in to your application using SAML, you and your customer need to perform a multi-step configuration in Osso's Admin UI and the admin dashboard of the tenant's Identity Provider. Osso provides documentation for providers like Okta and OneLogin, cloud-based IDPs who also offer a developer account that's useful for testing. Osso also provides a [Mock IDP](https://idp.ossoapp.com) that you can use for testing without needing to sign up for an Identity Provider service.
|
||||
|
||||
See Osso's complete configuration and testing documentation at https://ossoapp.com/docs/configure/overview
|
||||
|
||||
## Options
|
||||
|
||||
The **Osso Provider** comes with a set of default options:
|
||||
|
||||
- [Osso Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/osso.js)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
## Example
|
||||
|
||||
A full example application is available at https://github.com/enterprise-oss/osso-next-auth-example and https://nextjs-demo.ossoapp.com
|
||||
|
||||
```js
|
||||
import OssoProvider from "next-auth/providers/osso";
|
||||
...
|
||||
providers: [
|
||||
OssoProvider({
|
||||
clientId: process.env.OSSO_CLIENT_ID,
|
||||
clientSecret: process.env.OSSO_CLIENT_SECRET,
|
||||
issuer: process.env.OSSO_ISSUER
|
||||
})
|
||||
}
|
||||
...
|
||||
```
|
||||
|
||||
:::note
|
||||
`issuer` should be the fully qualified domain – e.g. `demo.ossoapp.com`
|
||||
:::
|
||||
@@ -1,38 +0,0 @@
|
||||
---
|
||||
id: osu
|
||||
title: Osu!
|
||||
---
|
||||
|
||||
## Documentation
|
||||
|
||||
https://osu.ppy.sh/docs/index.html#authentication
|
||||
|
||||
## Configuration
|
||||
|
||||
https://osu.ppy.sh/home/account/edit#new-oauth-application
|
||||
|
||||
## Options
|
||||
|
||||
The **Osu Provider** comes with a set of default options:
|
||||
|
||||
- [Osu Provider options](https://github.com/nextauthjs/next-auth/blob/main/packages/next-auth/src/providers/osu.ts)
|
||||
|
||||
You can override any of the options to suit your own use case.
|
||||
|
||||
:::note
|
||||
Osu! does **not** provide a user email!
|
||||
:::
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
import OsuProvider from "next-auth/providers/osu";
|
||||
...
|
||||
providers: [
|
||||
OsuProvider({
|
||||
clientId: process.env.OSU_CLIENT_ID,
|
||||
clientSecret: process.env.OSU_CLIENT_SECRET
|
||||
})
|
||||
]
|
||||
...
|
||||
```
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user