Compare commits

...

536 Commits

Author SHA1 Message Date
Balázs Orbán
b3be2e1c39 chore(release): bump version 2022-04-20 17:03:00 +00:00
Balázs Orbán
afdb3c8d7c fix: more strict default callback url handling 2022-04-20 18:52:24 +02:00
Raúl Marín
fd755bc29e fix(signin): set email sign-in input to "email" & "required"(#4352)
* fix(core\pages\signin.tsx): set type of built-in email sign-in input to email for browse validation
* fix(core\pages\signin.tsx): add required attribute to built-in sign-in email input

Co-authored-by: Lluis Agusti <hi@llu.lu>
2022-04-15 19:12:01 +02:00
Yisu Kim
59daa0e43f fix(providers): add optional chaining to avoid nullish reference errors (#4365) 2022-04-14 16:35:54 +02:00
Simon Kirsten
58d06ed727 fix: Cleanup global __NEXTAUTH state after unmount (#4383) 2022-04-14 16:35:10 +02:00
Salah Eddine
82159d3e8f docs: remove auth from keycloack url (#4391)
in keycloak 17.0+ , There's a change in endpoints as per the official documentation (https://www.keycloak.org/docs-api/11.0/rest-api/index.html#_users_resource) .
so the new url well be https://my-keycloak-domain.com/realms/My_Realm
2022-04-14 16:28:21 +02:00
Balázs Orbán
abb9fed7aa chore: bump versions 2022-04-14 11:09:32 +02:00
Balázs Orbán
5471c0f675 chore: use --no-workspaces
See: https://github.com/npm/cli/issues/4605#issuecomment-1076900100
2022-04-14 11:03:27 +02:00
Balázs Orbán
b2da0b38d4 chore: add --verbose 2022-04-14 10:54:20 +02:00
Balázs Orbán
b3b8d4be46 chore: log npm config list 2022-04-13 18:05:21 +02:00
Balázs Orbán
182e118d9b chore: else 2022-04-13 15:19:18 +02:00
Balázs Orbán
7183b06939 chore: write .npmrc 2022-04-13 15:18:35 +02:00
Balázs Orbán
bd10e87bf4 chore: more visible log 2022-04-13 15:08:14 +02:00
Balázs Orbán
d07abfe517 chore: log 2022-04-13 15:00:44 +02:00
Balázs Orbán
c1110cdc98 chore: don't write .npmrc 2022-04-13 14:35:57 +02:00
Balázs Orbán
8ed038d891 chore: revert 2022-04-12 17:05:40 +02:00
Balázs Orbán
b25425795b chore: CI=1 2022-04-12 17:01:16 +02:00
Balázs Orbán
ad1650a817 chore: no brackets 2022-04-12 16:52:09 +02:00
Balázs Orbán
a4a487a22a chore: NPM_TOKEN_PKG 2022-04-12 16:46:26 +02:00
Balázs Orbán
b30de36126 chore: remove cat 2022-04-12 16:36:38 +02:00
Balázs Orbán
41e4e515ad chore: cat .npmrc 2022-04-12 16:35:12 +02:00
Balázs Orbán
cde1f82e3c chore: revert 2022-04-12 16:26:55 +02:00
Balázs Orbán
c39782007b chore: pkg vs org? 2022-04-12 16:22:33 +02:00
Balázs Orbán
984a089c15 chore: ignore .npmrc 2022-04-12 16:10:04 +02:00
Balázs Orbán
26f8b8c1f1 chore: remove npm whoami 2022-04-12 16:09:27 +02:00
Balázs Orbán
afc9b43c53 chore: npm whoami 2022-04-12 16:03:02 +02:00
Balázs Orbán
cdbd9ac2e6 chore: manually upgrade dep version 2022-04-12 15:39:55 +02:00
Balázs Orbán
3d8cc316f1 chore: debug release script 2022-04-12 15:32:50 +02:00
Balázs Orbán
3b8c568f79 chore: trigger deploy 2022-04-12 15:22:57 +02:00
Balázs Orbán
16668d307d docs: revert 2022-04-12 14:17:00 +02:00
Balázs Orbán
6e15bdcb2d fix: update default callbacks.redirect 2022-04-12 14:14:35 +02:00
Yisu Kim
7a4bf038b1 Update callbacks.md (#4361)
missing async keyword
2022-04-09 22:23:26 +02:00
Francis Gulotta
11ad64f617 docs: add google oauth URI examples (#4347)
* docs: add google oauth URI examples

* Update docs/docs/providers/google.md

Co-authored-by: Lluis Agusti <hi@llu.lu>

Co-authored-by: Lluis Agusti <hi@llu.lu>
2022-04-09 09:45:55 +02:00
Francis Gulotta
0a278b9297 docs: callbacks can now be relative (#4346)
* docs: callbacks can now be relative

since v4 anyway

* Update docs/docs/getting-started/client.md

Co-authored-by: Lluis Agusti <hi@llu.lu>

Co-authored-by: Lluis Agusti <hi@llu.lu>
2022-04-09 09:45:19 +02:00
Francis Gulotta
8c8070f30b docs(client): fix type in signIn examples (#4308) 2022-04-07 12:58:06 +02:00
Christopher Reece
6442d089c1 docs(adapters): update providerAccount to account (#4329) 2022-04-07 12:45:41 +02:00
Francis Gulotta
63398d4c3f docs: Update JWT docs to reflect JWE changes in v4 (#4313)
* docs: Update JWT docs to reflect JWE changes in v4

This PR https://github.com/nextauthjs/next-auth/pull/3039 changed the defaults for JWT tokens to be encrypted by default (JWE). We have conflicting documentation across the docs site and readme.

Additionatlly this PR https://github.com/nextauthjs/next-auth/pull/3783 made providing a secret required in production via NEXTAUTH_SECRET or an option.

* Missed a reference

* Update docs/docs/faq.md

Co-authored-by: Nico Domino <yo@ndo.dev>

* Update docs/docs/faq.md

Co-authored-by: Nico Domino <yo@ndo.dev>

Co-authored-by: Nico Domino <yo@ndo.dev>
2022-04-05 12:48:06 +02:00
Oliver Terbu
0d54170e83 feat: added siwe tutorial (#4276)
Co-authored-by: Oliver Terbu <oliver@awoie.local>
2022-04-04 22:52:55 +02:00
Francis Gulotta
174f0d6aec chore(docs): fix Custom Client Session Handling example (#4310)
* docs: fix Custom Client Session Handling example

It made reference to a useEffect call that was no longer needed.

* Update docs/docs/getting-started/client.md

Co-authored-by: Lluis Agusti <hi@llu.lu>

Co-authored-by: Lluis Agusti <hi@llu.lu>
2022-04-04 22:11:59 +02:00
Francis Gulotta
f91b9dc03d docs: Add some more context to the adapters page (#4303)
Link the models to the adapters page to provide some context about what is passed into each function.

Co-authored-by: Nico Domino <yo@ndo.dev>
2022-04-02 12:48:19 +02:00
Sriram Jothiswaran
8763e4aeb9 chore(docs): update prisma mongodb connector required modifications (#4304)
* Update for Mongodb prisma connector 

In reference to https://www.prisma.io/docs/reference/api-reference/prisma-schema-reference#model-field-scalar-types, for scalar type String the native MongoDB type attribute is @db.String.

* Update prisma.md
2022-04-02 12:48:06 +02:00
Danny Luedke
e936c51575 Fix API directory (#4283)
Update the API directory from `pages/api/[...nextauth].ts` to `pages/api/auth/[...nextauth].ts`  so it matches the typescript example.
2022-03-29 22:44:24 +02:00
dependabot[bot]
8d7ba75bca chore(deps): bump minimist in /apps/playground-sveltekit (#4261)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-28 11:18:36 +02:00
dependabot[bot]
67038b4022 chore(deps): bump node-forge from 1.2.1 to 1.3.0 (#4262)
Bumps [node-forge](https://github.com/digitalbazaar/forge) from 1.2.1 to 1.3.0.
- [Release notes](https://github.com/digitalbazaar/forge/releases)
- [Changelog](https://github.com/digitalbazaar/forge/blob/main/CHANGELOG.md)
- [Commits](https://github.com/digitalbazaar/forge/compare/v1.2.1...v1.3.0)

---
updated-dependencies:
- dependency-name: node-forge
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-28 11:18:24 +02:00
dependabot[bot]
5b7ce98a87 chore(deps): bump minimist from 1.2.5 to 1.2.6 (#4263)
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-03-28 11:18:07 +02:00
Chandler GREFF
1c468f057d docs: fix return type in jwt decode example (#4273) 2022-03-28 11:17:52 +02:00
Nico Domino
ef22c5b835 chore(docs): add carbon ads to docs sidebar (#4250)
* chore(docs): add carbon ads to docs page

* fix: add carbon-wrap element

* fix: script in docusaurus config object

* fix: add _carbonads_js id

* fix: add script directly to sidebar

* fix: carbon ads style

* chore: bump ad container down a bit
2022-03-25 19:24:05 +01:00
Grégory D'Angelo
a912739b24 chore(docs): add full stack course (Next.js/NextAuth.js/Supabase/Prisma) (#4086)
* Add free course ""

* Adjust new entry formatting to comply with all the other resources in the page

Co-authored-by: Nico Domino <yo@ndo.dev>
2022-03-23 19:50:26 +01:00
Nico Domino
ae318788c3 chore(docs): fix broken tutorial links (#4241) 2022-03-23 19:32:24 +01:00
1000101
affa459fcc fix(docs): v3->v4 migration (#4039)
Co-authored-by: Nico Domino <yo@ndo.dev>
2022-03-23 19:18:23 +01:00
Nico Domino
b88a31ef1a chore(docs): add tutorial for avoiding corporate email scanning HEAD reqs (#3900)
* chore(docs): add tutorial for avoiding corporate email scanning HEAD requests breaking email invitations

* fix: move to internal guides section
2022-03-22 23:29:05 +01:00
Nico Domino
bc82d6555a chore(docs): add corporate proxy tutorial (#3931)
* chore(docs): add corporate proxy tutorial

* fix(docs): add details about provider proxy adjustments

* fix: add to internal guides section
2022-03-22 23:27:14 +01:00
Thang Vu
11954567c2 docs: fix markdown link in jwt options (#4197)
Co-authored-by: Nico Domino <yo@ndo.dev>
2022-03-22 22:55:21 +01:00
Thang Vu
6e28ccf84f chore(adapters): Add next-autth as devDependencies for adapters (#4226)
* Upgrade turborepo, add next-auth as dev deps

* Fix TS error

* Update adapters.json

* ignore linting
2022-03-21 21:26:37 +01:00
Deepak Prabhakara
f542b400ba updated port number (5000 is blocked by MacOS AirPlay) (#4221) 2022-03-19 09:30:21 +01:00
Piyush Priyadarshi
d1b76bc302 docs: remove unused negation operator (#4217) 2022-03-18 22:28:43 +01:00
Andreas Thomas
3f396be5d9 feat(deps): upgrade minimal peer dependency @upstash/redis@v1 (#4213)
BREAKING CHANGE

From now on, you will need a minimum version of `@upstash/redis@v1` installed if you want to use this adapter.

You can upgrade by running `npm i @upstash/redis@latest` or `yarn add @upstash/redis@latest`
2022-03-18 22:27:45 +01:00
Balázs Orbán
bf4916dd70 chore: manually bump versions 2022-03-17 19:24:08 +01:00
Balázs Orbán
5100784d72 chore: update tsconfig 2022-03-17 19:03:26 +01:00
Balázs Orbán
3853e16268 chore: downgrade turbo 2022-03-17 18:57:46 +01:00
Balázs Orbán
4c0cc9e614 chore: manually bump package versions
since the last automatic release failed to do so
2022-03-17 18:38:20 +01:00
Balázs Orbán
d0112aae61 chore: upgrade lock file 2022-03-17 16:49:37 +01:00
Balázs Orbán
e373ff2473 chore: exclude firebase 2022-03-17 15:03:39 +01:00
Balázs Orbán
6d6d0a8679 Merge branch 'main' of github.com:nextauthjs/next-auth 2022-03-17 13:51:39 +01:00
Balázs Orbán
8152752cc8 chore: exclude firebase from testing 2022-03-17 13:51:31 +01:00
Andreas Thomas
966381ac9b docs: pin @upstash/redis version to 0.2.1 (#4201)
Until we migrate to v1 there might be people installing the latest
version of @upstash/redis and then encountering errors.
With this they will at least get a warning.

This is obsolete and should be updated once
https://github.com/nextauthjs/next-auth/issues/4183 is resolved.

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-03-17 13:44:21 +01:00
Wayne Shih
8199c96b76 fix: update font-family stack (#4192) 2022-03-17 13:43:08 +01:00
Balázs Orbán
6a06b8e054 chore: ignore building firebase adapter 2022-03-17 13:41:58 +01:00
Thang Vu
68bab17914 fix: set module to commonjs for adapters (#4205)
* fix: set module to commonjs for adapters

* Update tsconfig.json

* Update tsconfig.json

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-03-17 13:36:25 +01:00
Nico Domino
47b4765941 docs: 1st party guides section (#4167)
* chore: simplify example-gatsby readme header

* chore(docs): move 1st party guides to own section
2022-03-16 00:01:29 +01:00
Simon Kirsten
6d45ad4840 fix: encode callbackUrl for custom sign-in page (#4174) 2022-03-15 23:57:52 +01:00
Alexandru Călin
e5e49aca1c docs(adapters): add dynamoDB cf ProjectionType (#4182) 2022-03-15 23:54:50 +01:00
Lluis Agusti
ea944ebb86 docs(oauth): use Mermaid for the diagram (#4147) 2022-03-15 23:54:19 +01:00
Balázs Orbán
ca8af7fcd5 chore: push tags before GitHub release 2022-03-15 23:13:08 +01:00
Balázs Orbán
c9e74f435c chore: remove dry run flag 2022-03-15 22:54:43 +01:00
Balázs Orbán
c2601430fa fix: remove action from bad request response 2022-03-15 22:39:25 +01:00
TheBestMoshe
5b08e084a5 chore(docs): fixed broken link (#4189) 2022-03-15 22:07:51 +01:00
Balázs Orbán
6b9333d4ee docs: Remove false cookie size limit claim
Fixed with cookie chunking in v4
2022-03-15 16:02:06 +01:00
William Crutchfield
7636de4a34 Update provider links in oauth.md (#4175)
Noticed some links we're still looking for the files pre-monorepo
2022-03-14 02:55:13 +01:00
Nico Domino
ad2609d313 chore(docs): bump docusaurus dependencies (#4168)
* chore: simplify example-gatsby readme header

* chore(docs): upgrade docusaurus deps

* chore: dummy commit - will revert

* chore: revert dummy commit

* chore: revert rm searchParameters option

* chore: more dummy update 🤦

* chore(docs): new aloglia apiKey

* chore(docs): revert dummy update
2022-03-12 20:31:37 +01:00
Danilo Woznica
454add250c chore(docs): Adds Sandpack integration (#3880)
Co-authored-by: ndom91 <yo@ndo.dev>
2022-03-12 19:51:23 +01:00
Nico Domino
90b4dbc194 chore: simplify note header (#4166)
* chore: simplify note header

* chore: simplify example-gatsby readme header

* chore: fix broken docs README badge

* chore: rm docs README prerelease shield
2022-03-12 18:09:22 +01:00
Israel Ortiz
8783b17fc2 docs: update to v4 session object to strategy: "jwt" (#4159)
I saw in the documentation that v4 now uses
  session: {
    strategy: "jwt"
  },
instead of 
  session: {
    jwt: true
  },

also there was double ;; at the end of the return statement, fixing it
2022-03-12 05:48:26 +01:00
boulatbek
3585c8e0c3 docs: Update initialization.md (#4158)
minor edit to the text to remove redundant words
2022-03-12 05:46:06 +01:00
Balázs Orbán
1be87d40af docs: warn in Credentials 2022-03-09 18:41:41 +01:00
Theo Tarr
c64aebcd4f docs: space formatting for redirect callback example (#4131) 2022-03-07 13:16:38 +01:00
Deepak Prabhakara
001354eaa8 feat(providers): add BoxyHQ SAML provider (#3782)
* added saml-jackson provider

* incorporated code review changes

* fixed SAMLJacksonProfile type

* trying to adjust code for monorepo

* cleanup from merge with main

* updated docs link

* added example

* consistent naming

* Incorporated code review changes:
- env var default values moved to env.local.example
- consistent naming and use of id

* email is guaranteed to be present
2022-03-05 23:52:55 +01:00
天阙
b0935c7b4a docs: fix typo for bungie.md (#4098) 2022-03-03 07:13:43 +01:00
Thang Vu
2ea5566d1e docs(adapters): update overview.md (#4092) 2022-03-01 18:47:46 +01:00
Thang Vu
755904d5ae chore: add WorkOS to readme.md (#4091) 2022-03-01 14:45:20 +01:00
Balázs Orbán
d66d963e86 fix: ensure Prisma/MongoDB integration (#4083)
* chore(deps): upgrade Prisma

* fix: ignore `id` when not needed

* test: ensure MongoDB/Prisma integration

* test: remove table mappers

* docs(adapters): mention MongoDB in the Prisma adapter

* docs: plural

* fix: `@ts-ignore`

* docs: typo, consistency
2022-03-01 05:52:56 +01:00
Lluis Agusti
6f30b7aeb5 docs(getting-started): explain callback URL (#4065)
* docs(getting-started): explain callback URL

* docs(getting-started): refer to existing guide

* fix: grammar

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* fix: grammar

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* fix: grammar

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-03-01 03:02:14 +01:00
Pumidol Leelerdsakulvong
d69969894e docs(providers): fix link on 42 School page (#4062)
* UPDATE documentation

UPDATE incorrect import 
ADD callback uri information

* Update docs/docs/providers/42.md

Co-authored-by: Lluis Agusti <hi@llu.lu>

* Update docs/docs/providers/42.md

Co-authored-by: Lluis Agusti <hi@llu.lu>

* Update docs/docs/providers/42.md

Co-authored-by: Lluis Agusti <hi@llu.lu>

* Apply suggestions from code review

Co-authored-by: Lluis Agusti <hi@llu.lu>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-03-01 03:01:30 +01:00
DiamondeX
2a4d45c665 docs: Update securing-pages-and-api-routes.md (#4085)
I'm not sure, but it looks like the `null`  should be returned in case of server-side run, that is with `typeof window === "undefined"`
2022-03-01 02:00:07 +01:00
Balázs Orbán
05803ba36c fix: deduplicate id, return correct updated data (#4082)
* chore: remove `:wip` suffix from scripts

* fix: deduplicate id, return updated data

* chore: revert change

* refactor: deduplicate `id` in `updateSession`

* chore(deps): upgrade to `mongo@4.4.0`
2022-03-01 01:40:27 +01:00
dependabot[bot]
8dca4c87ab chore(deps): bump prismjs from 1.26.0 to 1.27.0 (#4077)
Bumps [prismjs](https://github.com/PrismJS/prism) from 1.26.0 to 1.27.0.
- [Release notes](https://github.com/PrismJS/prism/releases)
- [Changelog](https://github.com/PrismJS/prism/blob/master/CHANGELOG.md)
- [Commits](https://github.com/PrismJS/prism/compare/v1.26.0...v1.27.0)

---
updated-dependencies:
- dependency-name: prismjs
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-28 00:51:19 +01:00
Novezeil
04383aee9b docs: fix providers overview page link in readme.md (#4079) 2022-02-28 00:51:05 +01:00
Balázs Orbán
9a86bd38cf chore: disable coverage, fix dynamodb jest config 2022-02-28 00:50:42 +01:00
Balázs Orbán
f1af3ffae7 chore: make upstash tests dependent on env variables 2022-02-28 00:34:54 +01:00
Balázs Orbán
d9bb3ce94b chore: update Turbo, clean up scopes 2022-02-28 00:29:14 +01:00
Balázs Orbán
2a36da8278 chore: enforce build before publish 2022-02-28 00:13:06 +01:00
ANTARES
0a267d9a72 fix(ts): SignInAuthorisationParams -> SignInAuthorizationParams (#4072) 2022-02-25 23:56:10 +01:00
Colin Jones
bc401657a6 fix(ts): make refresh_token nullable (#4064)
This field is already nullable in the database, so this should only
affect types.

Because the type is being widened, not narrowed, this should also be
fully backwards-compatible, since pre-existing custom entities of type
`string` will be substitutable for the new default type of `string |
null`.

See #4055 for more specifics on the impact.
2022-02-25 03:20:08 +01:00
Maxime VAST
86b7bfdcdc docs: update auth0 and vercel config documentation (#4049)
* docs: update auth0 and vercel config documentation

* Update docs/docs/configuration/options.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-24 00:07:32 +01:00
Nico Domino
83a9867cbc docs: small css update (#4053) 2022-02-23 14:42:01 +01:00
Balázs Orbán
1f07ff05d6 docs: fix lint 2022-02-23 00:49:51 +01:00
Balázs Orbán
163149b424 fix(providers): fix BattleNet 2022-02-23 00:40:56 +01:00
Balázs Orbán
4234742d90 fix(providers): issuer instead of region 2022-02-23 00:30:22 +01:00
Lluis Agusti
3ddfff7808 docs(client): explain basePath on <Provider /> (#4012)
* docs(client): explain `basePath` on <Provider />

* fix: grammar

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-23 00:24:38 +01:00
Karl Stoney
75cb175259 fix: Switch BattleNet to OIDC (#4015)
* Fixes: https://github.com/nextauthjs/next-auth/issues/4013

* Update packages/next-auth/src/providers/battlenet.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update packages/next-auth/src/providers/battlenet.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update packages/next-auth/src/providers/battlenet.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Apply suggestions from code review

* Update battlenet.ts

* Update battlenet.ts

* Update battlenet.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-23 00:20:31 +01:00
Jonas Strassel
21f410425b docs: typo thge -> the (#4046) 2022-02-23 00:09:36 +01:00
Robert Soriano
3d0c68d9e0 docs: add SvelteKit playground (#4023)
* docs: add SvelteKit playground

* docs: update readme

* add svelte2tsx for packaging

* remove header component in lib folder

* reexport next-auth functions

* remove as strings

* format svelte files

* update README

* format files

* add hook usage in readme

* Update README.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update README.md

Additional info for sveltekit + nextauth.js experimental project

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update global.d.ts

Remove sample github client id and secret

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update .env.example

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update example route

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* remove .npmrc

* remove pnpm lockfile

* move prettier config to package.json

* reformat files

* Add secret config

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* remove packaging related lines and files

* remove package command

* Update next-auth.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-21 22:34:46 +01:00
Thang Vu
03ba6683c7 chore: Replay cache output for next-auth (#4025) 2022-02-21 22:24:19 +01:00
AlexRay
3ec3761634 docs(dgraph): fix syntax error in secure schema auth rule (#4024) 2022-02-21 02:03:24 +01:00
Balázs Orbán
e9c1059f3c chore: ignore docs in turbo build 2022-02-21 01:57:03 +01:00
Balázs Orbán
906b7930e8 chore(docs): fix linting 2022-02-21 01:50:12 +01:00
Balázs Orbán
45861548c2 chore: tweak Turbo 2022-02-21 01:40:13 +01:00
Balázs Orbán
0c0a070d6f refactor(adapters): code clean-up 2022-02-20 01:11:21 +01:00
Thang Vu
3f528b03ff chore: exclude tests from release artifact (#4011)
* chore: exclude tests from release artifact

Update base.json

* Symlink readme
2022-02-19 17:00:08 +01:00
Jonas Strassel
e87d5a61f8 feat(adapters): simplify mikro-orm configuration (#4008)
* feat(mikro-orm): simplify mikro-orm configuration

* docs(mikro-orm): clean up the mikro-orm docs

* chore(deps-dev): bump mikro-orm deps

* Apply suggestions from code review

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-19 01:25:45 +01:00
Balázs Orbán
fb8874d6d8 fix: only warn when using Twitter + OAuth 2.0 (#4003) 2022-02-19 00:39:35 +01:00
Thang Vu
692fafeafb chore: separate build commands for core and app (#3845)
* chore: separate build commands for core and app

* Move emitDeclarationOnly to next-auth

* Update release.yml

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-19 00:38:59 +01:00
dependabot[bot]
b6bf2366e2 chore(deps): bump next from 12.0.9 to 12.1.0 (#4005)
Bumps [next](https://github.com/vercel/next.js) from 12.0.9 to 12.1.0.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](https://github.com/vercel/next.js/compare/v12.0.9...v12.1.0)

---
updated-dependencies:
- dependency-name: next
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-18 06:21:11 +01:00
dependabot[bot]
a9ef2292eb chore(deps): bump vm2 from 3.9.5 to 3.9.7 (#3979)
Bumps [vm2](https://github.com/patriksimek/vm2) from 3.9.5 to 3.9.7.
- [Release notes](https://github.com/patriksimek/vm2/releases)
- [Changelog](https://github.com/patriksimek/vm2/blob/master/CHANGELOG.md)
- [Commits](https://github.com/patriksimek/vm2/compare/3.9.5...3.9.7)

---
updated-dependencies:
- dependency-name: vm2
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-17 02:19:04 +01:00
Nico Domino
846a0a0f9d docs: move database model to mermaid (#3839)
* chore: move database model to mermaid

* chore: update model details

* chore: update docusaurus dependencies

* chore: add model notes

* chore(docs): fix broken links

* Apply suggestions from code review

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-16 00:12:27 +01:00
Thang Vu
bb37c29218 chore: improve caching dependencies (#3971) 2022-02-15 04:02:09 +01:00
Balázs Orbán
cea444b2b9 docs: move database migration under Adapter 2022-02-15 01:07:36 +01:00
Nico Domino
17314b9b2f docs: add v4 migration script for adapters (#3874)
* chore: add v4 migration script for adapters

* chore: cleanup

* chore: PR comments

* chore(docs): add mongodb migration example + fix nextauthjs/adapters links
2022-02-15 01:00:38 +01:00
Balázs Orbán
fda6d4ab44 chore: enforce double quotes with Prettier 2022-02-15 00:48:14 +01:00
Balázs Orbán
ff84151a02 chore: description first 2022-02-15 00:18:00 +01:00
Balázs Orbán
02f0335e18 chore: tweaks in contributors docs page 2022-02-15 00:16:22 +01:00
Balázs Orbán
5ec3713f20 chore: update contributors docs page 2022-02-15 00:09:09 +01:00
Balázs Orbán
22d3f707e9 chore: rename issue template, add triage label 2022-02-14 20:11:44 +01:00
Balázs Orbán
2d87da454d chore: add docs issue template 2022-02-14 20:08:54 +01:00
Balázs Orbán
614d9cc433 chore: tweaks on release script 2022-02-14 03:01:11 +01:00
Balázs Orbán
9aed24fb4b chore: remove duplicate from issue template dropdown 2022-02-14 02:45:21 +01:00
Balázs Orbán
1c2b573933 chore: pin down repo-file-sync until bug fixed
See https://github.com/BetaHuhn/repo-file-sync-action/issues/168
2022-02-14 02:33:50 +01:00
Balázs Orbán
da840e5461 chore: correct package paths, improve dry run 2022-02-14 02:19:12 +01:00
Balázs Orbán
be9555e6cf chore: force order on issue templates 2022-02-14 01:32:43 +01:00
Balázs Orbán
a18ea2245f chore: minor fixes on issue templates 2022-02-14 01:31:07 +01:00
Balázs Orbán
39f947365d chore: improve maintenance (#3969)
* chore: clean up stalebot config

* chore: introduce issue labeler bot

* chore: clean up PR labeler bot

* chore: clean up bug report process

* chore: add space

* chore: add links to docs in provider/adapter issue templates

* chore: add triage label to feature request issue template
2022-02-14 01:25:50 +01:00
dependabot[bot]
582a4924fa chore(deps): bump follow-redirects from 1.14.7 to 1.14.8 (#3965)
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.7 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.7...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-13 19:34:18 +01:00
Jonas Strassel
7feda249a9 feat(deps): drop mikro-orm <5 support (#3875)
Co-authored-by: Balázs Orbán <info@balazsorban.com>

BREAKING CHANGE

With this release, we only support `@mikro-orm/*@5`

To migrate, run the following (replace the `*` with [your driver](https://mikro-orm.io/docs/installation)):

```sh
npm install @mikro-orm/core@5 @mikro-orm/*@5
```

Check out the [MikroORM v5 changelog](https://github.com/mikro-orm/mikro-orm/blob/master/CHANGELOG.md#500-2022-02-06) for more details.
2022-02-13 19:32:59 +01:00
Balázs Orbán
d0cf5786f1 chore: move changelog generation to publish 2022-02-13 19:03:32 +01:00
Balázs Orbán
fe08b5c8f1 chore: write new version to package.json even in dry run 2022-02-13 18:30:15 +01:00
Balázs Orbán
caa9a17fc8 fix(providers): refactor WorkOS to work in v4 (#3886)
* refactor(dev): moved dev app

* chore(dev): fix dev app

* fix(providers): WorkOS to TS, use `client_secret_post`

* chore: decrease test concurrency

* chore: remove org

* chore: run tests sequentially

* feat(providers): use `picture` in WorkOS if available
2022-02-13 17:56:01 +01:00
Balázs Orbán
2e371053c2 chore: add release script (#3891)
* chore: fix `next-auth` version in `package.json`

* chore: add WIP publish script

* chore: fix comments, add TODOs

* chore: set newer TS target

* chore: extract release config

* chore: WIP work on publish script

* chore: finish up release script

* chore: do not push unless not dryRun

* chore: add debug env var, return early if no package to update

* chore: remove unnecessary comment

* chore: remove changeset and unused dependencies

* chore: drop `semantic-release`

* chore: remove `jsonfile` dependency

* chore: address code review

* fix: list other commits in changelog when releasing

* chore: fix env variable references

* chore: fetch with tags and commit history

* chore: fix analyze code

* chore: fix utils script

* chore: better changelog formatting

* chore: fix package path

* chore: fix some remaining stuff

* chore: remove DEBUG flag
2022-02-13 17:36:15 +01:00
Balázs Orbán
8d410abdc9 chore: fix typo an issue template 2022-02-13 00:49:59 +01:00
Balázs Orbán
a4c619e358 chore: link to discussions from issue template 2022-02-13 00:49:03 +01:00
Balázs Orbán
53433db493 chore: note that feature requests are converted 2022-02-13 00:39:17 +01:00
Sean McEmerson
7c10f380a0 docs: Typo correction for type import (#3914)
Fix incorrect JWT type import path.
2022-02-11 21:50:28 +01:00
Thang Vu
68e412b063 chore: fix Github action error with yarn (#3903)
Restore action name
2022-02-10 16:39:27 +01:00
Mads Thines
7434fb919a docs: Update getting-started/example.md (#3904)
Shouldn't this also be set to inline-code block?
2022-02-10 16:38:44 +01:00
Thang Vu
a9a3f60cb7 chore: Attempt to improve cache speed (#3893) 2022-02-10 02:02:20 +01:00
Balázs Orbán
a7c55b752f chore(dev): move dev app to apps workspace (#3888)
* chore: move dev app

* chore: run tests sequentially
2022-02-09 01:12:24 +01:00
Balázs Orbán
cbf9622e6f chore: move docs to top-level (#3887)
* chore: move docs to top-level

* chore: add docs back to workspaces
2022-02-09 00:42:11 +01:00
Zach Grimaldi
9dc591290a docs(adapters): split Fauna setup commands into two sections (#3877)
* feat(docs): Fauna Adapter setup commands split into two sections

* fix: removed extraneous newline from my contribution
2022-02-08 02:06:59 +01:00
Nico Domino
e062f338e3 chore: add Lowdefy opencollective sponsor (#3876) 2022-02-07 20:13:12 +01:00
Balázs Orbán
5c1826a8d1 docs(example): add Gatsby example, move Next.js example (#3872)
* docs: add Gatsby example, move Next.js example

* chore: fix sync action

* docs(example): fix README link
2022-02-07 18:03:51 +01:00
Balázs Orbán
953712ceaa chore: skip PR when syncing to example repo 2022-02-06 23:31:56 +01:00
Balázs Orbán
c43d1903cf docs: make syncing note more prominent 2022-02-06 23:22:16 +01:00
Balázs Orbán
ef769523bc chore: move example (#3861)
* chore: sync LICENSE file

* chore: move example repository into monorepo

* change to public repository

* add ntoe about source

* change order
2022-02-06 23:18:48 +01:00
Balázs Orbán
3b5ee252bd Update sync.yml 2022-02-06 23:00:28 +01:00
Balázs Orbán
e9dee0af44 chore: add sync config (#3860) 2022-02-06 22:59:29 +01:00
Brian Muenzenmeyer
83232710fd docs(oauth): fixes typo in comment (#3856) 2022-02-06 22:21:09 +01:00
Manny Becerra
87332b3c2e docs: Typo correction (#3857)
On the configuration->options docs, `Promise` has a typo instance that this PR fixes.
2022-02-06 22:20:49 +01:00
Salah Azzouz
40ad78a3ec docs: fix typo in NEXTAUTH_SECRET (#3854)
Fix the misspelling of  'NEXT_AUTG' to 'NEXT_AUTH', the misspelling was found in the JWT Helper section.
Link: https://next-auth.js.org/configuration/options#jwt-helper
2022-02-06 15:29:16 +01:00
Thang Vu
0c91e7f3e3 chore: update contributing docs (#3844)
* chore: update contributing docs

* Mention node version

* Update CONTRIBUTING.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update CONTRIBUTING.md

* chore: alias `yarn dev:app` with `yarn dev`

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-06 15:14:09 +01:00
Balázs Orbán
878fe84e29 chore: expose UPSTASH env vars to test runs 2022-02-06 15:10:08 +01:00
Balázs Orbán
8ad90b3eb0 docs: move encode/decode to advanced options (#3849)
* docs: move `encode/decode` to advanced options

* chore: change docs label to documentation
2022-02-06 14:07:29 +01:00
Nico Domino
4d63aa6a41 chore: add adapters issue template (#3807)
* chore: add adapters issue template

* fix: cleanup existing issue templates

* fix: add adapter auto labels

* fix: balazs als docs owner

* Update .github/ISSUE_TEMPLATE/adapters.yml

* feat: add incorrect info disclaimer line

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-05 14:39:28 +01:00
Nico Domino
76c1c4cd72 chore: update readme packagephobia (#3838) 2022-02-05 14:38:46 +01:00
Balázs Orbán
3571031820 Update deployment.md 2022-02-05 14:28:41 +01:00
Brian Muenzenmeyer
4d866373fd docs(faq): fixes typo (#3835)
Noticed this while reading the docs.
2022-02-05 03:02:40 +01:00
Nico Domino
2db3db6ff9 docs: update README for monorepo (#3832)
* fix: update README for monorepo

* Apply suggestions from code review

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-04 22:42:40 +01:00
Nico Domino
dc3ad8c408 chore: move adapters to monorepo (#3805)
* feat: move adapters repo to new packages dir

* fix: rm docusaurus build dir

* fix: update .gitignore

* fix: reorganise package directories

* remove package lock files

* fix: folder rename

* remove package lock file

* fix: jest config paths

* update yarn.lock

* ignore dynamodb local bin

* fix: gitignore

* fix: update adapter-test

* change adapter-test package json

* rename prisma adapter package name

* fix paths

* update gitignore

* run tests with one concurrency

* fix: merge conflicts

* gitignore dist folders

* fix: add jest.config.js to tsconfig ignore

* fix: yarn.lock

* fix: ignore pouch in turbo commands

* ignore jest file

* fix: test turbo test cmd

* fix: turbo test cmd

* test: disable mongodb-adapter temporarily

* ignore all dev.db files

* simplify gitignore

* remove unused dependency

* have tsconfig in its own package

* remove unnecessary .gitignore files

* move jest config to preset

* add ts expect error comment

* chore: update .gitignore

* remove babelrc

* don't depend on build for testing in turbo

* fix: cleanup testing npm scripts

* fix: remove jest-config roots

* fix: add fauna jest preset

* fix: rm dev.db from prisma mirgation

* fix prisma

* remove nohoist

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-04 22:40:32 +01:00
Balázs Orbán
cb30f49f9b docs: fix docusaurus edit link and Vercel path 2022-02-04 16:14:18 +01:00
Balázs Orbán
3fe7a64e7a chore: monorepo 1 (#3804)
* fix labeler

* try fixing test runs in GitHub Actions

* pass flags to test command

* test version pr

* move versoin-pr action

* remove --dry-run flag

* re-enable testing, re-add semantic release for now

* add docs

* use `yarn.lock` and different docs port

* simplify dev app config

* fix coverage report

* fix provider source links

* fix more links
2022-02-04 16:01:26 +01:00
Thang Vu
a72f1b6d21 chore: Convert to monorepo (#3788)
* chore: convert to monorepo

* Remove eslint, typescript, semantic-release

* Add yarn.lock

* Add turbo

* Run test command

* Move to src

* Add a seperate tsconfig file

* Update .gitignore

* Update commands to yarn

* Replace semantic-release with changesets

* Update changesets usage

* Fix commands: dev, setup, clean

* Add back changes from main

* Fixed HMR

* Update .gitignore
2022-02-04 13:40:04 +01:00
Balázs Orbán
f7fc562b49 fix(middleware): handle no argument case (#3799)
* fix(middleware): handle no argument case

* use absolute URLs

* use origin instead of host
2022-02-04 00:27:51 +01:00
Balázs Orbán
f3be5e87f6 feat(middleware): introduce withAuth Next.js method (#3657)
* feat(middleware): introduce Middleware API to Next.js

* chore(app): upgrade Next.js in dev app

* chore(dev): add Middleware protected page to dev app

* chore(middleware): add `next/middleware` to `exports`

* fix(middleware): bail out redirect on custom pages

* fix(middleware): allow one-line export

* chore(middleware): simplify code

* fix(middleware): redirect back to page after succesful login

* feat(middleware): re-export `withAuth` as `default`

* chore: export middleware from `next-auth/middleware`

* chore: add `middleware` files to npm

* feat(middleware): handle chaining, fix some bugs

* chore(dev): showcase different middlewares

* chore(middleware): remove `@ts-expect-error` comments

* chore: update build clean script

* fix: bail out when NextAuth.js paths

* refactor: be more explicit about `initConfig` result

* refactor: simplify

* refactor: use `callbacks` similarily to `NextAuthOptions`

* refactor: use `nextauth` namespace when setting `token` on `req`

* refactor: don't allow passing `secret`

* addressing review
2022-02-03 18:07:26 +01:00
Dinil Fernando
844c9b147c feat(providers): add Trakt provider (#3771)
* added trakt provider

* fixed incorrect auth url

* Update src/providers/trakt.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update src/providers/trakt.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update trakt.ts

Co-authored-by: caidenwilson <caidenwilson@protonmail.com>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-02-03 15:27:05 +01:00
Balázs Orbán
c9e16fb71e fix(core): only show Twitter OAuth 2 warning once 2022-02-02 16:06:14 +01:00
Balázs Orbán
a7d34f97c8 fix(providers): properly warn when using Twitter OAuth 2 (#3784)
* fix(providers): properly warn when using Twitter OAuth 2

* refactor(providers): move Twitter OAuth2 warning to `assert`

* fix: use proper warning code

* refactor: only set boolean
2022-02-02 12:37:17 +01:00
Balázs Orbán
f20d6790c8 feat(core): detect NEXTAUTH_SECRET (#3783)
* feat(core): detect `NEXTAUTH_SECRET` env variable

* chore(dev): use detected `NEXTAUTH_SECRET` in dev app
2022-02-02 02:08:56 +01:00
Norbert Szabó
53baf6d67d feat(ts): strongly type sign-in and error page errors (#3740)
* feat: added types for sign in errors

* feat: adding type to error prop

* chore: added documentation links to types
2022-02-02 02:08:44 +01:00
dependabot[bot]
255c822dfb chore(deps): bump node-fetch from 2.6.6 to 2.6.7 (#3777)
Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.6 to 2.6.7.
- [Release notes](https://github.com/node-fetch/node-fetch/releases)
- [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.6...v2.6.7)

---
updated-dependencies:
- dependency-name: node-fetch
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-01 08:18:26 +01:00
inshatan
31c03c96d1 typo in redirect url for response with error (#3758) 2022-02-01 08:18:09 +01:00
dependabot[bot]
74df39a678 chore(deps-dev): bump next from 12.0.7 to 12.0.9 (#3764)
Bumps [next](https://github.com/vercel/next.js) from 12.0.7 to 12.0.9.
- [Release notes](https://github.com/vercel/next.js/releases)
- [Changelog](https://github.com/vercel/next.js/blob/canary/release.js)
- [Commits](https://github.com/vercel/next.js/compare/v12.0.7...v12.0.9)

---
updated-dependencies:
- dependency-name: next
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-02-01 08:16:25 +01:00
Balázs Orbán
714d80a4f5 Update package.json 2022-01-25 18:39:58 +01:00
Balázs Orbán
3d5c669a05 Update bug_report.yaml 2022-01-25 18:37:30 +01:00
Balázs Orbán
29977f108f Update bug_report.yaml 2022-01-25 18:36:56 +01:00
Balázs Orbán
7d2e16a6bb Update bug_report.yaml 2022-01-25 18:35:54 +01:00
Seiji Takahashi
af157dac07 feat(react): add refetchOnWindowFocus option to SessionProvider (#3730) 2022-01-25 18:06:37 +01:00
Alex Johansson
1bf56a218e fix: Allow React 18 as peer dependency (#3728)
Avoid peer dependency warning when using React 18
2022-01-25 18:02:53 +01:00
David Chalifoux
4824f8c02a fix(providers): Check for valid profile picture response before converting to base64 (#3656)
* Fix: Add OpenID to authorization scope

* Fix: Check for valid profile picture response before converting to base64

* Update src/providers/azure-ad.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Confirm that profile photo was returned

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-01-20 02:09:04 +01:00
PAKKU-Chan
a4d831d1b9 feat(providers): add authentik provider (#3625)
* Added authentik provider

* Removed idToken
2022-01-19 01:38:46 +01:00
David Chalifoux
59985264a2 fix(providers): use openid scopes by default (#3651) 2022-01-17 04:28:15 +01:00
Iftekhar Rifat
c844296982 fix: pass csrf & callbackUrl cookies in session api (#3607) 2022-01-17 00:41:16 +01:00
Jon Bellah
d1aa2a1a8e fix(ts): match GoogleProfile interface with Google docs (#3643) 2022-01-17 00:40:23 +01:00
Balázs Orbán
8139126f29 fix(core): detect Vercel without NEXTAUTH_URL (#3649)
* fix(core): detect Vercel without `NEXTAUTH_URL`

* chore(ts): use `any`

* chore: use `process.env.VERCEL` to detect Vercel
2022-01-17 00:37:30 +01:00
Laxmikanta Nayak
aa0e8200b3 docs: Updated the wrong link to providers list in readme (#3616)
The link to providers list was 404 so updated to the correct link in document.
2022-01-15 04:44:31 +01:00
Thang Vu
82447f8e3e fix: display inline errors when using custom error page. (#3576) 2022-01-10 11:57:27 +01:00
Balázs Orbán
a0b3814c81 feat: better out-of-the-box id_token detection (#3514)
* feat: better out-of-the-box `id_token` detection

* fix: check for `scope` on correct endpoint

* chore: simplify internal typing
2022-01-10 11:50:45 +01:00
Balázs Orbán
90c7d535c0 feat(providers): add support to Twitter OAuth 2.0 (#3446)
* feat(providers): add support to Twitter OAuth 2.0

* docs: add docs comment

* chore: cleanup

* chore: remove comments

* chore: give warning for OAuth 2 for now
2022-01-10 11:49:43 +01:00
Tetedeiench
0510c9b1ba feat(providers): add Patreon provider (#3581)
* Added patreon provider - tested and working

* Update src/providers/patreon.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update src/providers/patreon.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update src/providers/patreon.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update src/providers/patreon.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Switched to TS, restore .env.local, restore package.json as per comments on the PR

* chore: ran Prettier

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-01-10 11:48:11 +01:00
Changsoon Bok
49e4af17e2 fix(providers): refactor naver provider profile (#3500)
* fix(providers): refactor naver provider profile

fix(providers): refactor naver provider profile

* fix(providers): convert typescript - naver provider profile

fix(providers): convert typescript - naver provider profile

* chore(providers): use nested interface for consistency

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-01-10 11:35:53 +01:00
Changsoon Bok
db65afe5ab fix(providers): fix url and auth method for Kakao provider (#3501)
* fix(providers): fix url and auth method for Kakao provider

* fix(providers): convert typescript - Kakao provider

fix(providers): convert typescript - Kakao provider

* chore(providers): use nested interface for consistency

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-01-10 11:31:55 +01:00
Changsoon Bok
36ca1f99e3 docs: update contributing guide link (#3595) 2022-01-10 11:22:58 +01:00
Thang Vu
9bec96784f chore(dev): add postinstall in app to remove next-auth (#3575) 2022-01-08 00:43:38 +01:00
Thang Vu
227ff2259f chore: add eslintIgnore in package.json (#3548)
* fix: add eslintIgnore in package.json

* Let eslint runs in app, config + js files

* Add a separate tsconfig.eslint.json file

We want to run the lint command on `app`, `src` and `config`, but at the same time want `tsc` to compile files in `src` only. A separate `tsconfig.eslint.json` is a suitable solution to satisfy both `eslint` and `tsc`: 04d1f3e549/packages/parser/README.md
2022-01-05 04:02:03 +01:00
Yves Fridelance
c71cb8457d fix(oauth): set httpOptions before issuer discovery (#3537)
* Update client.ts

Set custom.setHttpOptionsDefaults before Issuer.discover(.wellKnown). This allow discover the .wellKnown endpoint behind a proxy

* chore: address code review

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-01-02 00:04:23 +01:00
krautwigundrüben
a09a75be53 fix(providers): make Strava work again (#3520)
* Update strava.js

Auth with Strava was throwing errors before, this works.

* Update strava.js

changed according to commenters' suggestions

* chore: run linter

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2022-01-02 00:00:33 +01:00
Balázs Orbán
c4936991e5 chore(app): upgrade dev app dependencies 2021-12-31 00:41:59 +01:00
Thang Vu
e2add6a597 chore(dev): fix start email script (#3541) 2021-12-30 22:42:26 +01:00
Adam Kaczmarek
0e8be0c7d2 docs: fix OpenCollective link in README.md (#3494) 2021-12-22 00:42:21 +01:00
Ivan Esteban
d1d2d977fe fix(providers): use idToken by default in Cognito provider (#3448) 2021-12-18 02:21:20 +01:00
Kirankumar Ambati
48749d7320 fix(pages): remove default placeholder for credentials provider (#3451)
* fix #3449: removed default placeholder for credentials provider

* fix: formatting
2021-12-18 02:10:05 +01:00
Drew Miller
87d0beb70c fix(jwt): use authorization header as fallback (#3453)
If the `req` sent to `getToken` doesn't have the relevant cookies, use
the Bearer token in the Authorization header as a fallback.

Fixes #3452
2021-12-16 13:37:03 +01:00
Balázs Orbán
978e2eeb08 chore(dev): minor fixes on dev app 2021-12-11 21:19:12 +01:00
Balázs Orbán
8ab057ea33 chore(deps): ugprade dependencies (#3415) 2021-12-11 21:17:22 +01:00
Bogdan Soare
2c269a6a81 fix(providers): use id_token by default on Okta provider (#3418) 2021-12-11 12:52:40 +01:00
Alessandro Cuppari
8b9a109255 fix(providers): refactor FusionAuth to v4 (#3376)
* feat: updated fusionauth provider

* Updated fusionauth profile interface docstring

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Refactored openid well know logic

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Removed jwks endpoint property

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-12-09 21:48:01 +01:00
Etienne Martin
ac35d9f739 docs: Fix README.md typo (#3412) 2021-12-09 16:53:17 +01:00
Balázs Orbán
30a0fc6bc0 fix: properly handle callback URL fallback (#3402)
* fix: don't default to localhost on `host`

* fall back to `host` for `callbackUrl`

* use parsed host

* remove unnecessary type cast
2021-12-08 18:20:33 +01:00
Balázs Orbán
b0f6175cec chore(deps): upgrade next dev dependency 2021-12-08 17:50:25 +01:00
Balázs Orbán
1c7fe57edb fix: default to VERCEL_URL for callbackUrl 2021-12-08 17:43:49 +01:00
Balázs Orbán
59797bbdef fix: use VERCEL_URL by default for secureCookie (#3399) 2021-12-08 17:22:57 +01:00
Paul Büchner
9eb78a9de9 chore: fix typo in comment (#3388) 2021-12-08 03:07:26 +01:00
Balázs Orbán
2670bbb28f docs: match docs page wording for SECURITY.md 2021-12-06 21:05:41 +01:00
DmitryScaletta
0431c2a334 fix(ts): improve types for encode/decode functions (#3346)
* fix: improve types for encode/decode functions

* fix: use Awaitable type for encode/decode functions
2021-12-04 02:09:48 +01:00
Rraji Abdelbari
5ac688cc18 fix(providers): convert 42 School profile id to string (#3351) 2021-12-04 02:08:48 +01:00
Anthony Ringoet
8ea75f0c1c fix(ts): typo in Auth0Profile interface (#3347) 2021-12-04 02:06:23 +01:00
dnikomon
4dcdb62dca fix: remove nextauth from authorization params (#3332)
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-12-02 19:43:42 +01:00
Nico Domino
1f4b7d8089 chore: add opencollective to package.json (#3333) 2021-12-02 12:50:14 +01:00
Balázs Orbán
fedb84872d docs: add top contributors to package.json 2021-12-01 16:44:20 +01:00
Balázs Orbán
c0dddfb77f docs: upgrade README 2021-12-01 16:40:21 +01:00
Balázs Orbán
50fe115df6 Release v4 2021-12-01 16:32:35 +01:00
Jameel Khan
cc17ddf8aa fix: Fallback to --color-text when no color-brand (#3313) 2021-12-01 15:01:11 +01:00
Balázs Orbán
8644e553ed Merge branch 'main' into beta 2021-11-30 19:20:56 +01:00
Nisala Kalupahana
d1d0db43ea feat(providers): ensure GitHub provider always gives an email (#3302)
* Ensure that GitHub provider always gives an email

* Update src/providers/github.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-11-29 23:58:49 +01:00
Balázs Orbán
b01f6805d3 chore(providers): TS improvements (#3295) 2021-11-28 17:52:56 +01:00
Balázs Orbán
c44b860b9e feat(providers): refactor Apple provider (#2875)
* chore: remove legacy code

* fix(providers): refactor Apple provider

* chore(dev): add Apple provider

* docs(providers): add `generateClientSecret` to JSDoc

* fix(providers): use `jose@4`

* fix(providers): use seconds since epoch, correct sign

* chore(providers): move secret generator into a script
2021-11-28 17:52:24 +01:00
Khánh Hoàng
22f74d7c4d fix(providers): correct authorization url for Atlassian (#2999)
* fix(provider): correct authorization for Atlassian

* feat(providers): use wellKnown for better configuration

* fix(atlassian): switch back to raw config

* fix(providers): pass generic to `OAuthUserConfig`

Co-authored-by: Lluis Agusti <hi@llu.lu>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-11-28 15:49:24 +01:00
Balázs Orbán
2570168660 fix: add custom error message when session required (#3288) 2021-11-28 15:38:02 +01:00
Balázs Orbán
187a1474f5 feat(oauth): expose httpOptions (#3287) 2021-11-26 23:40:58 +01:00
Kevin McKernan
4dc76749f2 fix(providers): Rewrite EVEOnline in TS, fix default scopes (#2759)
* refactor EVEOnlineProvider into typescript, fix default scopes

* Update src/providers/eveonline.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* update to new OIDC SSO endpoints

* set idToken: true

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-11-26 19:20:40 +01:00
Torben
35ee608d59 feat(providers): add Osu! provider (#3234) 2021-11-20 14:49:51 +01:00
Estevan Jantsk
0f132de115 feat(providers): add Pipedrive provider (#3011)
* Add Pipedrive as a provider

* convert pipedrive provider to ts

* remove others interface

* refactor(pipedrive): run prettier

Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-11-17 23:07:29 +01:00
Balázs Orbán
31426b9435 fix(providers): match filename with 42 Provider's id (#3225) 2021-11-17 23:03:56 +01:00
Balázs Orbán
64b2a2c43b fix: assert action when req.query isn't available (#3222)
* fix: assert `action` if `req.query` unavailable

* refactor: make `method` externally optional
2021-11-17 22:47:12 +01:00
Balázs Orbán
7beb3ff03b refactor(providers): cleanup 42 (#3221) 2021-11-17 10:15:59 +01:00
Richard van der Dys
432876c011 fix(providers): refactor Zoom
* Added support for zoom in beta

* Converted to typescript

* rename

* Now reflects response from Zoom

* chore: Prettier

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-11-16 23:37:03 +01:00
Balázs Orbán
15d1fab4c8 fix: correct assertion when Credentials only (#3217) 2021-11-16 23:16:12 +01:00
Rraji Abdelbari
5e803cd34c refactor(providers): convert 42 to TypeScript (#3211) 2021-11-16 21:57:53 +01:00
Balázs Orbán
76bf524e8e feat: make missing secret an error (#3143)
BREAKING CHANGE:

It is now required to set a `secret` in production.
2021-11-15 18:45:56 +01:00
Balázs Orbán
f9e0ef8d18 feat: introduce chunking when session cookie becomes too big (#3101)
If the expected cookie size would exceed the 4096 bytes most browsers allow, we split up the cookie value and put the content into multiple cookies, then assemble it upon reading it back. This eliminates the need for a database or user-land solutions in case the user wants to save more data or is constrained by their IdP for certain fields.
2021-11-15 10:30:26 +01:00
Rraji Abdelbari
38cefdd548 fix(providers): set 42 default scope (#3189)
With no scope defined, it sets `openid` by default, which is an invalid 42 scope.

Co-authored-by: Alaa Zorkane <alaazorkane@gmail.com>

Co-authored-by: Alaa Zorkane <alaazorkane@gmail.com>
2021-11-13 11:14:29 +01:00
Balázs Orbán
b871b47d8b fix: allow configuring http timeout (#3188) 2021-11-12 12:58:08 +01:00
Balázs Orbán
043b252940 refactor: decouple CSRF-state (#3142)
* refactor: decouple csrf token from state

* refactor: simplify pkce-handler
2021-11-11 22:30:19 +01:00
Balázs Orbán
e9ac11b4b2 fix: respect host in getServerSession (#3179) 2021-11-11 11:27:14 +01:00
Balázs Orbán
ba39efb256 feat: rename session strategy (#3144)
BREAKING CHANGE:

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://next-auth.js.org/faq#json-web-tokens

Example:

```diff
session: {
-  jwt: true,
+ strategy: "jwt",
}
```
2021-11-07 21:06:10 +01:00
Balázs Orbán
6502b63e9c feat: allow relative redirects (#3140) 2021-11-07 17:40:13 +01:00
Balázs Orbán
0d7d8da2d9 fix: use error query param if set (#3141) 2021-11-07 17:37:09 +01:00
Mathis Møller
f998bf2768 refactor: strict types (#2802)
* WIP strict types

* wip types

* wip strict types

* More strict typing

* Removing strict false
Fix last types

* Fix typo

* Make TS happy

* Fix tests

* Fixes to types

* Make files align with strict mode
2021-11-04 20:01:45 +01:00
Kovacs Nicolas
78fa33312f docs(readme): opencollective domain (#3066)
I had 502 using `opencollective.org` for some time, also, the correct domain looks like `opencollective.com`
2021-11-04 08:16:30 +01:00
Nico Domino
533ed949b3 feat: Clerk to README supporters
Added Clerk to supporters section!
2021-11-03 22:53:38 +01:00
Balázs Orbán
1597369d30 fix: correctly transpile all client-side submodules (#3100) 2021-11-03 18:31:02 +01:00
Balázs Orbán
41819882be fix(oauth): allow 10 sec clock tolerance (#3071) 2021-10-31 14:57:25 +01:00
Srijan Sharma
b66afcc5cc fix: normalize URL before parsing (#3077) 2021-10-31 10:35:02 +01:00
Filip Skokan
da991de8a4 fix: bump openid-client (#3063)
fixes #3052
2021-10-29 14:10:14 +02:00
Balázs Orbán
1d9b7b82b9 feat(react): preserve history on client-side navigation (#2980)
* feat(react): preserve history on client-side navigation

* chore(deps): upgrade jest

* test(client): use absolute URL since `whatwg-*` refusing relative URLs
2021-10-29 12:55:53 +02:00
Filip Skokan
c089ede3af refactor: use universal modules in next-auth/jwt (#3062) 2021-10-29 12:45:47 +02:00
Thang Vu
5725931406 fix(providers): add default id_token_signed_response_alg to LINE (#3059)
* Add default value for client in Line Provider

* Migrate to TypeScript
2021-10-29 10:33:25 +02:00
Haye
c8b7e2e3cb fix: uuid import (#3056) 2021-10-28 22:33:13 +02:00
Filip Skokan
72408ab7d7 feat: update jose and openid-client (#3039)
Updates the `jose` and `openid-client` packages.

BREAKING CHANGE:

The `jwt` option has been simplified and the NextAuth.js issued JWT is now encrypted by default.

If you want to override the defaults, you can still use the `encode` and `decode` functions. These are advanced options and they should only be used if you know what you are doing.

The default secret generation has been removed in this PR, which will be added back in a separate one. Remember, that is only for developer convenience, it is **highly** recommended to always create your own secret for production.
2021-10-27 22:09:46 +02:00
Balázs Orbán
eb33c9db1d refactor: decouple Next.js from core (#2857)
* refactor: decouple Next.js from core (WIP)

* refactor: use `base` instead of `baseUrl`+`basePath`

* fix: signout route

* refactor(ts): convert files to TS

* fix: imports

* refactor: convert callback route

* fix: add `next` files to package

* chore(dev): alias npm email

* refactor: do not merge req with user options

* refactor: rename userOptions to options

* refactor: use native `URL` in `parseUrl`

* refactor: move Next.js specific code to `next` module

* refactor(ts): return `OutgoingResponse` on all routes

* fix: change `base` to `url`

* feat: introduce `getServerSession`

* refactor: move main logic to `handler` file

* chore(dev): showcase `getServerSession`

* feat: extract `sessionToken` from Authorization header

* fix: pass headers to getServerSession

* refactor: rename `server` to `core`

* refactor: re-export `next-auth/next` in `next-auth`

* fix: add `core` to npm package

* fix: re-export default method

* feat: return `body`+`header` instead of `json`,`text`

* feat: pass `NEXTAUTH_URL` as a variable to core

* refactor: simplify Next.js wrapper

* feat: export `client/_utils`

* fix(ts): suppress TS errors
2021-10-27 16:11:58 +02:00
Tania
932d05da70 docs: mention other repos in readme and issue forms (#2989)
* Update bug_report.yaml

Add information about distributing issues to the correct repo

* fix yaml syntax

* remove new line

* improve content

* Import content

* remove one emoji

* Update feature_request.yaml

* Update README.md
2021-10-22 09:40:18 +02:00
Balázs Orbán
58a98b667d fix(providers): resize default AzureAD profile picture (#2910)
* Update azure-ad.js

* fix: default azure AD profile photo size

Co-authored-by: ndom91 <yo@ndo.dev>
2021-10-10 18:47:51 +02:00
Thang Vu
129d161115 fix(providers): Refactor Line Provider (#2917)
* feat(providers): Refactor Line Provider

* Use static wellKnown + retrieve email

* Remove issuer
2021-10-08 16:09:38 +02:00
Nico Domino
19e326e8e2 fix: conditionally render theme logo on builtin pages (#2916)
* fix: conditionally render theme logo

* fix: add dispaly to render span

* fix: theme-logo img display
2021-10-08 04:43:53 +02:00
Balázs Orbán
a0b9577267 chore(deps): upgrade dependencies (#2900) 2021-10-06 01:42:29 +02:00
Balázs Orbán
dfff2e692f fix: correctly set authorization url for OAuth1 (#2884) 2021-10-03 15:26:14 +02:00
Balázs Orbán
5149a5d865 chore: trigger CI 2021-10-03 13:29:49 +02:00
Gegham Zakaryan
0707ba663b fix(signin): Set default input type to text to fix CSS (#2881) 2021-10-03 01:01:34 +02:00
Gegham Zakaryan
c5bd99d92a feat(signin): Support passing any argument to credentials input (#2876)
Spreading the object into the input tag allows developers to specify any attribute for the input tag used in the builtin sign-in page, such as 'autocomplete', 'autofocus', etc.

Removed the hardcoded attributes which just set the defaults of the 'input' tag and won't cause any behavior change in case they are absence from the object.

Signed-off-by: Gegham Zakaryan <zakaryan.2004@outlook.com>
2021-10-01 23:25:35 +02:00
Balázs Orbán
72d4c5bfe1 feat(providers): refactor Azure B2C provider (#2862)
* fix(providers): refactor AzureB2C provider

* chore(dev): add Azure B2C to the dev app

* chore(providers): remove unnecessary config
2021-09-29 23:43:42 +02:00
Kiran Jd
f6350354f0 fix(provider): refactor Okta provider (#2856)
* fix(provider): refactor Okta provider

* fix(providers): convert Okta to TS

* fix: typo

* fix(okta): adds picture to profile

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* fix(provider): refactor Okta provider

fix(providers): convert Okta to TS

fix: typo

* fix: resolves merge conflicts

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-09-28 20:59:57 +02:00
Balázs Orbán
50e6a64832 feat(providers): expose openid-client options client and jwks (#2717) 2021-09-28 17:32:47 +02:00
Balázs Orbán
9e1eab088a fix(providers): convert to TS, add picture (#2851) 2021-09-28 14:47:33 +02:00
Balázs Orbán
f0551b07b8 feat(providers): refactor Slack provider (#2848)
* chore(dev): add SlackProvider to dev app

* feat(providers): refactor Slack provider

* chore(dev): remove unwanted provider
2021-09-28 14:47:18 +02:00
Balázs Orbán
c2fd58d72a chore: remove unused www reference 2021-09-28 01:53:09 +02:00
Balázs Orbán
b052d4cfc1 fix(providers): make string endpoint handlers overrideable (#2842)
* chore: remove `console.log`

* chore(ts): improve `InternalProvider` type

* refactor(ts): convert some files to TypeScript

* fix(providers): make string endpoint handlers overrideable
2021-09-26 22:02:21 +02:00
Balázs Orbán
506672676a feat(providers): refactor Cognito provider (#2829)
* chore(dev): add CognitoProvider to dev app

* feat(log): log `error_description` in OAuth callback

* fix(providers): migrate Cognito to v4

* docs: mention superblog.ai for infra support

* fix: return profile picture for Cognito

* fix(ts): add picture to CognitoProfile
2021-09-25 14:14:56 +02:00
Nico Domino
ffa2b1bd6b fix: use default export map syntax for ESM/CJS (#2830) 2021-09-25 14:01:28 +02:00
Balázs Orbán
1d52600f41 fix(provider): refactor LinkedIn provider (#2821) 2021-09-24 11:27:57 +02:00
Balázs Orbán
9693277222 chore(app): add SpotifyProvider to dev app 2021-09-23 00:43:28 +02:00
Balázs Orbán
19a33f3131 chore(dev): add AzureADProvider to dev app 2021-09-22 23:55:49 +02:00
Nico Domino
424bd04eff fix(providers): refactor Azure AD provider to support v4 (#2818) 2021-09-22 23:35:13 +02:00
ndom91
a177bbb68c fix: login logo height 2021-09-22 22:21:45 +02:00
Jussi Räsänen
04fc3fd6bc fix(provider): remove extra brace from jwks_uri (#2813) 2021-09-22 16:17:43 +02:00
Nico Domino
cabcdc967f feat: built-in page theme updates (#2788)
Add some very minimal customization to the built-in pages so people might not immediately need to replace them. This way they can customize some things with their brand color and add their company/project logo. We explicitly **do not** want to go overboard styling this page. This is not an authentication component library or Next.js app template!

Example:
```js
export default NextAuth({
  providers: [...],
  jwt: {...},
  theme: {
    colorScheme: 'auto',
    brandColor: '#67b246',
    logo: 'https://company.com/assets/logo.png'
  }
})
```
2021-09-20 00:48:36 +02:00
Balázs Orbán
a2c4046772 fix(ts): add defaults to OAuthConfig generics 2021-09-15 10:24:26 +02:00
Balázs Orbán
ea3f0d6911 refactor(ts): move Twitch to TypeScript 2021-09-15 10:19:35 +02:00
Mathis Møller
819e97e6d2 fix: respect id from user options in signinUrl and callbackUrl id (#2698) 2021-09-08 20:31:24 +02:00
Patryk Slowinski
17bea4ab69 fix(ts): hint built-in provider types in signIn (#2655)
* Change singIn provider type to optional string

* provider intellisense support

* restore clean

* Requested changes

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-09-07 10:56:55 +02:00
Balázs Orbán
0989accf23 fix(ts): make OAuth profile overrideable (#2682)
* fix(ts): make OAuth profile overrideable

* fix(ts): default to empty object

* fix(ts): use relative import
2021-09-06 23:42:03 +02:00
Balázs Orbán
3b23cfe3a5 fix(ts): forward credentials fields to authorize (#2683) 2021-09-06 23:41:30 +02:00
Balázs Orbán
419ffe7787 fix(ts): make options on useSession optional
Fixes #2674
2021-09-06 10:58:09 +02:00
Balázs Orbán
2cb763ceba chore: remove test:types script in release workflow 2021-09-05 11:14:04 +02:00
Balázs Orbán
8bfbaa41a9 chore: fix build due to Next.js type error
See: https://github.com/vercel/next.js/pull/28672
2021-09-05 11:11:29 +02:00
Balázs Orbán
7dfc5811b0 chore: remove docs after merge 2021-09-04 12:28:50 +02:00
Balázs Orbán
3f943d2f8a Merge beta into next 2021-09-04 12:28:19 +02:00
Balázs Orbán
da8d729129 Merge main into next 2021-09-04 12:23:22 +02:00
Balázs Orbán
245567bb98 fix: avoid infinite loop in error handlers (#2647)
* fix: avoid infinite loop in error handlers

* chore(dev): remove mongodb folder
2021-09-03 01:25:56 +02:00
Balázs Orbán
8f32b5d625 refactor(dev): use Next.js externalDir to fix dev app (#2631) 2021-09-01 21:06:36 +02:00
Balázs Orbán
e099223a27 refactor(ts): rewrite core to TypeScript (#2552)
* chore(deps): upgrade TS packages

* build(ts): use tsc to compile

* refactor(ts): move some files to TS

* chore: implement SkyPack check suggestions

* chore(ci): temprarily disable tests

* chore: add PR comment action

* chore: add determine version github action

* chore: prefix with env.

* chore: add runs to action

* chore: change runs.using to node12

* chore: fix typo

* chore: install @actions/core as dev dependency

* chore: move env var, remove old script

* chore: change version comment message

* refactor(ts): convert server/index.js to TS

* chore: fix `types` path

* chore: fix paths

* refactor(ts): convert `next-auth/react`

* refactor(ts): convert `next-auth/jwt` to TS

* chore: fix import

* refactor: move `types` into `src`

* refactor(ts): fix types imports

* chore: add cleanup script

* chore: exclude all `tests` folder from compilation

* refactor: rename types/index.d.ts to types/index.ts

* refactor(ts): move `next-auth/jwt`

* refactor(ts): move `next-auth/providers`

* chore(ts): fix `next-auth` types

* refactor(ts): change internal import paths

* test(ts): remove type tests

* chore: remove test:types script

* refactor(ts): move more code to TypeScript

* refactor: fix some imports

* refactor(ts): move error module into server

* fix(ts): add type to .js providers

* chore: rename adapters.ts to adapters.d.ts

* fix: update exports field

* chore: add files that should end up on npm

* chore: add stricter lib checking

* refactor(ts): remove unnecessary files, fix imports

* chore: autocomplete env variables

* fix: add css folder to npm files

* fix: fix CSS import/generation

* feat: log provider when authorization url error happens

* refactor(ts): turn pages into .tsx

* chore: compile differently for client/server

* refactor(ts): move server file to TS

* chore: add back node target

* chore: add back comment removal

* chore: re-enable tests

* chore: ignore test files when building

* chore(ts): refactor files to TS

* chore(ts): fix imports

* chore(ts): more ts

* fix(ts): correctly type _NEXTAUTH_DEBUG env var

* chore: don't generate internals module iwth babel

* fix(ts): better `clientId`, `clientSecret` constraints

* refactor(ts): move facebook provider to TS

* refactor(ts): apply suggested changes

* chore(ts): strip internal types from compilation

* refactor(ts): move server types to server folder

* refactor(ts): rename internals to types
2021-08-31 15:18:12 +02:00
Gianluca
e8a58a01b6 docs(contributing): fixed numeration type (#2624)
There was a numeration type error in the "For  contributors" section
2021-08-29 11:30:05 +02:00
Lluis Agusti
08349c3a8b feat(client): remove staleTime (#2613)
BREAKING CHANGE:

`staleTime` (previously `clientMaxAge`) has been removed. Check out `refetchInterval` instead. It should cover most of the cases. If not, we can look into adding this back later on.
2021-08-27 21:44:10 +02:00
Balázs Orbán
1c1e8410e6 chore(docs): remove docs from repo (#2609)
Documentation has been moved to its own repository. See https://github.com/nextauthjs/docs
2021-08-27 13:15:33 +02:00
Balázs Orbán
a49903fd76 Merge main into next 2021-08-27 00:48:11 +02:00
Nico Domino
55ab95e3be docs(providers): split provider type docs into individual pages (#2480)
* docs(providers): split provider type docs into individual pages

* fix: spelling

* docs: wrap interface

* fix: oauth provider config copy
2021-08-27 00:25:00 +02:00
Nico Domino
5da62888ce docs: add v4 migration docs page (#2350)
* docs: add initial migration to v4 docs page

* docs: add upgrade guide to sidebar

* docs: number migration sections

* docs: add more breaking changes and link to releases

* docs: cleanup text

* docs(dep): bump docusaurus to latest beta

* docs(www): upgrade guide

Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(www): upgrade guide

Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(www): upgrade guide

Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(www): upgrade guide

Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(www): add nodemailer link

* docs(www): add v4-next.20 breaking change notes

* docs(www): typo

* Update www/docs/getting-started/upgrade-to-v4.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update www/docs/getting-started/upgrade-to-v4.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* docs(www): move provider rename hint

* docs(www): add OAuth provider import changes

* docs(www): add adapter notes

* fix: update schema image

* docs(typeorm): add new postgres schema

* docs(typeorm): add new mysql schema

* docs(typeorm): fix mysql timestamp fields

* docs(www): update provider copy

* docs(www): add note regarding github provider scope

* docs: add suggestions to migration docs

* docs: add note about adapter api rewrite

* docs: fix upgrade headings

* docs: upgrade docs copy

* docs: upgrade link

Co-authored-by: Lluis Agusti <hi@llu.lu>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-08-27 00:01:50 +02:00
Nico Domino
91de463a5e docs(providers): add tip about async provider code (#2443) 2021-08-26 23:45:07 +02:00
Nico Domino
4a9d871698 docs(www): add more algolia no-result terms (#2442) 2021-08-26 23:41:49 +02:00
Alex Vilchis
c2119b15de chore(docs): fix dependency name (#2607) 2021-08-26 19:42:20 +02:00
Lluis Agusti
d76f15b6fa test(client): fully cover client module (#2295)
Contains:

* test(client-provider): fix flaky test
* wip
* test(client-provider): verify more use-cases
* test(client): programmatic session refetch
* test(client): further coverage
* test(client): `stateTime` + `refetchInterval`
* refactor(client): test insights
* refactor: unused variable
* chore: revert `package-lock.json` to  v2
* refactor: pair-review suggestions
2021-08-26 15:30:58 +02:00
Alex Vilchis
0ce15c4a18 docs: Fix grammar (#2602) 2021-08-25 19:48:14 +02:00
Bruno Bigras
eb8ba69d3b feat(provider): add Keycloak provider (#2485)
* add Keycloak provider

* Update src/providers/keycloak.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-08-23 22:43:05 +02:00
dan-kwiat
a9f699fd54 fix(callback): respect callbackUrl in Email Provider (#2574)
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-08-23 22:10:33 +02:00
Nico Domino
ead715219a fix(deps): update built-in adapter dependencies (#2589)
* fix(deps): update prisma-legacy-adapter and typeorm-legacy-adapter dependencies

* chore: add missing package-lock update
2021-08-23 21:55:33 +02:00
nathanclevenger
e15bf9b2f5 feat(provider): use more restrictive default scope for GitHub (#2579)
When using the default settings of the Github provider, with the "user" scope, it grants read/write access to profile info only. By changing to "read:user" and "user:email" it will only request read-only access https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps

BREAKING CHANGE:

By default, the GitHub Provider scope won't ask for full write access to user profiles. If you need that, you will now have to add the `user` scope to your configuration.
2021-08-22 01:29:48 +02:00
Ashutosh Kumar
8faa7553dd docs: add suggestions for secret and encryption key generation (#2578) 2021-08-21 23:08:56 +02:00
Eduard Babinyan
90a6a0084b feat(provider): return image for Yandex by default (#2563)
Uploading an user image.
2021-08-20 09:37:30 +02:00
Aaron Powell
cb844a2436 docs(provider): remove en-us from Azure urls (#2554)
MS Docs has a lot of local language translations, so it's best to remove locale information from the URLs so that when someone follows them, they land on the right language version of the content.
2021-08-18 09:46:32 +02:00
Balázs Orbán
e06ced5b66 chore: add FaunaAdapter to dev app 2021-08-17 23:51:53 +02:00
Balázs Orbán
2c43fbd867 fix(provider): remove double CSS from email template 2021-08-17 12:24:08 +02:00
Sercan Altundas
74558d6cc2 docs(email): remove duplicate CSS property from html (#2546)
- The CSS property 'text-decoration: none;' was duplicated in the example html code and is removed.
2021-08-17 12:17:54 +02:00
Jaye Hackett
d03125a77b docs(ts): mention module augmentation on callbacks (#2541) 2021-08-17 01:01:19 +02:00
Balázs Orbán
78d8f28968 fix(ts): allow void return type on delete operations 2021-08-16 11:50:43 +02:00
Balázs Orbán
8914f88cd7 feat: simplify Adapter API (#2361)
BREAKING CHANGE:

`prisma-legacy` is now gone. Use `@next-auth/prisma-adapter`. Any features from the old adapter will be migrated over to the new one eventually. This is done so we can require the same default set of options from all the built-in providers, rather than allowing ambiguity on what an official adapter has to support.

The `TypeORM` adapter will probably be the only one migrated as-is, but in the future, we would like to break it down to lighter-weight adapters that only support single databases.

Adapters no longer have to return a `getAdapter()` method, they can return the actual adapter methods instead. All the values previously being provided through the arguments of `getAdapter` will now be available in a more digestible format directly in the concerning methods. This behavior was created so that connections could be handled more efficiently. Our review has shown that currently, the TypeORM adapter is the only one that does not handle connections out-of-the-box, so we are going to look into how we can create a wrapper/util function to make it work in the new version. For all other adapters, this will be a huge gain, as with this new API, methods are actually overrideable without creating a whole new custom adapter! 🥳

Example:

```js
function MySlightlyCustomAdapter(...args) {
  const adapter = AdapterFromSomeoneElse(...args)
  adapter.someMethodIWantToModify = (...args) => {
    // Much better implementation goes here.
  }
  return adapter
}
```

**The following method names are changing:**

```diff
- getSession
+ getSessionAndUser
```
This method now requires that you return both the user and the session as `{user, session}`. If any of these could not be retrieved, you will have to return `null` instead. (In other words, this must be a transaction.) This requires one less database call, improving the user session retrieval. Any expiry logic included in the Adapter before is now done in the core as well.

```diff
- createVerificationRequest
+ createVerificationToken
```
Better describes the functionality. This method no longer needs to call `provider.sendVerificationRequest`, we are moving this into the core. This responsibility shouldn't have fallen to the adapter in the first place.

`createVerificationToken` will now receive a `VerificationToken` object, which looks like this:
```ts
interface VerificationToken {
  identifier: string
  expires: Date
  token: string
}
```

The token provided is already hashed, so nothing has to be done, simply write it to your database. (Here we lift up the responsibility from the adapter to hash tokens)


```diff
- getVerificationRequest
+ useVerificationToken
```
Better describes the functionality. It now also has the responsibility to delete the used-up token from the database. Most ORMs should support retrieving the value while deleting it at the same time, so it will reduce the number of database calls.

``` diff
- deleteVerificationRequest
```
This method is gone. See `useVerificationToken`.

Most of the method signatures have been changed, have a look at the [TypeScript interface](ba4ec5faa3/types/adapters.d.ts) to get a better picture.
2021-08-15 21:01:56 +02:00
Balázs Orbán
55132e5da2 feat(provider): require to import every provider individually (#2518)
Adds a new way to import providers for modularity and better tree-shaking.

BREAKING CHANGE:

Providers now have to be imported one-by-one:

Example:
```diff
- import Provider from "next-auth/providers"
- Providers.Auth0({...})
+ import Auth0Provider from "next-auth/providers/auth0"
+ Auth0Provider({...})
```
2021-08-13 19:12:52 +02:00
Balázs Orbán
65040dcc83 fix(provider): make userinfo.params optional (#2517) 2021-08-13 18:38:24 +02:00
Liam Tait
66d16f8bf4 fix(ts): allow scope as string array type (#2511) 2021-08-12 17:51:31 +02:00
Griko Nibras
92b9d22309 fix(ts): fix internal react type import (#2450)
Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-08-12 13:06:58 +02:00
Balázs Orbán
b50a2eb845 refactor: remove wrapping Promise (#2514)
* refactor: don't wrap NextAuth handler with Promise

* refactor: update OneLogin provider config

* chore: add OneLogin to dev app

* chore: fix typo
2021-08-11 14:05:21 +02:00
Balázs Orbán
e5fe470792 Merge main into next 2021-08-05 01:27:44 +02:00
Balázs Orbán
7c65bda6f1 feat: improve OAuth provider configuration (#2411)
> This touches on all OAuth providers, so there is a big potential for breaking by default. We have let new providers be added for contributors' specific needs, but from now on, we will require a more strict default on all new providers, so the basic behavior is predictable for everyone.
⚠ Unfortunately, we will not have the capacity to test each and every provider that has been added to the default providers, but we will do our best to test the most popular ones. (@ndom91 has worked on setting up the infrastructure for this). If you wish to make sure that the provider you are using will stay working, please reach out with your concerns and tell us how can you help us test that particular provider in the future. 🙏

That said, I will try my best to not break ANY of the currently built-in providers, or at least make the migration super easy. So hopefully, you won't have to change anything. It will most probably affect you if you defined a custom provider though.

We will monitor the default configuration much more closely, so the behavior will be more consistent across providers by default.

Closes #1846, Closes #1605, Closes #1607

BREAKING CHANGES:

Basecamp provider is removed. See the explanation [here](https://github.com/basecamp/api/blob/master/sections/authentication.md#on-authenticating-users-via-oauth)

**ALL** OAuth providers' `profile` callback is expected to only return these fields by default from now on: `id`, `name`, `email`, and `image` at most. Any of these missing values should be set to `null`.

The following new options are available:
1. `authorization` (replaces `authorizationUrl`, `authorizationParams`, `scope`)
2. `token` replaces (`accessTokenUrl`, `headers`, `params`)
3. `userinfo` (replaces `profileUrl`)

These three options map nicely to the OAuth spec's three endpoints for
1. initiating the login flow
2. retrieve OAuth tokens
3. retrieve user information

They all take the form of `EndpointHandler`:
```ts
type EndpointRequest<C, R> = (
  context: C & {
    /** `openid-client` Client */
    client: Client
    /** Provider is passed for convenience, ans also contains the `callbackUrl`. */
    provider: OAuthConfig & {
      signinUrl: string
      callbackUrl: string
    }
  }
) => Awaitable<R>

/** Gives granular control of the request to the given endpoint */
type AdvancedEndpointHandler<P extends UrlParams, C, R> = {
  /** Endpoint URL. Can contain parameters. Optionally, you can use `params`*/
  url?: string
  /** These will be prepended to the `url` */
  params?: P
  /**
   * Control the corresponding OAuth endpoint request completely.
   * Useful if your provider relies on some custom behavior
   * or it diverges from the OAuth spec.
   *
   * - ⚠ **This is an advanced option.**
   * You should **try to avoid using advanced options** unless you are very comfortable using them.
   */
  request?: EndpointRequest<C, R>
}

/** Either an URL (containing all the parameters) or an object with more granular control. */
type EndpointHandler<P extends UrlParams, C = any, R = any> =
  | string
  | AdvancedEndpointHandler<P, C, R>
```

In case of `authorization`, the `EndpointHandler` can define the `params` as [`AuthorizationParameters`](51dc47d9ac/types/index.d.ts (L108-L143))

> Note: `authorization` does not implement `request` yet. We will have to see if there is demand for it.

From now on, instead of using the `...` spread operator when adding a new built-in provider, the user is expected to add `options` as a property at the end of the default config. This way, we can deep merge the user config with the default one. This is needed  to let the user do something like this:

```js
MyProvider({
  clientId: "",
  clientSecret: "",
  authorization: { params: {scope: ""} }
})
```
So even if the default config defines anything in `authorization`, only the user-defined parts will be overridden.
2021-08-05 00:42:47 +02:00
Nico Domino
be74dd0e7e docs(security): email contact update (#2467)
* chore(docs): email contact update

* chore(docs): add me@iaincollins.com back
2021-08-02 17:18:17 +02:00
Aryan Beezadhur
9bf867ddcf docs: Update faq.md (#2458) 2021-07-30 22:34:32 +02:00
Nico Domino
0f460c22da docs(client): add text regarding 'logout' (#2432) 2021-07-28 20:10:08 +02:00
Sigurd Heggemsnes
887cb00877 docs(adapter): Typo in filepath for firebase auth in docs. (#2436) 2021-07-28 12:48:47 +02:00
Balázs Orbán
f06e4d286b refactor: replace node-oauth with openid-client (#1698)
* chore(deps): add openid-client

* chore: merge in next

* refactor(provider): remove redundant requestUrl param

* feat(provider): make profile callback optional

* refactor: use openid-client for OAuth2/OIDC

* refactor: use openidClient in oauth signin handler

* refactor: use openidClient in oauth callback handler

* docs(warn): add async issuer/old config warnings

* chore(deps): remove jsonwebtoken

* chore: add issuer property for testing locally

* chore(dev): import providers one-by-one

* fix(oauth): handle when no user in body/query

* chore(deps): remove pkce-challenge

* chore(dev): change Auth0 protection

* refactor(oauth): simplify pkce/state

* refactor: split OAuth1 client, reduce openid client

will improve API in another PR

* chore: change comment, dev app

* chore: mention OIDC client config discovery

* fix: add new operator when creating OIDC client

* refactor: delete req.query.nextauth after use

* docs(ts): use `TokenSet` from `openid-client`

* chore: simplify/type signin route

* refactor: rename to client-legacy to indicate intnet of maintenance

* chore(deps): try setting `oauth` as optional peer dep

* chore(deps): add `oauth` back as regular dependency

* chore(deps): add @types/oauth as dev dependency

* chore: remove params kept for backwards compatibility

* chore: don't make breaking changes in this PR

* chore(core): use correct TS declarations

* refactor: move files/add more accurate types internally

* chore: remove TODO comment

* chore: catch all errors in authorization URL generation
2021-07-20 14:52:35 +02:00
Douglas
75ca097ff7 docs: Fix link to code (#2405) 2021-07-19 15:36:37 +02:00
Nicolas Azari
bcb9383aec docs: fix typos in options.md (#2393)
* Update options.md

* Update www/docs/configuration/options.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-07-17 22:21:45 +02:00
Lluis Agusti
bececbc200 Revert "refactor(providers): try Typescript"
This reverts commit 6d74da1f65.
2021-07-17 21:58:25 +02:00
Lluis Agusti
6d74da1f65 refactor(providers): try Typescript 2021-07-17 21:56:18 +02:00
John Michael Kuhn Jr
b953963101 chore(core): fix typo in csrf-token-handler.js where 'strategy' is misspelled (#2391) 2021-07-17 12:02:38 +02:00
Nico Domino
4649f1968b docs(readme): add opencollective details to readme (#2388)
* docs(readme): add opencollective details to readme

* docs(www): add sponsors to docs footer

* docs(readme): move support under ack

* docs(www): dropped docusaurus link in footer
2021-07-16 18:05:15 +02:00
Angelo Annunziata
45f4a69a4e docs(configuration): remove comments in JWT example (#2378) 2021-07-16 09:28:19 +02:00
Prabhdeep Singh
2155c93a3c feat(providers): add OneLogin (#2345)
Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-07-14 11:07:56 +02:00
Angelo Annunziata
d5958571a4 docs(provider): fix typo (#2369) 2021-07-13 21:36:00 +02:00
Theo Browne
3312e53279 feat(events): include profile on signIn events (#2356)
* include profile on signIn events

* update docs

* Undefined profile on credentials, update docs
2021-07-13 18:12:24 +02:00
James Q Quick
ebecaa6a4b docs(adapter): match Fauna index name with implementation(#2360)
* Update Fauna Adapter 

- added one-liner to explain how to use the setup scripts inside of the Fauna dashboard
- updated the `verification_request_by_token` index name to match what is expected inside of the SDK which is `verification_request_by_token_and_identifier`

* Update Typo

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-07-13 17:58:58 +02:00
Vincent Grafé
1c5173a818 docs(callbacks): fix typo (#2363) 2021-07-13 10:24:05 +02:00
Nico Domino
ebf420c84a docs: clarify page protection (#2355) 2021-07-12 01:28:39 +02:00
Balázs Orbán
111d5fc572 feat(events): use named params for all event callbacks (#2342)
Unified API for all of our user-facing methods.

NOTE: `events.error` has been removed. This method has never been called in the core, so it did actually nothing. If you want to log errors to a third-party, check out the [`logger`](https://next-auth.js.org/configuration/options#logger) option instead.

BREAKING CHANGE:

Two event signatures changed to use named params, `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 })
}
```
2021-07-12 00:30:24 +02:00
Balázs Orbán
acc9393560 feat(logger): simplify logger API (#2344)
Similar to #2342, this aims to unify the user-facing API and provide an easier way to extend in the future.

In addition, this PR also solves the problem when the `logger.error` method sometimes did not print results, because `Error` instances are not serializable and will be printed as empty objects `"{}"`.

After this PR, we make any `Error` instances serializable as described here: https://iaincollins.medium.com/error-handling-in-javascript-a6172ccdf9af

Closes #1602
Achieved by adding a `client: true` flag when logs are coming from the frontend.

BREAKING CHANGE:

The main change is that instead of an unknown number of parameters, the log events have at most two, where the second parameter is usually an object. In the case of the `error` event, it can also be an `Error` instance (that is serializable by `JSON.stringify`). If it is an object, an `Error` instance will be available on `metadata.error`, and `message` will default to `metadata.error.message`. This is done so that an error event always provides some kind of a stack to see where the error happened

```diff
// [...nextauth.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) {}
}
```
2021-07-12 00:17:32 +02:00
Ben Goshow
35ce332cc6 feat(providers): add Freshbooks (#2322)
Contains the following squashed commits: 

* Create freshbooks.js
* Create freshbooks.md
* Update providers.d.ts
* Update freshbooks.md
* Update src/providers/freshbooks.js
* Update providers.test.ts
* Update freshbooks.md
2021-07-11 20:25:26 +02:00
Imamuzzaki Abu Salam
ec295287f1 docs: delete can word in "can can" (#2348) 2021-07-11 15:08:05 +02:00
Balázs Orbán
6911dd9267 feat: rename protection to checks (#2255)
This change aligns the API with `openid-client`'s `checks` https://github.com/panva/node-openid-client/blob/main/docs/README.md#clientcallbackredirecturi-parameters-checks-extras, a library which we intend to migrate to in the future. Aligning our API early, so people get used to it.

Also, objectively the name `protection` might not have been as clear as I first thought. `checks` better describe the intention.

BREAKING CHANGE:

The `state` option on OAuth providers is now deprecated. Use `checks: ["state"]` instead.
`protections` is renamed to `checks`, here is an example:
```diff
- protection: ["pkce"]
+ checks: ["pkece"]
```

Furthermore, string values are not supported anymore. This is to be able to handle fewer cases internally.
```diff
- checks: "state"
+ checks: ["state"]
```
2021-07-10 23:55:20 +02:00
Balázs Orbán
cff153bd80 Merge main into next 2021-07-10 12:02:21 +02:00
Nick Arciero
46978ac02f docs(tutorial): Add link to blog post about integrating with Magic (#2340) 2021-07-10 09:56:13 +02:00
Pol
f546e550dd fix(oauth): correctly remove code_verifier cookie when used (#2325)
Co-authored-by: Pol Bonastre <pbonastre@plainconcepts.com>
2021-07-08 17:24:56 +02:00
Balázs Orbán
ac5b4db0f2 chore: add OpenCollective link to FUNDING.yml 2021-07-05 17:54:34 +02:00
Balázs Orbán
a2e5afa162 feat(react): make session requireable in useSession (#2236)
A living session could be a requirement for specific pages (like dashboards). If it doesn’t exist, the user should be redirected to a page asking them to sign in again.

Sometimes, a user might log out by accident, or by deleting cookies on purpose. If that happens (e.g. on a separate tab), then `useSession({ required: true })` should detect the absence of a session cookie and always return a non-nullable Session object type.

When `required: true` is set, the default behavior will be to redirect the user to the sign-in page. This can be overridden by an `action()` callback:

```js
const session = useSession({
  required: true,
  action() {
    // ....
  }
})
if (session.status === "Loading") return "Loading or not authenticated..."

// session.data is always defined here.
```

Co-authored-by: Kristóf Poduszló <kripod@protonmail.com>
Co-authored-by: Lluis Agusti <hi@llu.lu>

BREAKING CHANGE:

The `useSession` hook now returns an object. Here is how to accommodate for this change:

```diff
- const [ session, loading ] = useSession()
+ const { data: session, status } = useSession()
+ const loading = status === "loading"
```

With the new `status` option, you can test states much more clearly.
2021-07-05 16:03:55 +02:00
Nico Domino
53e5e37948 docs: update tutorials/faq structure (#2256)
* docs: cleanup css

* docs: upgrade deps

* docs: cleanup docusaurus config

* docs: reorganise tutorials page

* docs: fix github-counter css

* docs: update faq page structure

* docs(tutorials): copy

Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(tutorials): copy

Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(tutorials): copy

Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(tutorials): copy

Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(style): reorg css

Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-07-05 11:15:45 +02:00
Mahieyin Rahmun
8bbffdd08c docs(github): remove title property (#2308) 2021-07-04 13:23:44 +02:00
Mahieyin Rahmun
a22a0a36fd docs(github): remove title prefix and make reproductions required (#2306) 2021-07-04 11:19:13 +02:00
Mahieyin Rahmun
797272afe1 docs: use issue template forms (#2274)
* (docs) initial issue template forms as per #2271

* (typo) fix grammar and typo

* (forms) make the requested changes

* (chore) delete the old .md files

* (forms) fix type key
2021-07-02 21:13:03 +02:00
Balázs Orbán
8ff4b26014 Merge main into next 2021-07-02 13:10:34 +02:00
Mahieyin Rahmun
13e56bcf2f docs(adapters): update outdated documentation (#2296) 2021-07-02 12:50:27 +02:00
yokinist
b0f7f87c04 docs: update 'pages' option in example code (#2270) 2021-07-01 17:12:01 +02:00
Balázs Orbán
9c0851c0f9 chore(ci): shorten names in release.yml workflow 2021-06-30 21:36:28 +02:00
Andriy Komm
f5b3c29ab1 fix(ts): improve authorize typing on Credentials provider (#2227)
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-06-30 15:49:38 +02:00
Nico Domino
b4f2a0106a chore(ci): add environment approval (#2214)
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-06-30 15:28:12 +02:00
Balázs Orbán
2c35aa27f9 Merge main into next 2021-06-29 22:55:33 +02:00
Balázs Orbán
9c095b0532 chore(dev): fix dev app when running locally (#2280)
* fix: fix console warning in dev app

* chore: add `npm i` to `dev:setup` script

* chore(deps): update dev dependencies (react+next)

* chore: update package-lock.json

* chore: use node 16 in actions
2021-06-29 22:11:55 +02:00
Nico Domino
0475964a0f chore(pages): typo in error messages (#2265) 2021-06-28 02:57:35 +02:00
Justin Forlenza
ad6c13cdc9 fix(ts): extend server type in Email provider from nodemailer (#2259)
* Added optional secure & TLS settings for SMTP

* Replaced custom interface with nodemailers

* Fix lockfile version

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-06-27 18:51:34 +02:00
Nico Domino
591aa7cc7e docs(adapter): rm @canary from adapters' install instructions (#2260) 2021-06-27 18:28:58 +02:00
ndom91
9abb392b4e chore: fix gh action typo 2021-06-27 03:39:38 +02:00
ndom91
b89ae87fb1 docs: respect color mode 2021-06-27 03:38:04 +02:00
ndom91
3687d17724 Merge branch 'main' of ssh://github.com/nextauthjs/next-auth 2021-06-27 03:11:07 +02:00
Balázs Orbán
2833b661bd feat(core): use named params in callbacks (#2173)
Some of our user-facing callbacks come with a bunch of parameters, and it is not always the case that a user needs all of them. Picking out certain parameters from the end of the list would require the user to define params that they wouldn't even need.

Therefore this PR changes such callbacks so the user can only pick the necessary parameters.

This comes with the bonus of better TS support on the `session` and `signIn` callbacks, where some parameters historically could have been different types.

In the `session` callback, the second param could have been `token` (when using JWT sessions) or `user` (when using DB persisted sessions). Now they are separate parameters.

In the `signIn` callback, we now separate `profile` (OAuth), `email` (Email) and `credentials` (Credentials) provider params.

BREAKING CHANGE:

The `callbacks` method signatures are changing the following way:

```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 })
```

> NOTE: You only need to define the params that you actually need (no more need  for `_` params.)

This way, if you only need `token` and `account` in the `jwt` callback, you can write:

```js
jwt({ token, account }) {
  if(account) {
    token.accessToken = account.access_token
  }
  return token
}
```
2021-06-26 14:54:13 +02:00
Balázs Orbán
6c1a0ec620 feat: bump dependencies (#2254)
Node 10 has reached end-of-life, Next.js stopped supporting it in Next 11. Since we are a Next.js library, it doesn't make sense for us to support anything lower than that either.

I also upgraded a bunch of dependencies and dropped some that weren't necessary anymore.

BREAKING CHANGE:

The lowest supported Node version is 12. (We still support IE11 in browsers, until that is not dropped by Next.js itself)
2021-06-26 11:39:18 +02:00
Balázs Orbán
988c9912b1 test(ts): fix ts tests 2021-06-26 00:32:35 +02:00
Balázs Orbán
a225324d4f Merge main into next 2021-06-25 22:10:09 +02:00
Balázs Orbán
b04ff82fb9 chore: clarify where to run envinfo in bug report template 2021-06-24 01:46:02 +02:00
Balázs Orbán
c11915ba9c chore: update bug report template 2021-06-24 01:44:33 +02:00
Balázs Orbán
24ee459f97 chore(ci): run tests and typechecks only 2021-06-24 00:38:17 +02:00
Balázs Orbán
ac4851d238 chore(ci): run test:ci (linting+test+typecheck) 2021-06-24 00:33:32 +02:00
Nico Domino
3a48b8e467 docs: update errors page with more details (#2196) 2021-06-22 20:15:17 +02:00
can-mihci
84094b0ee7 docs(client): fix code block typo (#2217) 2021-06-22 20:11:18 +02:00
Vikrant Bhat
f09ab4a04f docs(providers): fix typo (#2220) 2021-06-22 20:08:43 +02:00
Vikrant Bhat
067364381b docs(providers): fix english sentence in Email provider section (#2222) 2021-06-22 09:28:47 +02:00
Lluis Agusti
fb50b54466 test(client-provider): fix flaky test (#2216) 2021-06-20 20:04:34 +02:00
ndom91
6ee36b6842 ci: test release environment approval 2021-06-18 20:03:07 +02:00
Sheldon Vaughn
fa89431573 docs(provider): import useState in WorkOS example (#2198)
Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Add useState dependency

I went to execute the signin.js file and received an error that useState was undefined. Was able to reconcile this by adding the dependency.

Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Sangwon Park <dev.psw@gmail.com>
2021-06-17 01:23:50 +02:00
Balázs Orbán
3383857715 Merge branch 'main' into next 2021-06-17 01:21:49 +02:00
David Peherstorfer
bbc2d9b538 docs(provider): scope expects space separated string (#2188)
* fix(docs): scope expects space separated string

Currently the docs list string[] as possible type for scope. 
However, It only accepts a string (with space as separator).

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-06-16 07:38:39 +02:00
Sangwon Park
5a89ab69d3 feat(provider): add Naver provider (#2172)
* add Naver provider

* fix typo

* Update src/providers/naver.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-06-16 00:46:41 +02:00
Hugh Boylan
d10bd9beba fix(react): publish react scripts with npm build (#2192) 2021-06-15 23:27:06 +02:00
Vikrant Bhat
c1c866f664 docs(provider): English language sentence fix (#2175)
* English language sentence fix

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-06-14 23:55:10 +02:00
Balázs Orbán
86ff89e296 fix(react): initialize session without loading state (#2180)
See commit dd12181378
2021-06-14 21:16:42 +02:00
Hugh Boylan
dd12181378 initialize session without loading state (#2180) 2021-06-14 20:11:56 +02:00
Balázs Orbán
47c17a89ae Merge branch 'main' into next
commit 665445818e
Author: Balázs Orbán <info@balazsorban.com>
Date:   Sat Jun 12 17:11:53 2021 +0200

    docs(config): link to next documentation instead of canary

commit 67cf2a11bb
Author: ndom91 <yo@ndo.dev>
Date:   Sat Jun 12 16:42:48 2021 +0200

    docs: fix alt client provider example
2021-06-12 17:15:35 +02:00
Balázs Orbán
665445818e docs(config): link to next documentation instead of canary 2021-06-12 17:11:53 +02:00
Nico Domino
c07fe1b9a7 docs: add versioned docs for unreleased v4.0.0-next.* (#2167)
* docs: add versioned docs for unreleased canary 4.x

* docs(fix): prettier broke custom image component without .mdx extension

* docs(feat): automatically fetch latest stable version label

* docs: cleanup script

* docs: cleanup next version name

* docs(chore): cleanup version leftovers

* docs: fix .gitignore

* docs: v4 default

* docs: remove auto version generation

* docs: fix missing import

* docs: rm node-fetch
2021-06-12 17:04:32 +02:00
ndom91
67cf2a11bb docs: fix alt client provider example 2021-06-12 16:42:48 +02:00
Balázs Orbán
abaa5aed65 fix(react): don't use localStorage on server side (#2166) 2021-06-11 22:11:50 +02:00
Balázs Orbán
ca0ed1e2a8 feat(react): create client tailored to React (#1473)
**What**:

These changes ensure that we work more tightly with React that can also result in unforeseen performance boosts. In case we would decide on expanding to other libraries/frameworks, a new file per framework could be added.

**Why**:

Some performance issues (https://github.com/nextauthjs/next-auth/issues/844) could only be fixed by moving more of the client code into the `Provider`.

**How**:

Refactoring `next-auth/client`

Related: #1461, #1084, #1462

BREAKING CHANGE:
**1.** `next-auth/client` is renamed to `next-auth/react`.

**2.** In the past, we exposed most of the functions with different names for convenience. To simplify our source code, the new React specific client code exports only the following functions, listed with the necessary changes:

- `setOptions`: Not exposed anymore, use `SessionProvider` props
- `options`: Not exposed anymore, use `SessionProvider` props
- `session`: Rename to `getSession`
- `providers`: Rename to `getProviders`
- `csrfToken`: Rename to `getCsrfToken`
- `signin`: Rename to `signIn`
- `signout`: Rename to `signOut`
- `Provider`: Rename to `SessionProvider`

**3.** `Provider` changes.
- `Provider` is renamed to `SessionProvider`
- The `options` prop is now flattened as the props of `SessionProvider`.
- `clientMaxAge` has been renamed to `staleTime`.
- `keepAlive` has been renamed to `refetchInterval`.
An example of the changes:
```diff
- <Provider options={{clientMaxAge: 0, keepAlive: 0}}>{children}</Provider>
+ <SessionProvider staleTime={0} refetchInterval={0}>{children}</SessionProvider> 
```

**4.** It is now **required** to wrap the part of your application that uses `useSession` into a `SessionProvider`.

Usually, the best place for this is in your `pages/_app.jsx` file:

```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}>
      <Component {...pageProps} />
    </SessionProvider>
  )
}
```
2021-06-11 21:59:36 +02:00
Balázs Orbán
ed345346db fix(ts): add AzureAD to OAuthProviderType 2021-06-10 20:11:12 +02:00
Ben
5ac1db741a feat(provider): refactor Azure AD, B2C providers (#1591)
BREAKING CHANGE: 

If you currently use `AzureADB2C`, you will need to update it to to `AzureAD` There should be no other changes needed.
2021-06-10 20:09:34 +02:00
Balázs Orbán
0c17af969e Merge branch 'main' into next 2021-06-10 14:49:36 +02:00
Lluis Agusti
832d51f10e test(client): add more tests (#2135)
Contains the following squashed commits:

* test(client): verify CSRF Token fetch
* test(client): verify `getProviders` logic
* test(client): verify `useSession` happy path
* test(coverage): initial coverage setup (trial)
* chore(test): fix coverage reporting
* chore(test): define report directory for codecov

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-06-10 11:42:58 +02:00
Balázs Orbán
29862ac887 fix(build): do not run husky on postinstall (#2158) 2021-06-10 00:24:06 +02:00
Christopher Betz
5aa2b61b88 feat(provider): add Coinbase provider (#2153)
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-06-09 22:46:12 +02:00
Nicholas Chiang
929c644653 docs(client): fix callback anchor links (#2151) 2021-06-09 22:19:26 +02:00
Nicholas Chiang
2657e72e81 docs(callbacks): don't use signIn for redirects (#2150)
Specifies that you shouldn't use the `signIn` callback for arbitrary redirects. Instead, use the `callbackUrl` option or the redirect callback.
2021-06-09 22:17:45 +02:00
Apoorv Taneja
8ff7dbb18f docs(tutorial): Adding a YouTube link for NextAuth.js introduction (#2047)
Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-06-09 17:04:41 +02:00
Tom Richter
ea9b6e37a9 fix(provider): convert github profile id from int to string (#2108) 2021-06-09 17:02:52 +02:00
Manish Kumar
748d576a5a docs(adapter): align DynamoDB docs with source code (#2125)
* Updated DynamoDB Adaptor documentation

* Update dynamodb.md

* Update dynamodb.md

* Update dynamodb.md
2021-06-09 17:01:00 +02:00
Balázs Orbán
960bc1e9c0 feat(adapter): remove adapters from core (#1919)
* feat(adapter): remove built-in adapters and database

BREAKING CHANGE:

From now on, you will have to import your own adapter

Check out https://github.com/nextauthjs/adapters

The migration is super easy and has HUGE advantages for those not using TypeORM.

```diff
// [...nextauth].js
+ import TypeORMAdapter from "@next-auth/typeorm-legacy-adapter"
import NextAuth from "next-auth"

...
export default NextAuth({
-  database: "yourconnectionstring",
+ adapter: TypeORMAdapter("yourconnectionstring")
})
```


Co-authored-by: Lluis Agusti <hi@llu.lu>
Co-authored-by: Giovanni Carnel <479046+g10@users.noreply.github.com>
2021-06-09 14:45:13 +02:00
Balázs Orbán
d29e3e9c9d Merge branch 'main'
Conflicts:
	config/babel.config.json
	package-lock.json
	package.json
	src/server/index.js
	src/server/routes/callback.js
	src/server/routes/signin.js
2021-06-09 02:16:11 +02:00
Camille Gabrieli
9f16e3f0fb docs(client): fix typo (#2139) 2021-06-08 09:02:41 +02:00
Adrian Artiles
1042e9a93d docs: fix typos (#2136) 2021-06-08 08:57:13 +02:00
Nico Domino
aa57f2dd7e docs(prisma-legacy): update tip location
Move client tip up to client section of docs
2021-06-07 22:44:04 +02:00
Nico Domino
1817286ce3 Update pouchdb.md 2021-06-07 22:21:39 +02:00
Nico Domino
b942dd34f3 docs(pouchdb): add pouchdb page (#2140) 2021-06-07 17:10:42 +02:00
Lluis Agusti
4d9622e1cc chore(git): fix git hooks (#2130)
Contains the following squashed commits:

* chore(git): fix husky pre-commit
* chore(husky): install git hooks on `postinstall`
2021-06-04 12:55:41 +02:00
sanctuxm
a7eadf80e5 docs(provider): fix ngrok typo on instagram provider docs (#2121) 2021-06-03 10:35:07 +02:00
Manish Kumar
75c7dbc3e7 docs(adapter): fix file location in DynamoDB docs (#2120) 2021-06-03 10:11:45 +02:00
Yi-Ru Lin
d36b89cb12 feat(provider): add Zoom provider (#2110)
* feat(provider): add Zoom provider

* Update src/providers/zoom.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update src/providers/zoom.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update www/docs/providers/zoom.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* fix: syntax error

* Update www/docs/providers/zoom.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update www/docs/providers/zoom.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update www/docs/providers/zoom.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* remove the default protection setting of Zoom for now

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-06-03 00:44:22 +02:00
Nico Domino
349cd03fbd docs(adapters): update adapter install instructions to canary branch (#2119) 2021-06-02 23:50:01 +02:00
Lluis Agusti
5cd130669b chore(lint): format files on pre-commit (#2117)
Contains the following squashed commits:

* chore(lint): run prettier on pre-commit
* chore(lint): format files on pre-commit
* chore(npm): update lock file
2021-06-02 13:59:53 +02:00
Lluis Agusti
638233f4a0 docs(readme): update release flow badge 2021-06-01 18:01:22 +02:00
Lluis Agusti
37e175195f chore(github): re-organize workflows (#2109)
Contains:

* chore(github): re-organize workflows
* chore(github): rename workflows structure
2021-06-01 17:52:17 +02:00
Lluis Agusti
e8a9e8aeb6 fix(client): unit tests setup and providers error handling (#1992)
* test(client): initial Jest + RTL setup

* test(client): add tests for `getSession`

* test(client): document expect cases and fix regex

* test(client): small refactors

* chore(npm): re-generate package-lock.json

* test(client): initial test for `signIn`

* test(client): refactor session tests for consistency

* test(client): credentials/email signin scenarios

* test(client): finish sign-in tests

* chore(github): add test to ci

* test(client): refactor and extend use cases

* test(client): sign-out tests

* refactor(client): code review suggestions (1)

* test(client): add few more sign-in/sign-out cases

* test(client): broadcasting session events

* fix(client): handle fetch providers error
2021-06-01 17:12:13 +02:00
Balázs Orbán
1fb308a6f4 docs(adapter): correct npm install script 2021-06-01 00:44:07 +02:00
Paul van Dyk
613c303315 docs: fix spelling in docs (#2105)
`restriected` => `restricted`
2021-05-31 19:22:39 +02:00
Nico Domino
d24fe1cebb docs: add error + warning pages to sidebar (#2100) 2021-05-31 02:14:27 +02:00
Manten
885b02ca95 chore(dev): add property to decrypt JWT (#2095) 2021-05-31 01:07:46 +02:00
Balázs Orbán
f218697fd6 docs(adapter): remove unnecessary section from prisma 2021-05-30 23:22:00 +02:00
Balázs Orbán
dbead0ad85 docs(adapter): fix API mixup in legacy adapter 2021-05-30 23:17:57 +02:00
Nico Domino
704ded5310 docs(prisma): add prisma-legacy separate docs page (#2097) 2021-05-30 21:44:58 +02:00
Manten
25fbcb4648 docs(FAQ): fix typo (#2088) 2021-05-29 16:47:06 +02:00
Nico Domino
53a439b44b docs(firebase): update firebase usage and options (#2076)
* docs(firebase): update firebase usage and options

* docs(firebase): add firebase tips/warnings

Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-05-28 16:05:15 +02:00
Ben Orozco
16a2e37fd6 feat: Allow client to override scope (#2079)
* Ref[Signin]: Allow client to override scope

Allow client to override `scope` via query params

* Doc[Client]: Signin no longer overrides scope server-side
2021-05-28 10:07:42 +02:00
Colby Fayock
0392a8df9a docs(website): add Twitter Provider tutorial 2021-05-26 09:29:08 +02:00
Olav Fosse
a459b95c5b docs(website): fix typo (#2061) 2021-05-25 20:53:37 +02:00
Balázs Orbán
13df7eb81d docs: update urls to .vercel.app (#2039) 2021-05-25 00:35:57 +02:00
Kiran Paul
62f261209c docs(provider): improve authorize code example (#2046)
* Updated user fetch code as per review comments
2021-05-24 16:54:50 +02:00
Nico Domino
da43d0d896 docs(adapters): reorganise adapter docs for new pkg (#2051)
* docs(adapters): reorganise adapter docs for new pkg

* docs(adapters): fix link typos

* docs(adapters): add vercel.json redirects for new adapters URLs
2021-05-23 22:16:14 +02:00
Ben West
4b1271ba75 docs: Remove claim that new users do not have an ID (#1737)
I'm not sure when this changed, but it's no longer true. If the person logging in doesn't have a stored user account, the ID will be the provider_account_id
2021-05-22 13:47:48 +02:00
Marshall Bowers
d30da0170f fix(provider): make WorkOS domain configurable from signIn (#2038)
* Don't pass `domain` to the WorkOS provider

* Update docs

* Change `apiUrl` to `domain`
2021-05-22 13:40:48 +02:00
Nico Domino
887b2985fc docs(adapters): update copy regarding adapters (#2026)
* docs(adapters): update copy regarding adapters

* docs(adapters): add prisma schema page

* docs(adapters): add fauna schema/setup page

* docs(adapters): address PR comments

* Update www/docs/schemas/adapters.md

Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(adapters): update adapters.md

* docs(adapters): update adapters.md

Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-05-22 12:10:26 +02:00
Nico Domino
d2bbac1164 docs: explain where pageProps come from in Provider docs (#2016)
* docs: explain where pageProps come from in Provider docs

* chore: formatting

* docs(getting-started): add alternative client session handling methods

* docs(getting-started): update alternative client api docs
2021-05-22 11:30:38 +02:00
Balázs Orbán
35583a513d fix: ts type, and transpilation (#2037)
* fix(ts): mark getUserByEmail param as nullable

* fix(build): transpile with optional-catch-binding
2021-05-20 20:40:45 +02:00
Nico Domino
665d91019f style: small tweaks to navbar (#2024) 2021-05-20 16:22:31 +02:00
Daniel Sabbagh
f2b816b7b9 docs: fix minor typo (#2022)
* fix minor typo

* fix typo again

Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-05-19 20:59:00 +02:00
Nico Domino
2e770fb0bf docs: update github PR template comments (#2025) 2021-05-19 01:11:42 +02:00
Nico Domino
e83e7231fb docs(search): add new algolia docsearch (#2023)
* docs(search): add new algolia docsearch

* style(search): fix algolia docsearch mobile style
2021-05-18 21:49:43 +02:00
Marco Valsecchi
4593ec8b01 docs(provider): Fix Using a custom OAuth Provider index link (#2019) 2021-05-18 14:30:17 +02:00
Nico Domino
12517f629b docs(style): add github star counter to navbar (#2015)
* docs(style): add github star counter to navbar

* chore: cleanup kFormatter logic
2021-05-18 00:23:44 +02:00
Balázs Orbán
77012bc00c fix(deps): pin down legacy adapter versions (#2009)
* fix(deps): pin down legacy adapter versions

* chore: trigger github actions
2021-05-16 20:52:04 +02:00
Chalk
60fdf26a56 fix(provider): support multiple image formats for Twitter profile (#1995)
see supported formats: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image

Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-05-15 23:28:34 +02:00
Igor Danchenko
0fae0c7a8e feat(provider): forward request to authorize (#1979)
* feat/add-request-to-credentials-authorize

* Update src/server/routes/callback.js

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update types/providers.d.ts

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update www/docs/providers/credentials.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update www/docs

* Update test app

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-05-15 03:00:39 +02:00
Nico Domino
eba79f4445 feat: upgrade docusaurus + style a bit (#1993) 2021-05-13 23:24:02 +02:00
Balázs Orbán
e3bb9881ea chore(dev): fix dev app imports (#1991) 2021-05-13 12:36:28 +02:00
Balázs Orbán
827049cb35 docs(www): Docusaurus webpack 5 (#1989)
This reverts commit bc9805d1ba.
2021-05-13 01:28:36 +02:00
Nico Domino
ad8100d402 docs: max cookie size information (#1949)
* fix: max cookie information

* fix: typo

* fix: wording regarding cookie size

* Update www/docs/faq.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-05-12 10:22:08 +02:00
dependabot[bot]
7b5defff16 chore(deps): bump hosted-git-info from 2.8.8 to 2.8.9 (#1976)
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-05-12 10:20:24 +02:00
Balázs Orbán
bc9805d1ba docs: revert "Docusaurus webpack 5" (#1982)
This reverts commit c823016b36.
2021-05-12 10:19:30 +02:00
Sébastien Lorber
c823016b36 docs(www): update Docusaurus to webpack 5 (#1826)
* upgrade

* upgrade

* fix lunr plugin bug

Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-05-12 10:01:33 +02:00
dependabot[bot]
ca0f4c6fba chore(deps): bump hosted-git-info from 2.8.8 to 2.8.9 in /www (#1977)
Bumps [hosted-git-info](https://github.com/npm/hosted-git-info) from 2.8.8 to 2.8.9.
- [Release notes](https://github.com/npm/hosted-git-info/releases)
- [Changelog](https://github.com/npm/hosted-git-info/blob/v2.8.9/CHANGELOG.md)
- [Commits](https://github.com/npm/hosted-git-info/compare/v2.8.8...v2.8.9)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-11 21:04:27 +02:00
Balázs Orbán
c0d2f2d852 fix(adapter): upgrade legacy adapters (#1952)
* refactor(adapter): upgrade typeorm-legacy-adapter

* fix(ts): correct exported typeorm types

* fix(adapter): correct adapter exports

* chore(deps): upgrade typeorm-legacy-adapter

* chore(deps): upgrade dependencies

* chore: match comment for legacy adapters

* fix(ts): correctly export Prisma legacy types

* chore(deps): upgrade prisma legacy adapter

* chore(deps): remove unused dependencies

* test(ts): only run TS tests on latest TS version

* chore(deps): remove unused dev dependencies

* chore(deps): upgrade prisma adapter
2021-05-11 00:15:01 +02:00
Balázs Orbán
71f63117a9 fix(oauth): correctly set internal protection value (#1962) 2021-05-09 23:00:06 +02:00
i-palindrome-i
d04ce29314 feat(provider): add WorkOS provider (#1939)
* feat(provider): add WorkOS provider

* Update www/docs/providers/workos.md

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* Update workos.md

Co-authored-by: Adam Kaczmarek <adamkaz+workos@gmail.com>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-05-09 21:45:37 +02:00
Lluis Agusti
d2882f1958 fix(deps): unpin react-dom version (#1956) 2021-05-09 21:43:51 +02:00
Lluis Agusti
66db563ca5 docs(provider): link to providers' source code (#1955) 2021-05-09 21:41:28 +02:00
Marcus Reinhardt
9619077363 docs(typeorm): update link to source (#1957) 2021-05-08 23:37:55 +02:00
dependabot[bot]
013ccb4cb0 chore(deps): bump lodash from 4.17.19 to 4.17.21 (#1954)
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.19 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.19...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-08 00:40:35 +02:00
dependabot[bot]
6eb41259d1 chore(deps): bump underscore from 1.10.2 to 1.13.1 (#1951)
Bumps [underscore](https://github.com/jashkenas/underscore) from 1.10.2 to 1.13.1.
- [Release notes](https://github.com/jashkenas/underscore/releases)
- [Commits](https://github.com/jashkenas/underscore/compare/1.10.2...1.13.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-05-07 17:58:22 +02:00
Nico Domino
141f8d07e2 docs(provider): clarify where user is created with email provider (#1950) 2021-05-07 00:54:52 +02:00
Zack Sheppard
ffd0601ab0 fix(ts): improve events handlers' types (#1853)
* Constrain the adapters type generics more accurately

* Add types for the incoming messages to events callbacks

* Code review comments from @lluia

* Rebase from trunk and fix merge conflicts

* Update documentation

* Rip out generics

* fix(build): export aliases from client (#1909)

* docs(provider): update providers documentation (#1900)

* docs(providers): update providers documentation

- delineate clearly the 3 provider types (oauth, email, credentials)
- make each section structure consistent
- update the option list for every provider type
- use emojis

* docs(providers): instructions on new provider types

* docs(providers): remove emojis

To stay consistent with the rest of our documentation, for now we should not emojis on the sections of our documentation pages.

* docs(providers): reword sentence

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* docs(providers): add tip on overriding options

* docs(providers): clarify `params` option usage

* docs(providers): make names list inline

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* fix(ts): unset generics defaults for overriding (#1891)

Co-authored-by: Lluis Agusti <hi@llu.lu>

* fix(ts): tweak Adapter related types (#1914)

Contains the following squashed commits:

* fix(ts): make first adapter parameter non-optional
* fix(ts): make defaulted values non-optional internally
* test(ts): fix linting

* fix(page): don't pass params to custom signout page (#1912)

* For the custom signout page addressed two issues with the query params being added to the signout url. A conditional check on the error value is now made before adding it as a query param. Also added a conditional check on the callbackUrl and if present that then gets appended as a query param to the signout api call.

* Changed fix for bug #192 to have no querystring params in the custom signout page url.

Co-authored-by: anubisoft <anubisoftprez@gmail.com>
Co-authored-by: Lluis Agusti <hi@llu.lu>

* docs(www): fix typo (#1922)

* docs(provider): Update IdentityServer 4 demo configuration (#1932)

* Responding to code review comments

* Fix tests

* Fix lint error

Co-authored-by: Lluis Agusti <hi@llu.lu>
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Kristóf Poduszló <kripod@protonmail.com>
Co-authored-by: Anubisoft <1471887+anubisoft@users.noreply.github.com>
Co-authored-by: anubisoft <anubisoftprez@gmail.com>
Co-authored-by: Ernie Miranda <emiranda04@users.noreply.github.com>
Co-authored-by: Mathis Møller <thisen-dk@hotmail.com>
2021-05-06 11:44:30 +02:00
Lluis Agusti
7864d4705d docs(adapter): mention new types (#1916)
Containts the following squashed commits:

* docs(adapters): mention new types
* docs(adapters): rename interface on example
* docs(adapters): move section above
* docs(adapters): fix casing
* docs(adapters): fix example import
* fix(www): Typescript -> TypeScript
2021-05-06 11:10:37 +02:00
i-palindrome-i
98dc82e5d6 docs: fix command in CONTRIBUTING.md (#1940)
Co-authored-by: Adam Kaczmarek <adamkaz+workos@gmail.com>
2021-05-06 10:19:50 +02:00
Balázs Orbán
86baefdd9d feat(adapter): take away error handling from adapters (#1871) 2021-05-05 19:45:11 +02:00
Manish Chiniwalar
332e237c3e feat(provider): add Dropbox (#1756)
Co-authored-by: Balázs Orbán <info@balazsorban.com>
Co-authored-by: Adam Bergman <adam@fransvilhelm.com>
2021-05-05 19:42:55 +02:00
Mathis Møller
2fce08c0b5 docs(provider): Update IdentityServer 4 demo configuration (#1932) 2021-05-05 15:17:22 +02:00
Ernie Miranda
adf3fb669f docs(www): fix typo (#1922) 2021-05-04 19:34:06 +02:00
Anubisoft
5323be3594 fix(page): don't pass params to custom signout page (#1912)
* For the custom signout page addressed two issues with the query params being added to the signout url. A conditional check on the error value is now made before adding it as a query param. Also added a conditional check on the callbackUrl and if present that then gets appended as a query param to the signout api call.

* Changed fix for bug #192 to have no querystring params in the custom signout page url.

Co-authored-by: anubisoft <anubisoftprez@gmail.com>
Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-05-03 22:43:38 +02:00
Balázs Orbán
6df0d04a1e fix(ts): tweak Adapter related types (#1914)
Contains the following squashed commits:

* fix(ts): make first adapter parameter non-optional
* fix(ts): make defaulted values non-optional internally
* test(ts): fix linting
2021-05-03 21:24:19 +02:00
Balázs Orbán
a388b44d0b Merge branch 'main' into next 2021-05-03 21:11:04 +02:00
Kristóf Poduszló
aa9c1e7c96 fix(ts): unset generics defaults for overriding (#1891)
Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-05-03 14:31:56 +02:00
Lluis Agusti
66473054f5 docs(provider): update providers documentation (#1900)
* docs(providers): update providers documentation

- delineate clearly the 3 provider types (oauth, email, credentials)
- make each section structure consistent
- update the option list for every provider type
- use emojis

* docs(providers): instructions on new provider types

* docs(providers): remove emojis

To stay consistent with the rest of our documentation, for now we should not emojis on the sections of our documentation pages.

* docs(providers): reword sentence

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* docs(providers): add tip on overriding options

* docs(providers): clarify `params` option usage

* docs(providers): make names list inline

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-05-02 22:07:08 +02:00
Balázs Orbán
e8ddbc5c11 fix(build): export aliases from client (#1909) 2021-05-02 12:11:11 +02:00
Ernie Miranda
dfe4620056 docs(www): fix minor typo. (#1902)
Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-05-01 11:09:01 +02:00
leeoocca
848224e2c5 fix(ts): optional variables for custom provider options (#1876)
Contains the following squashed commits:

* fix optional variables for custom provider options
* revert some types for custom provider
* docs: client secret required in provider options
* Revert "docs: client secret required in provider options"
2021-05-01 10:46:04 +02:00
dependabot[bot]
aee376cc57 chore(deps): bump ssri from 6.0.1 to 6.0.2 in /www (#1901)
Bumps [ssri](https://github.com/npm/ssri) from 6.0.1 to 6.0.2.
- [Release notes](https://github.com/npm/ssri/releases)
- [Changelog](https://github.com/npm/ssri/blob/v6.0.2/CHANGELOG.md)
- [Commits](https://github.com/npm/ssri/compare/v6.0.1...v6.0.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-04-30 21:17:23 +02:00
Amir Ali
0d2a81cd39 docs(www): syntax error on JWT_SESSION_ERROR code example (#1899) 2021-04-30 16:51:02 +02:00
Balázs Orbán
61e99c9489 fix(ts): wrap adapter option in ReturnType (#1887)
* fix(ts): wrap adapter option in ReturnType

* test(ts): fix adapter tests
2021-04-29 19:43:34 +02:00
Balázs Orbán
0eb4159737 fix(ts): fix updateSession return type 2021-04-28 22:23:13 +02:00
Balázs Orbán
9f0008375f fix(ts): fix createVerificationRequest type (#1877) 2021-04-28 22:16:09 +02:00
leeoocca
0cf1823e70 docs: fix typos in custom provider page (#1875)
* fix typo on custom provider options table

* fix typo in custom provider code example
2021-04-28 20:49:27 +02:00
Mohamed Ouyizme
7f39669053 feat(provider): add 42 School provider (#1872)
* feat(provider): add 42 School provider

* fix(docs): fix provider import

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* fix(provider): change provider id

Co-authored-by: Balázs Orbán <info@balazsorban.com>

* fix(provider): change provider id

Co-authored-by: Balázs Orbán <info@balazsorban.com>

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-04-28 19:10:05 +02:00
Balázs Orbán
7b82d6e985 fix(ts): typo in Adapter interface 2021-04-28 11:59:34 +02:00
Balázs Orbán
53b0a7aa74 fix(ts): improve adapter TypeScript support (#1870)
* fix(ts): clean up adapter interfaces

* fix(ts): add accessTokenExpires to TokenSet

* docs(adapter): do not recommend getUserByCredentials

* fix(ts): make whole EmailConfig required in AdapterInstance

* fix(ts): fix tests

* refactor(ts): remove legacy adapter types

Co-authored-by: Lluis Agusti <hi@llu.lu>
2021-04-28 11:20:03 +02:00
Lluis Agusti
fbb09303af docs(website): fix layout on small screens (#1869) 2021-04-27 19:30:01 +02:00
Balázs Orbán
ff05ac1e41 feat(adapter): split out adapters (#1862)
* refactor(adapter): remove example adapter

* chore(deps): add legacy adapter dependencies

* refactor(adapter): reference legacy adapters

* chore(deps): upgrade legacy adapters

* test(adapter): remove duplicate tests

* test: remove disfunctional tests

* chore: remove accidentally pushed file

* chore: revert unnecessary file changes
2021-04-27 10:01:11 +02:00
Lluis Agusti
a6f6c1590d chore(github): fix typos on issue templates (#1858)
* chore(github): fix typos on issue templates...

* chore(github): use statements rather than comments

on the PR template

* chore(github): Typescript -> TypeScript

* chore(github): add links to Codesanbox on issue templates

* Apply suggestions from code review

Co-authored-by: Balázs Orbán <info@balazsorban.com>
2021-04-26 16:02:37 +02:00
Lluis Agusti
52c2466b9e chore(github): update PR/issue templates (#1829)
Contains the following squashed commits: 

* chore(github): update PR template
* chore(github): refine PR template again
* chore(github): improve issue templates
* chore(github): fix typos on issue templates
* chore(github): improve "affected issues" section on PR template
* chore(github): link question bug report template
* chore(github): fix typo on issue template
* chore(github): add TypeScript issue template
2021-04-26 11:58:32 +02:00
Balázs Orbán
b6a3a72db4 Merge branch 'main' into next 2021-04-24 23:20:41 +02:00
Balázs Orbán
edcb10a823 Merge branch 'main' into next 2021-04-23 15:43:20 +02:00
Balázs Orbán
2acabe19e0 Merge main into next 2021-04-23 15:28:26 +02:00
Balázs Orbán
a6f5f4c184 fix: use upgraded require optional (#1743)
* chore(deps): switch back to (updated) require_optional

* fix: use @balazsorban/require-optional
2021-04-16 16:05:44 +02:00
Balázs Orbán
9fa93e3b5e fix(build): use optional-require dependency (#1736)
* chore(deps): add optional-require

* refactor: use optional-require
2021-04-16 00:23:29 +02:00
Balázs Orbán
cb4342fdda feat(build): modernize how we bundle next-auth (#1682)
* feat(build): optionally include TypeORM

If the user doesn't use databases,
it shouldn't be necessary to iclude it in the bundle.
This can more than half the package size!

* feat(build): clean up in dependencies

Remove unused dependencies, move optional ones to be optional

* feat(build): add exports field

* fix: use peerDependenciesMeta instead of non-standard peerOptionalDependecns field

* fix: ts-standard string quotes

* fix: ts-standard string quotes

* refactor: use asnyc/await for sendVerificationRequest

* chore(deps): upgrade mongodb, remove require_optional

Co-authored-by: ndom91 <yo@ndo.dev>

BREAKING CHANGE:
`typeorm`, and `nodemailer` are no longer dependencies added by default.
If you need any of them, you will have to install them yourself in your project directory.
TypeOrm is the default adapter, so if you only provide an `adapter` configuration or a `database`, you will need `typeorm`. You could also check out `@next-auth/typeorm-adapter`. In case you are using the Email provider, you will have to install `nodemailer` (or you can use the choice of your library in the `sendVerificationRequest` callback to send out the e-mail.)
2021-04-15 23:40:33 +02:00
Balázs Orbán
5f717b3914 chore: merge main into next 2021-04-12 00:46:27 +02:00
Balázs Orbán
d09a45ec7c chore: merge main into next 2021-03-26 16:23:35 +01:00
Balázs Orbán
930f58eba3 chore: merge main into next 2021-03-08 01:05:54 +01:00
Balázs Orbán
c20b7f2930 feat: use IE11 as client code bundle target (#1402) 2021-03-03 20:25:42 +01:00
Balázs Orbán
e418cddd96 chore: merge main into next 2021-03-03 20:25:42 +01:00
Balázs Orbán
111e7aabdf feat(provider): remove state property
BREAKING CHANGE: adding `state: true` is already redundant
as `protection: "state` is the default value. `state: false`
can be substituted with `protection: "state"`
2021-02-15 21:47:47 +01:00
Balázs Orbán
a113ef6fab feat: encourage returning strings instead of throwing
BREAKING CHANGE: We have supported throwing strings
for redirections, while we were showing a waring.
From now on, it is not possible. The user MUST return a string,
rather than throw it.
2021-02-15 21:47:35 +01:00
857 changed files with 56943 additions and 53946 deletions

3
.github/CODEOWNERS vendored
View File

@@ -1 +1,4 @@
/types/ @balazsorban44 @lluia
/docs/ @balazsorban44 @ndom91
/adapters/ @balazsorban44 @ndom91
/__tests__/ @lluia

1
.github/FUNDING.yml vendored
View File

@@ -1,3 +1,4 @@
# https://docs.github.com/en/github/administering-a-repository/displaying-a-sponsor-button-in-your-repository
open_collective: nextauth
github: [balazsorban44]

View File

@@ -0,0 +1,60 @@
name: Bug report
description: Report an issue so we can improve
labels: [triage]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this issue after reading/searching through the [documentation](https://next-auth.js.org) first!
Is this your first time contributing? Check out this video: https://www.youtube.com/watch?v=cuoNzXFLitc
### Important :exclamation:
_Providing incorrect/insufficient information or skipping steps to reproduce the issue may result in closing the issue or converting to a discussion without further explanation._
If you have a generic question specific to your project, it is best asked in Discussions under the [Questions category](https://github.com/nextauthjs/next-auth/discussions/new?category=Questions)
# Let's wait with this until adoption in other frameworks.
# - type: dropdown
# attributes:
# label: Framework
# description: Which framework(s) is this issue related to?
# multiple: true
# options:
# - "Next.js"
# - "Other"
- type: textarea
attributes:
label: Environment
description: |
Run this command in your project's root folder and paste the result:
```sh
npx envinfo --system --binaries --browsers --npmPackages "next,react,next-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:
required: true
- type: input
attributes:
label: Reproduction URL
description: A URL to a repository/code that clearly reproduces your issue. You can use our [`next-auth-example`](https://github.com/nextauthjs/next-auth-example) template repository to get started more easily, or link to your project if it's public
validations:
required: true
- type: textarea
attributes:
label: Describe the issue
description: Describe us what the issue is and what have you tried so far to fix it. Add any extra useful information in this section. Feel free to use screenshots (but prefer [code blocks](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting) over a picture of your code) or a video explanation.
validations:
required: true
- type: textarea
attributes:
label: How to reproduce
description: Explain with clear steps how to reproduce the issue
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: Explain what should have happened instead of what actually happened
validations:
required: true

View File

@@ -0,0 +1,116 @@
name: Bug report (Provider)
description: Create a provider-specific report
labels: [triage, providers]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this [Provider](https://next-auth.js.org/providers/overview) related issue!
Is this your first time contributing? Check out this video: https://www.youtube.com/watch?v=cuoNzXFLitc
### Important :exclamation:
_Providing incorrect/insufficient information or skipping steps to reproduce the issue may result in closing the issue or converting to a discussion without further explanation._
If you have a generic question specific to your project, it is best asked in Discussions under the [Questions category](https://github.com/nextauthjs/next-auth/discussions/new?category=Questions)
- type: dropdown
attributes:
label: Provider type
description: Provider(s) this issue is related to
multiple: true
options:
- "Credentials"
- "Email"
- "Custom provider"
- "42 School"
- "Apple"
- "Atlassian"
- "Auth0"
- "Authentik"
- "Azure Active Directory"
- "Azure Active Directory B2C"
- "Battlenet"
- "Box"
- "Bungie"
- "Cognito"
- "Coinbase"
- "Discord"
- "Dropbox"
- "EVE Online"
- "Facebook"
- "FACEIT"
- "Foursquare"
- "Freshbooks"
- "FusionAuth"
- "GitHub"
- "GitLab"
- "Google"
- "Identity Server 4"
- "Instagram"
- "Kakao"
- "Keycloak"
- "Line"
- "LinkedIn"
- "Mailchimp"
- "Mail.ru"
- "Medium"
- "Naver"
- "Netlify"
- "Okta"
- "OneLogin"
- "Osso"
- "Osu"
- "Patreon"
- "Pipedrive"
- "Reddit"
- "Salesforce"
- "Slack"
- "Spotify"
- "Strava"
- "Trakt"
- "Twitch"
- "Twitter"
- "Vk"
- "Wordpress"
- "WorkOS"
- "Yandex"
- "Zoho"
- "Zoom"
validations:
required: true
- type: textarea
attributes:
label: Environment
description: |
Run this command in your project's root folder and paste the result:
```sh
npx envinfo --system --binaries --browsers --npmPackages "next,react,next-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:
required: true
- type: input
attributes:
label: Reproduction URL
description: A URL to a repository/code that clearly reproduces your issue. You can use our [`next-auth-example`](https://github.com/nextauthjs/next-auth-example) template repository to get started more easily, or link to your project if it's public
validations:
required: true
- type: textarea
attributes:
label: Describe the issue
description: Describe us what the issue is and what have you tried so far to fix it. Add any extra useful information in this section. Feel free to use screenshots (but prefer [code blocks](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting) over a picture of your code) or a video explanation.
validations:
required: true
- type: textarea
attributes:
label: How to reproduce
description: Explain with clear steps how to reproduce the issue
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: Explain what should have happened instead of what actually happened
validations:
required: true

View File

@@ -0,0 +1,72 @@
name: Bug report (Adapter)
description: Create an adapter-specific report
labels: [triage, adapters]
body:
- type: markdown
attributes:
value: |
Thanks for taking the time to fill out this [Adapter](https://next-auth.js.org/adapters/overview) related issue!
Is this your first time contributing? Check out this video: https://www.youtube.com/watch?v=cuoNzXFLitc
### Important :exclamation:
_Providing incorrect/insufficient information or skipping steps to reproduce the issue may result in closing the issue or converting to a discussion without further explanation._
If you have a generic question specific to your project, it is best asked in Discussions under the [Questions category](https://github.com/nextauthjs/next-auth/discussions/new?category=Questions)
- type: dropdown
attributes:
label: Adapter type
description: Adapter(s) this issue is related to
multiple: true
options:
- "Custom adapter"
- "@next-auth/dgraph-adapter"
- "@next-auth/dynamodb-adapter"
- "@next-auth/fauna-adapter"
- "@next-auth/firebase-adapter"
- "@next-auth/mikro-orm-adapter"
- "@next-auth/mongodb-adapter"
- "@next-auth/neo4j-adapter"
- "@next-auth/pouchdb-adapter"
- "@next-auth/prisma-adapter"
- "@next-auth/sequelize-adapter"
- "@next-auth/typeorm-legacy-adapter"
- "@next-auth/upstash-redis-adapter"
validations:
required: true
- type: textarea
attributes:
label: Environment
description: |
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/*"
```
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:
required: true
- type: input
attributes:
label: Reproduction URL
description: A URL to a repository/code that clearly reproduces your issue. You can use our [`next-auth-example`](https://github.com/nextauthjs/next-auth-example) template repository to get started more easily, or link to your project if it's public
validations:
required: true
- type: textarea
attributes:
label: Describe the issue
description: Describe us what the issue is and what have you tried so far to fix it. Add any extra useful information in this section. Feel free to use screenshots (but prefer [code blocks](https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks#syntax-highlighting) over a picture of your code) or a video explanation.
validations:
required: true
- type: textarea
attributes:
label: How to reproduce
description: Explain with clear steps how to reproduce the issue
validations:
required: true
- type: textarea
attributes:
label: Expected behavior
description: Explain what should have happened instead of what actually happened
validations:
required: true

View File

@@ -0,0 +1,22 @@
name: "Documentation"
description: Request to update or improve NextAuth.js documentation
labels: ["triage", "documentation"]
body:
- type: textarea
attributes:
label: What is the improvement or update you wish to see?
description: "Example: The `next-auth` docs are missing information about X."
validations:
required: true
- type: textarea
attributes:
label: Is there any context that might help us understand?
description: A clear description of any added context that might help us understand.
validations:
required: true
- type: input
attributes:
label: Does the docs page already exist? Please link to it.
description: "Example: https://next-auth.js.org/getting-started/introduction"
validations:
required: false

View File

@@ -0,0 +1,71 @@
name: Feature Request
description: Suggest an idea for NextAuth.js
labels: [triage, enhancement]
# note: markdown sections will NOT appear as part of the issue as per documentation, rather they provide context to the user
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema#markdown
body:
- type: markdown
attributes:
value: |
Thank you very much for reaching out to us regarding the awesome feature that you believe should be included in the NextAuth.js library.
_NOTE: Feature requests are converted to [discussions (Ideas 💡)](https://github.com/nextauthjs/next-auth/discussions/categories/ideas). Make sure your idea hasn't been asked yet, and upvote the existing one before opening a new instead._
### Important :exclamation:
Please proceed by providing the following information:
- type: textarea
id: description
attributes:
label: Description 📓
description: Please provide a more in-depth description of the feature proposed.
validations:
required: true
- type: markdown
attributes:
value: |
Make sure you provide plenty of [links]() to external documentation and inline code examples like so:
```js
function myAwesomeNextAuthFeature() {
return 💚
}
```
Take time thinking about what you want to say and help us understand your proposal making sure that this description contains:
- **purpose of the feature**
- **potential problems**
- **potential alternatives**
- type: textarea
id: reproduction
attributes:
label: How to reproduce ☕️
description: If you have a CodeSandbox playground or some code snippets to help us visualize your idea better, please provide it here.
validations:
required: true
- type: markdown
attributes:
value: |
You can use one of the templates set up on **CodeSandbox** to better illustrate your idea:
- [`next-auth-example`](https://codesandbox.io/s/next-auth-example-1kktb)
- type: dropdown
id: pr
attributes:
label: Contributing 🙌🏽
multiple: false
options:
- "Yes, I am willing to help implement this feature in a PR"
- "No, I am afraid I cannot help regarding this"
validations:
required: true
- type: markdown
attributes:
value: |
It takes a lot of work 🏋🏻‍♀️ maintaining a library like `next-auth`; any contribution is more than welcome 💚

56
.github/ISSUE_TEMPLATE/6_typescript.yml vendored Normal file
View File

@@ -0,0 +1,56 @@
name: TypeScript
description: Ask a question about NextAuth.js TypeScript integration
labels: [question, TypeScript]
assignees: [lluia, balazsorban44]
# note: markdown sections will NOT appear as part of the issue as per documentation, rather they provide context to the user
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema#markdown
body:
- type: textarea
id: question
attributes:
label: Question 💬
description: Please provide an in-depth description of the question you have when using NextAuth.js on a Typescript project or when consuming the built-in types for `next-auth`.
validations:
required: true
- type: markdown
attributes:
value: |
Make sure you [link]() to external documentation if necessary and provide inline code examples like so:
```js
function myAwesomeNextAuthFeature() {
return 💚
}
```
**NOTE:** Questions will be converted to Discussions. You can find them [here](https://github.com/nextauthjs/next-auth/discussions)!
- type: textarea
id: codesandbox
attributes:
label: How to reproduce ☕️
description: Please provide a link to a minimal reproduction or code snippets that represents your question
validations:
required: true
- type: markdown
attributes:
value: |
We encourage you to use the template set-up on **CodeSandbox** as a playground to represent your question or doubt:
- [`next-auth-example`](https://codesandbox.io/s/next-auth-example-1kktb)
- type: dropdown
id: pr
attributes:
label: Contributing 🙌🏽
multiple: false
options:
- "Yes, I am willing to help answer this question in a PR"
- "No, I am afraid I cannot help regarding this"
validations:
required: true
- type: markdown
attributes:
value: |
It takes a lot of work 🏋🏻‍♀️ maintaining a library like `next-auth`; any contribution is more than welcome 💚

60
.github/ISSUE_TEMPLATE/7_question.yml vendored Normal file
View File

@@ -0,0 +1,60 @@
name: Question
description: Ask a question about NextAuth.js or for help using it
labels: [question]
# note: markdown sections will NOT appear as part of the issue as per documentation, rather they provide context to the user
# https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema#markdown
body:
- type: markdown
attributes:
value: |
We are glad that you have a question about this library. Please provide the following information:
- type: textarea
id: question
attributes:
label: Question 💬
description: Please provide an in-depth description of the question you have.
validations:
required: true
- type: markdown
attributes:
value: |
Make sure you [link]() to external documentation if necessary and provide inline code examples like so:
```js
function myAwesomeNextAuthFeature() {
return 💚
}
```
**NOTE:** Questions will be converted to Discussions. You can find them [here](https://github.com/nextauthjs/next-auth/discussions)!
- type: textarea
id: reproduction
attributes:
label: How to reproduce ☕️
description: Please provide a link to a minimal reproduction or code snippets that represents your question
validations:
required: true
- type: markdown
attributes:
value: |
We encourage you to use the template set-up on **CodeSandbox** as a playground to represent your question or doubt:
- [`next-auth-example`](https://codesandbox.io/s/next-auth-example-1kktb)
- type: dropdown
id: pr
attributes:
label: Contributing 🙌🏽
multiple: false
options:
- "Yes, I am willing to help answer this question in a PR"
- "No, I am afraid I cannot help regarding this"
validations:
required: true
- type: markdown
attributes:
value: |
It takes a lot of work 🏋🏻‍♀️ maintaining a library like `next-auth`; any contribution is more than welcome 💚

View File

@@ -1,34 +0,0 @@
---
name: Bug report
about: Report a defect with NextAuth.js
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of the bug in NextAuth.js.
Do not report bugs with your own project here, ask from help by raising a question instead - this helps us a lot with administration overhead.
**Steps to reproduce**
Steps to reproduce the behavior.
Include a link to public repository which can be used to reproduce the behaviour.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots or error logs**
If applicable add screenshots or error logs to help explain the problem.
**Additional context**
Add any other context about the problem here.
**Feedback**
*Documentation refers to searching through [online documentation](https://next-auth.js.org), code comments and issue history. The example project refers to [next-auth-example](https://github.com/iaincollins/next-auth-example).*
* [ ] Found the documentation helpful
* [ ] Found documentation but was incomplete
* [ ] Could not find relevant documentation
* [ ] Found the example project helpful
* [ ] Did not find the example project helpful

View File

@@ -1,26 +0,0 @@
---
name: Feature request
about: Suggest an idea for NextAuth.js
labels: enhancement
assignees: ''
---
**Summary of proposed feature**
A clear and concise description of the feature being proposed.
**Purpose of proposed feature**
A clear and concise description of why this feature is necessary and what problems it solves.
**Detail about proposed feature**
A detailed description of how the proposal might work (if you have one).
**Potential problems**
Describe any potential problems or potential limitations or caveats that might apply to the proposed solution.
**Describe any alternatives you've considered**
A clear and concise description of any alternative options you've considered.
**Additional context**
Any other context, screenshots, etc.
*Please indicate if you are willing and able to help implement the proposed feature.*

View File

@@ -1,25 +0,0 @@
---
name: Question
about: Ask a question about NextAuth.js or for help using it
labels: question
assignees: ''
---
<!-- NOTE: Questions will be converted to Discussions. You can find them at https://github.com/nextauthjs/next-auth/discussions! -->
**Your question**
<!-- A clear and concise question. -->
**What are you trying to do**
<!-- A description of what you are trying to do, for context. -->
**Reproduction**
<!-- If your question is code related, adding a reproduction to your use case can greatly reduce the time it takes us to figure out how to better help you. -->
**Feedback**
*Documentation refers to searching through [online documentation](https://next-auth.js.org), code comments and issue history. The example project refers to [next-auth-example](https://github.com/iaincollins/next-auth-example).*
* [ ] Found the documentation helpful
* [ ] Found documentation but was incomplete
* [ ] Could not find relevant documentation
* [ ] Found the example project helpful
* [ ] Did not find the example project helpful

View File

@@ -16,26 +16,33 @@ merge of your pull request!
<!-- What changes are being made? (What feature/bug is being fixed here?) -->
**What**:
## Reasoning 💡
<!-- Why are these changes necessary? -->
<!-- What changes are being made? What feature/bug is being fixed here? -->
**Why**:
## Checklist 🧢
<!-- How were these changes implemented? -->
<!-- Feel free cross items ( like this `~[] item~` ) if they're irrelevant to your changes.
**How**:
<!-- Have you done all of these things? -->
**Checklist**:
<!-- add "N/A" to the end of each line that's irrelevant to your changes -->
<!-- to check an item, place an "x" in the box like so: "- [x] Documentation" -->
To check an item, place an `x` in the box like so: `- [x] Documentation`. -->
- [ ] Documentation
- [ ] Tests
- [ ] Ready to be merged
<!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
<!-- feel free to add additional comments -->
<!-- In your opinion, is this ready to be merged as soon as it's reviewed? -->
## Affected issues 🎟
<!--
Please [scout and link issues](https://github.com/nextauthjs/next-auth/issues) that might be solved by this PR.
If you write `"Fixes"` or `"Closes"` before the issue link like so:
```
Fixes #359
```
the connected issue will be automatically closed once the PR is merged and hence help with maintenance of the library 😊
-->

37
.github/issue-labeler.yml vendored Normal file
View File

@@ -0,0 +1,37 @@
# https://github.com/github/issue-labeler#basic-examples
dgraph:
- "@next-auth/dgraph-adapter"
dynamodb:
- "@next-auth/dynamodb-adapter"
fauna:
- "@next-auth/fauna-adapter"
firebase:
- "@next-auth/firebase-adapter"
mikro-orm:
- "@next-auth/mikro-orm-adapter"
mongodb:
- "@next-auth/mongodb-adapter"
neo4j:
- "@next-auth/neo4j-adapter"
pouchdb:
- "@next-auth/pouchdb-adapter"
prisma:
- "@next-auth/prisma-adapter"
sequelize:
- "@next-auth/sequelize-adapter"
typeorm-legacy:
- "@next-auth/typeorm-legacy-adapter"
upstash-redis:
- "@next-auth/upstash-redis-adapter"

39
.github/labeler.yml vendored
View File

@@ -1,39 +0,0 @@
test:
- test/**/*
- types/tests/**/*
documentation:
- www/**/*
- ./**/*.md
providers:
- src/providers/**/*
- www/docs/configuration/providers.md
- test/integration/**/*
adapters:
- src/adapters/**/*
- www/docs/schemas/adapters.md
databases:
- www/docs/schemas/*.md
- test/docker/databases/**/*
- www/docs/configuration/databases.md
- test/fixtures/**/*
core:
- src/**/*
style:
- src/css/**/*
client:
- src/client/**/*
- www/docs/getting-started/client.md
pages:
- src/server/pages/**/*
- www/docs/configuration/pages.md
TypeScript:
- types/**/*

68
.github/pr-labeler.yml vendored Normal file
View File

@@ -0,0 +1,68 @@
# https://github.com/actions/labeler#create-githublabeleryml
test:
- test/**/*
- types/tests/**/*
providers:
- packages/next-auth/src/providers/**/*
- test/integration/**/*
adapters:
- packages/next-auth/src/adapters.ts
- packages/*-adapter/**
dgraph:
- packages/adapter-dgraph/**
dynamodb:
- packages/adapter-dynamodb/**
fauna:
- packages/adapter-fauna/**
firebase:
- packages/adapter-firebase/**
mikro-orm:
- packages/adapter-mikro-orm/**
mongodb:
- packages/adapter-mongodb/**
neo4j:
- packages/adapter-neo4j/**
pouchdb:
- packages/adapter-pouchdb/**
prisma:
- packages/adapter-prisma/**
sequelize:
- packages/adapter-sequelize/**
typeorm-legacy:
- packages/adapter-typeorm-legacy/**
upstash-redis:
- packages/adapter-upstash-redis/**
core:
- packages/next-auth/src/**/*
style:
- packages/next-auth/src/css/**/*
client:
- packages/next-auth/src/client/**/*
- packages/next-auth/src/react/**/*
pages:
- packages/next-auth/src/core/pages/**/*
TypeScript:
- packages/next-auth/src/**/types.ts
documentation:
- packages/docs/docs/**/*

25
.github/stale.yml vendored
View File

@@ -1,25 +1,20 @@
# Number of days of inactivity before an issue becomes stale
# https://github.com/probot/stale#usage
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
- priority
- bug
# Label to use when marking an issue as stale
- triage
- accepted
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
Hi there! It looks like this issue hasn't had any activity for a while.
It will be closed if no further activity occurs. If you think your issue
is still relevant, feel free to comment on it to keep it open. (Read more at #912)
Thanks!
# Comment to post when closing a stale issue. Set to `false` to disable
It looks like this issue did not receive any activity for 60 days.
It will be closed in 7 days if no further activity occurs. If you think your issue
is still relevant, commenting will keep it open. Thanks!
closeComment: >
Hi there! It looks like this issue hasn't had any activity for a while.
To keep things tidy, I am going to close this issue for now.
If you think your issue is still relevant, just leave a comment
and I will reopen it. (Read more at #912)
Thanks!
To keep things tidy, we are closing this issue for now.
If you think your issue is still relevant, leave a comment
and we might reopen it. Thanks!

13
.github/sync.yml vendored Normal file
View File

@@ -0,0 +1,13 @@
nextauthjs/next-auth-example:
- source: apps/example-nextjs
dest: .
deleteOrphaned: true
- .github/FUNDING.yml
- LICENSE
nextauthjs/next-auth-gatsby-example:
- source: apps/example-gatsby
dest: .
deleteOrphaned: true
- .github/FUNDING.yml
- LICENSE

8
.github/version-pr/action.yml vendored Normal file
View File

@@ -0,0 +1,8 @@
name: "Determine version"
description: "Determines npm package version based on PR number and commit SHA"
outputs:
version:
description: "npm package version"
runs:
using: "node12"
main: "index.js"

21
.github/version-pr/index.js vendored Normal file
View File

@@ -0,0 +1,21 @@
const fs = require("fs")
const path = require("path")
const core = require("@actions/core")
try {
const packageJSONPath = path.join(
process.cwd(),
"packages/next-auth/package.json"
)
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, "utf8"))
const sha8 = process.env.GITHUB_SHA.substring(0, 8)
const prNumber = process.env.PR_NUMBER
const packageVersion = `0.0.0-pr.${prNumber}.${sha8}`
packageJSON.version = packageVersion
core.setOutput("version", packageVersion)
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON))
} catch (error) {
core.setFailed(error.message)
}

View File

@@ -1,32 +0,0 @@
# Simple check that the build is valid and no linting errors.
# Currently is run as a seperate workflow as it's fast to fail.
name: Lint/Build
on:
push:
branches:
- main
- beta
- next
pull_request:
branches:
- main
- beta
- next
jobs:
lint-and-build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12, 14, 16]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
uses: bahmutov/npm-install@v1
- run: npm run lint
- run: npm run build

View File

@@ -1,67 +1,27 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"
name: Code Analysis
on:
push:
branches: [ main, beta, next ]
branches: [main, beta, next]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
branches: [main]
schedule:
- cron: '43 17 * * 2'
- cron: "43 17 * * 2"
jobs:
analyze:
name: Analyze
name: Verify
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
# Learn more:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
language: ["javascript"]
steps:
- name: Checkout repository
uses: actions/checkout@v2
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
#- run: |
# make bootstrap
# make release
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Checkout repository
uses: actions/checkout@v2
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1

View File

@@ -1,57 +0,0 @@
name: Integration Test
on:
push:
branches:
- main
- beta
- next
pull_request:
jobs:
test:
# Only run tests integration against Pull Requests from branches in
# this repository. We do this as integration tests require access to
# secrets in GitHub and they are not exposed to tests run against
# forks (for security reasons), so integration test against
# Pull Requests from external repos just fail and generate noise.
if: github.event.pull_request.head.repo.full_name == github.repository
# We use self-hosted runners as cloud based runnners (e.g. AWS, GPC)
# fail due to IP Address checks done by providers, which enforce
# CAPTCHA checks on login request from cloud compute IP addresses to
# prevent abuse.
runs-on: self-hosted
# Target time is under 5 minutes to run all tests. If it takes longer than
# 10 minutes should look at running tests in parallel. No individual flow
# should take longer than 5 minutes to build and run.
timeout-minutes: 10
strategy:
matrix:
node-version: [12, 14, 16]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
uses: bahmutov/npm-install@v1
# Run tests (build library, build + start test app in Docker, run tests)
- run: npm test
# TODO Tests should exit out if env vars not set (currently hangs)
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NEXTAUTH_TWITTER_ID: ${{secrets.NEXTAUTH_TWITTER_ID}}
NEXTAUTH_TWITTER_SECRET: ${{secrets.NEXTAUTH_TWITTER_SECRET}}
NEXTAUTH_TWITTER_USERNAME: ${{secrets.NEXTAUTH_TWITTER_USERNAME}}
NEXTAUTH_TWITTER_PASSWORD: ${{secrets.NEXTAUTH_TWITTER_PASSWORD}}
NEXTAUTH_GITHUB_ID: ${{secrets.NEXTAUTH_GITHUB_ID}}
NEXTAUTH_GITHUB_SECRET: ${{secrets.NEXTAUTH_GITHUB_SECRET}}
NEXTAUTH_GITHUB_USERNAME: ${{secrets.NEXTAUTH_GITHUB_USERNAME}}
NEXTAUTH_GITHUB_PASSWORD: ${{secrets.NEXTAUTH_GITHUB_PASSWORD}}

18
.github/workflows/label-issue.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
# https://github.com/github/issue-labeler#create-workflow
name: Label issues
on:
issues:
types: [opened]
jobs:
triage:
name: Triage
runs-on: ubuntu-latest
steps:
- uses: github/issue-labeler@v2.4.1
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: ".github/issue-labeler.yml"
enable-versioned-regex: 0

16
.github/workflows/label-pr.yml vendored Normal file
View File

@@ -0,0 +1,16 @@
# https://github.com/actions/labeler#create-workflow
name: Label Pull Requests
on:
pull_request_target:
jobs:
prs:
name: Triage
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: ".github/pr-labeler.yml"

View File

@@ -1,11 +0,0 @@
name: "Pull Request Labeler"
on:
- pull_request_target
jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@main
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

View File

@@ -1,4 +1,5 @@
name: Release
on:
push:
branches:
@@ -7,20 +8,119 @@ on:
- "next"
- "3.x"
pull_request:
jobs:
release:
name: "Release"
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Init
uses: actions/checkout@v2
- name: Setup Node.js
uses: actions/setup-node@v1
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 14
node-version: 16
cache: "yarn"
- name: Cache Node Modules
id: cache-node
uses: actions/cache@v2
with:
path: "**/node_modules"
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
restore-keys: |
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
- name: Install dependencies
uses: bahmutov/npm-install@v1
- run: npx semantic-release@17
run: yarn --prefer-offline --frozen-lockfile
- name: Build
run: yarn build
- name: Run tests
run: yarn test
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
UPSTASH_REDIS_URL: ${{ secrets.UPSTASH_REDIS_URL }}
UPSTASH_REDIS_KEY: ${{ secrets.UPSTASH_REDIS_KEY }}
# - name: Coverage
# uses: codecov/codecov-action@v1
# with:
# directory: ./coverage
# fail_ci_if_error: false
release-branch:
name: Publish branch
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'push' }}
environment: Production
steps:
- name: Init
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16
cache: "yarn"
- name: Cache Node Modules
id: cache-node
uses: actions/cache@v2
with:
path: "**/node_modules"
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
restore-keys: |
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
- name: Install dependencies
run: yarn --prefer-offline --frozen-lockfile
- name: Publish to npm and GitHub
run: |
git config --global user.email "balazsorban44@users.noreply.github.com"
git config --global user.name "Balázs Orbán"
yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN_PKG: ${{ secrets.NPM_TOKEN_PKG }}
NPM_TOKEN_ORG: ${{ secrets.NPM_TOKEN_ORG }}
release-pr:
name: Publish PR
runs-on: ubuntu-latest
needs: test
if: ${{ github.event_name == 'pull_request' }}
environment: Preview
steps:
- name: Init
uses: actions/checkout@v2
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version: 16
cache: "yarn"
- name: Cache Node Modules
id: cache-node
uses: actions/cache@v2
with:
path: "**/node_modules"
key: cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
restore-keys: |
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-${{ github.run_id }}
cache-node_modules-${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}-
- name: Install dependencies
run: yarn --prefer-offline --frozen-lockfile
- name: Determine version
uses: ./.github/version-pr
id: determine-version
env:
PR_NUMBER: ${{ github.event.number }}
- name: Publish to npm
run: |
cd packages/next-auth
echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" >> .npmrc
npm publish --access public --tag experimental
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Comment version on PR
uses: NejcZdovc/comment-pr@v1
with:
message: "🎉 Experimental release [published on npm](https://www.npmjs.com/package/next-auth/v/${{ env.VERSION }})!\n\n```sh\nnpm i next-auth@${{ env.VERSION }}\n```\n```sh\nyarn add next-auth@${{ env.VERSION }}\n```"
env:
VERSION: ${{ steps.determine-version.outputs.version }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

18
.github/workflows/sync-examples.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
name: Sync Example Repositories
on:
push:
branches:
- main
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2
- 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
with:
GH_PAT: ${{ secrets.SYNC_EXAMPLE_PAT }}
SKIP_PR: true

View File

@@ -1,27 +0,0 @@
name: Types
on:
push:
branches:
- main
- beta
- next
pull_request:
branches:
- main
- beta
- next
jobs:
lint-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install dependencies
uses: bahmutov/npm-install@v1
- name: Check types
run: npm run test:types

66
.gitignore vendored
View File

@@ -1,5 +1,6 @@
# Misc
.DS_Store
.npmrc
.env
.env.local
@@ -10,42 +11,38 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
firebase-debug.log
yarn.lock
# Dependencies
node_modules
# Build dirs
.next
/build
/dist
/www/build
build
dist
# Generated files
.docusaurus
.cache-loader
www/providers.json
src/providers/index.js
/internals
/adapters.d.ts
/adapters.js
/client.d.ts
/client.js
/index.d.ts
/index.js
/jwt.d.ts
/jwt.js
/providers.d.ts
/providers.js
/errors.js
/errors.d.ts
packages/next-auth/providers
packages/next-auth/src/providers/oauth-types.ts
packages/next-auth/client
packages/next-auth/css
packages/next-auth/lib
packages/next-auth/core
packages/next-auth/jwt
packages/next-auth/react
packages/next-auth/adapters.d.ts
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
# Development app
app/next-auth
app/dist/css
app/package-lock.json
app/yarn.lock
apps/dev/src/css
apps/dev/prisma/migrations
# VS
/.vs/slnx.sqlite-journal
@@ -53,9 +50,28 @@ app/yarn.lock
/.vs
.vscode
# Jetbrains
.idea
# GitHub Actions runner
/actions-runner
/_work
# Prisma migrations
/prisma/migrations
# DB
dev.db*
packages/adapter-prisma/prisma/dev.db
packages/adapter-prisma/prisma/migrations
db.sqlite
# Tests
coverage
dynamodblocal-bin
firestore-debug.log
test.schema.gql
# Turborepo
.turbo
# docusaurus
docs/.docusaurus
docs/providers.json

1
.husky/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
_

4
.husky/pre-commit Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
# npx pretty-quick --staged

1
.nvmrc Normal file
View File

@@ -0,0 +1 @@
16

View File

@@ -1,5 +1,5 @@
# CHANGELOG
The changelog is automatically updated using
[semantic-release](https://github.com/semantic-release/semantic-release). You
[scripts/release/index.ts](https://github.com/nextauthjs/next-auth/tree/main/scripts/index.ts). You
can see it on the [releases page](../../releases).

View File

@@ -14,22 +14,22 @@ appearance, race, religion, or sexual identity and orientation.
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or
advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic
address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
@@ -55,11 +55,11 @@ further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting me@iaincollins.com. All complaints will be reviewed and
investigated and will result in a response that is deemed necessary and
appropriate to the circumstances. The project team is obligated to maintain
confidentiality with regard to the reporter of an incident. Further details of
specific enforcement policies may be posted separately.
reported by contacting me@iaincollins.com or info@balazsorban.com and yo@ndo.dev.
All complaints will be reviewed and investigated and will result in a response
that is deemed necessary and appropriate to the circumstances. The project team
is obligated to maintain confidentiality with regard to the reporter of an
incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other

View File

@@ -11,43 +11,53 @@ Please raise any significant new functionality or breaking change an issue for d
## For contributors
Anyone can be a contributor. Either you found a typo, or you have an awesome feature request you could implement, we encourage you to create a Pull Request.
### Pull Requests
* The latest changes are always in `main`, so please make your Pull Request against that branch.
* Pull Requests should be raised for any change
* Pull Requests need approval of a [core contributor](https://next-auth.js.org/contributors#core-team) before merging
* We use ESLint/Prettier for linting/formatting, so please run `npm run lint:fix` before committing to make resolving conflicts easier (VSCode users, check out [this ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and [this Prettier extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) to fix lint and formatting issues in development)
* We encourage you to test your changes, and if you have the opportunity, please make those tests part of the Pull Request
* If you add new functionality, please provide the corresponding documentation as well and make it part of the Pull Request
- The latest changes are always in `main`, so please make your Pull Request against that branch.
- Pull Requests should be raised for any change
- Pull Requests need approval of a [core contributor](https://next-auth.js.org/contributors#core-team) before merging
- We use ESLint/Prettier for linting/formatting, so please run `yarn lint:fix` before committing to make resolving conflicts easier (VSCode users, check out [this ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and [this Prettier extension](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) to fix lint and formatting issues in development)
- We encourage you to test your changes, and if you have the opportunity, please make those tests part of the Pull Request
- If you add new functionality, please provide the corresponding documentation as well and make it part of the Pull Request
### Setting up local environment
A quick guide on how to setup *next-auth* locally to work on it and test out any changes:
A quick guide on how to setup _next-auth_ locally to work on it and test out any changes:
1. Clone the repo:
```sh
git clone git@github.com:nextauthjs/next-auth.git
cd next-auth
```
2. Install packages:
1. Install packages. Developing requires Node.js v16:
```sh
npm i && npm dev:setup
yarn
```
3. Populate `.env.local`:
Copy `app/.env.local.example` to `app/.env.local`, and add your env variables for each provider you want to test.
> NOTE: You can add any environment variables to .env.local that you would like to use in your dev app.
> You can find the next-auth config under`app/pages/api/auth/[...nextauth].js`.
Copy `apps/dev/.env.local.example` to `apps/dev/.env.local`, and add your env variables for each provider you want to test.
1. Start the dev application/server:
```sh
npm run dev
cd apps/dev
cp .env.local.example .env.local
```
Your dev application will be available on ```http://localhost:3000```
> NOTE: You can add any environment variables to .env.local that you would like to use in your dev app.
> You can find the next-auth config under`apps/dev/pages/api/auth/[...nextauth].js`.
4. Start the developer application/server:
```sh
yarn dev:app
```
Your developer application will be available on `http://localhost:3000`
That's it! 🎉
@@ -55,15 +65,16 @@ If you need an example project to link to, you can use [next-auth-example](https
#### Hot reloading
When running `npm run dev`, you start a Next.js dev server on `http://localhost:3000`, which includes hot reloading out of the box. Make changes on any of the files in `src` and see the changes immediately.
When running `yarn dev:app`, you start a Next.js developer server on `http://localhost:3000`, which includes hot reloading out of the box. Make changes on any of the files in `src` and see the changes immediately.
> NOTE: When working on CSS, you will have to manually refresh the page after changes. The reason for this is our pages using CSS are server-side rendered. (Improving this through a PR is very welcome!)
> NOTE: When working on CSS, you will have to manually refresh the page after changes. The reason for this is our pages using CSS are server-side rendered (using API routes). (Improving this through a PR is very welcome!)
> NOTE: The setup is as follows: The development application lives inside the `app` folder, and whenever you make a change to the `src` folder in the root (where next-auth is), it gets copied into `app` every time (gitignored), so Next.js can pick them up and apply hot reloading. This is to avoid some annoying issues with how symlinks are working with different React builds, and also to provide a super-fast feedback loop while developing core features.
#### Providers
If you think your custom provider might be useful to others, we encourage you to open a PR and add it to the built-in list so others can discover it much more easily! You only need to add two changes:
1. Add your config: [`src/providers/{provider}.js`](https://github.com/nextauthjs/next-auth/tree/main/src/providers) (Make sure you use a named default export, like `export default function YourProvider`!)
2. Add provider documentation: [`www/docs/providers/{provider}.md`](https://github.com/nextauthjs/next-auth/tree/main/www/docs/providers)
@@ -73,58 +84,28 @@ You can look at the existing built-in providers for inspiration.
#### Databases
Included is a Docker Compose file that starts up MySQL, PostgreSQL, and MongoDB databases on localhost.
It will use port `3306`, `5432`, and `27017` on localhost respectively; please make sure those ports are not used by other services on localhost.
You can start them with `npm run db:start` and stop them with `npm run db:stop`.
You will need Docker and Docker Compose installed to be able to start / stop the databases.
When stopping the databases, it will reset their contents.
If you would like to contribute to an existing database adapter or help create a new one, head over to the [nextauthjs/adapters](https://www.github.com/nextauthjs/adapters) repository and follow the instructions provided there.
#### Testing
Tests can be run with `npm run test`.
Tests can be run with `yarn test`.
Automated tests are currently crude and limited in functionality, but improvements are in development.
Currently, to run tests you need to first have started local test databases (e.g. using `npm run db:start`).
The databases can take a few seconds to start up, so you might need to give it a minute before running the tests.
## For maintainers
We use [semantic-release](https://github.com/semantic-release/semantic-release) together with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0) to automate releases. This makes the maintainenance process easier and less error-prone to human error. Please study the "Conventional Commits" site to understand how to write a good commit message.
We use [a custom script](https://github.com/nextauthjs/next-auth/tree/main/scripts/index.ts) together with [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0) to automate releases. This makes the maintenance process easier and less error-prone. Please study the "Conventional Commits" site to understand how to write a good commit message.
When accepting Pull Requests, make sure the following:
* Use "Squash and merge"
* Make sure you merge contributor PRs into `main`
* Rewrite the commit message to conform to the `Conventional Commits` style. Check the "Recommended Scopes" section for further advice.
* Optionally link issues the PR will resolve (You can add "close" in front of the issue numbers to close the issues automatically, when the PR is merged. `semantic-release` will also comment back to connected issues and PRs, notifying the users that a feature is added/bug fixed, etc.)
### Recommended Scopes
A typical conventional commit looks like this:
```
type(scope): title
body
```
Scope is the part that will help groupping the different commit types in the release notes.
Some recommened scopes are:
- **provider** - Provider related changes. (eg.: "feat(provider): add X provider", "docs(provider): fix typo in X documentation"
- **adapter** - Adapter related changes. (eg.: "feat(adapter): add X provider", "docs(provider): fix typo in X documentation"
- **db** - Database related changes. (eg.: "feat(db): add X database", "docs(db): fix typo in X documentation"
- **deps** - Adding/removing/updating a dependency (eg.: "chore(deps): add X")
> NOTE: If you are not sure which scope to use, you can simply ignore it. (eg.: "feat: add something"). Adding the correct type already helps a lot when analyzing the commit messages.
- Use "Squash and merge"
- Make sure you merge contributor PRs into `main`
- Rewrite the commit message to conform to the `Conventional Commits` style.
- Using `fix` releases a patch (x.x.1)
- Using `feat` releases a minor (x.1.x)
- Using `feat` when `BREAKING CHANGE` is present in the commit messgae releases a major (1.x.x)
- Optionally link issues the PR will resolve (You can add "close" in front of the issue numbers to close the issues automatically, when the PR is merged. `semantic-release` will also comment back to connected issues and PRs, notifying the users that a feature is added/bug fixed, etc.)
### Skipping a release
Every commit that contains [skip release] or [release skip] in their message will be excluded from the commit analysis and won't participate in the release type determination. This is useful, if the PR being merged should not trigger a new `npm` release.
If a commit contains `[skip release]` in their message will be excluded from the commit analysis and won't participate in the release type determination. This is useful, if the PR being merged should not trigger a new `npm` release.

165
README.md
View File

@@ -1,165 +0,0 @@
<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</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?query=workflow%3ARelease">
<img src="https://github.com/nextauthjs/next-auth/workflows/Release/badge.svg" alt="Release" />
</a>
<a href="https://github.com/nextauthjs/next-auth/actions?query=workflow%3A%22Integration+Test%22">
<img src="https://github.com/nextauthjs/next-auth/workflows/Integration%20Test/badge.svg" alt="Integration Test" />
</a>
<a href="https://bundlephobia.com/result?p=next-auth">
<img src="https://img.shields.io/bundlephobia/minzip/next-auth" alt="Bundle Size"/>
</a>
<a href="https://www.npmtrends.com/next-auth">
<img src="https://img.shields.io/npm/dm/next-auth" 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/next-auth">
<img src="https://img.shields.io/github/v/release/nextauthjs/next-auth?label=latest" alt="Github Stable Release" />
</a>
<img src="https://img.shields.io/github/v/release/nextauthjs/next-auth?include_prereleases&label=prerelease&sort=semver" alt="Github Prelease" />
</p>
</p>
## Overview
NextAuth.js is a complete open source authentication solution for [Next.js](http://nextjs.org/) applications.
It is designed from the ground up to support Next.js and Serverless.
## Getting Started
```
npm install --save next-auth
```
The easiest way to continue getting started, is to follow the [getting started](https://next-auth.js.org/getting-started/example) section in our docs.
We also have a section of [tutorials](https://next-auth.js.org/tutorials) for those looking for more specific examples.
See [next-auth.js.org](https://next-auth.js.org) for more information and documentation.
## Features
### Flexible and easy to use
* Designed to work with any OAuth service, it supports OAuth 1.0, 1.0A and 2.0
* Built-in support for [many popular sign-in services](https://next-auth.js.org/configuration/providers)
* Supports email / passwordless authentication
* Supports stateless authentication with any backend (Active Directory, LDAP, etc)
* Supports both JSON Web Tokens and database sessions
* Designed for Serverless but runs anywhere (AWS Lambda, Docker, Heroku, etc…)
### Own your own data
NextAuth.js can be used with or without a database.
* An open source solution that allows you to keep control of your data
* Supports Bring Your Own Database (BYOD) and can be used with any database
* Built-in support for [MySQL, MariaDB, Postgres, Microsoft SQL Server, MongoDB and SQLite](https://next-auth.js.org/configuration/databases)
* Works great with databases from popular hosting providers
* Can also be used *without a database* (e.g. OAuth + JWT)
### Secure by default
* Promotes the use of passwordless sign in mechanisms
* Designed to be secure by default and encourage best practice for safeguarding user data
* Uses Cross Site Request Forgery Tokens on POST routes (sign in, sign out)
* Default cookie policy aims for the most restrictive policy appropriate for each cookie
* When JSON Web Tokens are enabled, they are signed by default (JWS) with HS512
* Use JWT encryption (JWE) by setting the option `encryption: true` (defaults to A256GCM)
* Auto-generates symmetric signing and encryption keys for developer convenience
* Features tab/window syncing and keepalive messages to support short lived sessions
* Attempts to implement the latest guidance published by [Open Web Application Security Project](https://owasp.org/)
Advanced options allow you to define your own routines to handle controlling what accounts are allowed to sign in, for encoding and decoding JSON Web Tokens and to set custom cookie security policies and session properties, so you can control who is able to sign in and how often sessions have to be re-validated.
### TypeScript
NextAuth.js comes with built-in types. For more information and usage, check out the [TypeScript section](https://next-auth.js.org/getting-started/typescript) in the documentaion.
The package at `@types/next-auth` is now deprecated.
## Example
### Add API Route
```javascript
import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'
export default NextAuth({
providers: [
// OAuth authentication providers
Providers.Apple({
clientId: process.env.APPLE_ID,
clientSecret: process.env.APPLE_SECRET
}),
Providers.Google({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET
}),
// Sign in with passwordless email link
Providers.Email({
server: process.env.MAIL_SERVER,
from: '<no-reply@example.com>'
}),
],
// SQL or MongoDB database (or leave empty)
database: process.env.DATABASE_URL
})
```
### Add React Component
```javascript
import {
useSession, signIn, signOut
} from 'next-auth/client'
export default function Component() {
const [ session, loading ] = useSession()
if(session) {
return <>
Signed in as {session.user.email} <br/>
<button onClick={() => signOut()}>Sign out</button>
</>
}
return <>
Not signed in <br/>
<button onClick={() => signIn()}>Sign in</button>
</>
}
```
## Acknowledgements
[NextAuth.js is made possible thanks to all of its contributors.](https://next-auth.js.org/contributors)
<a href="https://github.com/nextauthjs/next-auth/graphs/contributors">
<img width="500px" src="https://contrib.rocks/image?repo=nextauthjs/next-auth" />
</a>
<div>
<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" />
</a>
</div>
<div>
<p align="left">Thanks to Vercel sponsoring this project by allowing it to be deployed for free for the entire NextAuth.js Team</p>
</div>
## 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/next-auth/blob/canary/CONTRIBUTING.md).
## License
ISC

1
README.md Symbolic link
View File

@@ -0,0 +1 @@
packages/next-auth/README.md

View File

@@ -2,23 +2,23 @@
NextAuth.js practices responsible disclosure.
## Supported Versions
Security updates are only released for the current version.
Old releases are not maintained and do not receive updates.
## Reporting a Vulnerability
We request that you contact us directly to report serious issues that might impact the security of sites using NextAuth.js.
If you contact us regarding a serious issue:
* We will endeavor to get back to you within 72 hours.
* We will aim to publish a fix within 30 days.
* We will disclose the issue (and credit you, with your consent) once a fix to resolve the issue has been released.
* If 90 days has elapsed and we still don't have a fix, we will disclose the issue publically.
- We will endeavor to get back to you within 72 hours.
- We will aim to publish a fix within 30 days.
- We will disclose the issue (and credit you, with your consent) once a fix to resolve the issue has been released.
- If 90 days has elapsed and we still don't have a fix, we will disclose the issue publicly.
Currently, the best way to report an issue is by emailing me@iaincollins.com
The best way to report an issue is by contacting us via email at info@balazsorban.com or me@iaincollins.com and yo@ndo.dev, or raise a public issue requesting someone get in touch with you via whatever means you prefer for more details. (Please do not disclose sensitive details publicly at this stage.)
For less serious issues (e.g. RFC compliance for unsupported flows or potential issues that may cause a problem future or default behaviour / options) it is appropriate to submit these these publically as bug reports or feature requests or to raise a question to open a discussion around them.
> For less serious issues (e.g. RFC compliance for unsupported flows or potential issues that may cause a problem in the future) it is appropriate to submit these these publically as bug reports or feature requests or to raise a question to open a discussion around them.
## Supported Versions
Security updates are only released for the current version.
Old releases are not maintained and do not receive updates.

View File

@@ -1,18 +0,0 @@
import Link from 'next/link'
import styles from './footer.module.css'
import { version } from 'package.json'
export default function Footer () {
return (
<footer className={styles.footer}>
<hr />
<ul className={styles.navItems}>
<li className={styles.navItem}><a href='https://next-auth.js.org'>Documentation</a></li>
<li className={styles.navItem}><a href='https://www.npmjs.com/package/next-auth'>NPM</a></li>
<li className={styles.navItem}><a href='https://github.com/nextauthjs/next-auth-example'>GitHub</a></li>
<li className={styles.navItem}><Link href='/policy'><a>Policy</a></Link></li>
<li className={styles.navItem}><em>{version}</em></li>
</ul>
</footer>
)
}

View File

@@ -1,5 +0,0 @@
{
"compilerOptions": {
"baseUrl": "."
}
}

2
app/next-env.d.ts vendored
View File

@@ -1,2 +0,0 @@
/// <reference types="next" />
/// <reference types="next/types/global" />

View File

@@ -1,19 +0,0 @@
const path = require("path")
module.exports = {
webpack(config) {
config.resolve = {
...config.resolve,
alias: {
...config.resolve.alias,
"next-auth$": path.join(process.cwd(), "next-auth/server"),
"next-auth/client$": path.join(process.cwd(), "next-auth/client"),
"next-auth/jwt$": path.join(process.cwd(), "next-auth/lib/jwt"),
"next-auth/adapters": path.join(process.cwd(), "next-auth/adapters"),
"next-auth/providers": path.join(process.cwd(), "next-auth/providers"),
},
}
return config
},
}

View File

@@ -1,25 +0,0 @@
{
"name": "next-auth-app",
"version": "1.0.0",
"description": "NextAuth.js Developer app",
"private": true,
"scripts": {
"dev": "npm-run-all --parallel copy:app dev:css dev:next",
"dev:next": "next dev",
"copy:app": "cpx \"../src/**/*\" next-auth --watch",
"copy:css": "cpx \"../dist/css/**/*\" dist/css --watch",
"watch:css": "cd .. && npm run watch:css",
"dev:css": "npm-run-all --parallel watch:css copy:css",
"start": "next start"
},
"license": "ISC",
"dependencies": {
"next": "^10.1.3",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"cpx": "^1.5.0",
"npm-run-all": "^4.1.5"
}
}

View File

@@ -1,31 +0,0 @@
import { Provider } from "next-auth/client"
import "./styles.css"
// Use the <Provider> to improve performance and allow components that call
// `useSession()` anywhere in your application to access the `session` object.
export default function App({ Component, pageProps }) {
return (
<Provider
// Provider options are not required but can be useful in situations where
// you have a short session maxAge time. Shown here with default values.
options={{
// Client Max Age controls how often the useSession in the client should
// contact the server to sync the session state. Value in seconds.
// e.g.
// * 0 - Disabled (always use cache value)
// * 60 - Sync session state with server if it's older than 60 seconds
clientMaxAge: 0,
// Keep Alive tells windows / tabs that are signed in to keep sending
// a keep alive request (which extends the current session expiry) to
// prevent sessions in open windows from expiring. Value in seconds.
//
// Note: If a session has expired when keep alive is triggered, all open
// windows / tabs will be updated to reflect the user is signed out.
keepAlive: 0,
}}
session={pageProps.session}
>
<Component {...pageProps} />
</Provider>
)
}

View File

@@ -1,87 +0,0 @@
import NextAuth from 'next-auth'
import Providers from 'next-auth/providers'
// import Adapters from 'next-auth/adapters'
// import { PrismaClient } from '@prisma/client'
// const prisma = new PrismaClient()
export default NextAuth({
// Used to debug https://github.com/nextauthjs/next-auth/issues/1664
// cookies: {
// csrfToken: {
// name: 'next-auth.csrf-token',
// options: {
// httpOnly: true,
// sameSite: 'none',
// path: '/',
// secure: true
// }
// },
// pkceCodeVerifier: {
// name: 'next-auth.pkce.code_verifier',
// options: {
// httpOnly: true,
// sameSite: 'none',
// path: '/',
// secure: true
// }
// }
// },
providers: [
Providers.Email({
server: process.env.EMAIL_SERVER,
from: process.env.EMAIL_FROM
}),
Providers.GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET
}),
Providers.Auth0({
clientId: process.env.AUTH0_ID,
clientSecret: process.env.AUTH0_SECRET,
domain: process.env.AUTH0_DOMAIN,
// Used to debug https://github.com/nextauthjs/next-auth/issues/1664
// protection: ["pkce", "state"],
// authorizationParams: {
// response_mode: 'form_post'
// }
protection: 'pkce'
}),
Providers.Twitter({
clientId: process.env.TWITTER_ID,
clientSecret: process.env.TWITTER_SECRET
}),
Providers.Credentials({
name: 'Credentials',
credentials: {
password: { label: 'Password', type: 'password' }
},
async authorize (credentials) {
if (credentials.password === 'password') {
return {
id: 1,
name: 'Fill Murray',
email: 'bill@fillmurray.com',
image: 'https://www.fillmurray.com/64/64'
}
}
return null
}
})
],
jwt: {
encryption: true,
secret: process.env.SECRET
},
debug: false,
theme: 'auto'
// Default Database Adapter (TypeORM)
// database: process.env.DATABASE_URL
// Prisma Database Adapter
// To configure this app to use the schema in `prisma/schema.prisma` run:
// npx prisma generate
// npx prisma migrate dev
// adapter: Adapters.Prisma.Adapter({ prisma })
})

View File

@@ -1,12 +0,0 @@
// This is an example of to protect an API route
import { getSession } from 'next-auth/client'
export default async (req, res) => {
const session = await getSession({ req })
if (session) {
res.send({ content: 'This is protected content. You can access this content because you are signed in.' })
} else {
res.send({ error: 'You must be sign in to view the protected content on this page.' })
}
}

View File

@@ -1,53 +0,0 @@
// eslint-disable-next-line no-use-before-define
import * as React from 'react'
import { signIn, signOut, useSession } from 'next-auth/client'
import Layout from 'components/layout'
export default function Page () {
const [response, setResponse] = React.useState(null)
const handleLogin = (options) => async () => {
if (options.redirect) {
return signIn('credentials', options)
}
const response = await signIn('credentials', options)
setResponse(response)
}
const handleLogout = (options) => async () => {
if (options.redirect) {
return signOut(options)
}
const response = await signOut(options)
setResponse(response)
}
const [session] = useSession()
if (session) {
return (
<Layout>
<h1>Test different flows for Credentials logout</h1>
<span className='spacing'>Default:</span>
<button onClick={handleLogout({ redirect: true })}>Logout</button><br />
<span className='spacing'>No redirect:</span>
<button onClick={handleLogout({ redirect: false })}>Logout</button><br />
<p>Response:</p>
<pre style={{ background: '#eee', padding: 16 }}>{JSON.stringify(response, null, 2)}</pre>
</Layout>
)
}
return (
<Layout>
<h1>Test different flows for Credentials login</h1>
<span className='spacing'>Default:</span>
<button onClick={handleLogin({ redirect: true, password: 'password' })}>Login</button><br />
<span className='spacing'>No redirect:</span>
<button onClick={handleLogin({ redirect: false, password: 'password' })}>Login</button><br />
<span className='spacing'>No redirect, wrong password:</span>
<button onClick={handleLogin({ redirect: false, password: '' })}>Login</button>
<p>Response:</p>
<pre style={{ background: '#eee', padding: 16 }}>{JSON.stringify(response, null, 2)}</pre>
</Layout>
)
}

View File

@@ -1,67 +0,0 @@
// eslint-disable-next-line no-use-before-define
import * as React from 'react'
import { signIn, signOut, useSession } from 'next-auth/client'
import Layout from 'components/layout'
export default function Page () {
const [response, setResponse] = React.useState(null)
const [email, setEmail] = React.useState('')
const handleChange = (event) => {
setEmail(event.target.value)
}
const handleLogin = (options) => async (event) => {
event.preventDefault()
if (options.redirect) {
return signIn('email', options)
}
const response = await signIn('email', options)
setResponse(response)
}
const handleLogout = (options) => async (event) => {
if (options.redirect) {
return signOut(options)
}
const response = await signOut(options)
setResponse(response)
}
const [session] = useSession()
if (session) {
return (
<Layout>
<h1>Test different flows for Email logout</h1>
<span className='spacing'>Default:</span>
<button onClick={handleLogout({ redirect: true })}>Logout</button><br />
<span className='spacing'>No redirect:</span>
<button onClick={handleLogout({ redirect: false })}>Logout</button><br />
<p>Response:</p>
<pre style={{ background: '#eee', padding: 16 }}>{JSON.stringify(response, null, 2)}</pre>
</Layout>
)
}
return (
<Layout>
<h1>Test different flows for Email login</h1>
<label className='spacing'>
Email address:{' '}
<input type='text' id='email' name='email' value={email} onChange={handleChange} />
</label><br />
<form onSubmit={handleLogin({ redirect: true, email })}>
<span className='spacing'>Default:</span>
<button type='submit'>Sign in with Email</button>
</form>
<form onSubmit={handleLogin({ redirect: false, email })}>
<span className='spacing'>No redirect:</span>
<button type='submit'>Sign in with Email</button>
</form>
<p>Response:</p>
<pre style={{ background: '#eee', padding: 16 }}>{JSON.stringify(response, null, 2)}</pre>
</Layout>
)
}

View File

@@ -1,37 +0,0 @@
// This is an example of how to protect content using server rendering
import { getSession } from 'next-auth/client'
import Layout from '../components/layout'
import AccessDenied from '../components/access-denied'
export default function Page ({ content, session }) {
// If no session exists, display access denied message
if (!session) { return <Layout><AccessDenied /></Layout> }
// If session exists, display content
return (
<Layout>
<h1>Protected Page</h1>
<p><strong>{content}</strong></p>
</Layout>
)
}
export async function getServerSideProps (context) {
const session = await getSession(context)
let content = null
if (session) {
const hostname = process.env.NEXTAUTH_URL || 'http://localhost:3000'
const options = { headers: { cookie: context.req.headers.cookie } }
const res = await fetch(`${hostname}/api/examples/protected`, options)
const json = await res.json()
if (json.content) { content = json.content }
}
return {
props: {
session,
content
}
}
}

View File

@@ -1,33 +0,0 @@
import { useState, useEffect } from 'react'
import { useSession } from 'next-auth/client'
import Layout from '../components/layout'
import AccessDenied from '../components/access-denied'
export default function Page () {
const [session, loading] = useSession()
const [content, setContent] = useState()
// Fetch content from protected route
useEffect(() => {
const fetchData = async () => {
const res = await fetch('/api/examples/protected')
const json = await res.json()
if (json.content) { setContent(json.content) }
}
fetchData()
}, [session])
// When rendering client side don't display anything until loading is complete
if (typeof window !== 'undefined' && loading) return null
// If no session exists, display access denied message
if (!session) { return <Layout><AccessDenied /></Layout> }
// If session exists, display content
return (
<Layout>
<h1>Protected Page</h1>
<p><strong>{content}</strong></p>
</Layout>
)
}

View File

@@ -1,63 +0,0 @@
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Account {
id Int @default(autoincrement()) @id
compoundId String @unique @map(name: "compound_id")
userId Int @map(name: "user_id")
providerType String @map(name: "provider_type")
providerId String @map(name: "provider_id")
providerAccountId String @map(name: "provider_account_id")
refreshToken String? @map(name: "refresh_token")
accessToken String? @map(name: "access_token")
accessTokenExpires DateTime? @map(name: "access_token_expires")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
@@index([providerAccountId], name: "providerAccountId")
@@index([providerId], name: "providerId")
@@index([userId], name: "userId")
@@map(name: "accounts")
}
model Session {
id Int @default(autoincrement()) @id
userId Int @map(name: "user_id")
expires DateTime
sessionToken String @unique @map(name: "session_token")
accessToken String @unique @map(name: "access_token")
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
@@map(name: "sessions")
}
model User {
id Int @default(autoincrement()) @id
name String?
email String? @unique
emailVerified DateTime? @map(name: "email_verified")
image String?
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
@@map(name: "users")
}
model VerificationRequest {
id Int @default(autoincrement()) @id
identifier String
token String @unique
expires DateTime
createdAt DateTime @default(now()) @map(name: "created_at")
updatedAt DateTime @default(now()) @map(name: "updated_at")
@@map(name: "verification_requests")
}

View File

@@ -4,30 +4,49 @@
NEXTAUTH_URL=http://localhost:3000
# You can use `openssl rand -hex 32` or
# https://generate-secret.now.sh/32 to generate a secret.
# https://generate-secret.vercel.app/32 to generate a secret.
# Note: Changing a secret may invalidate existing sessions
# and/or verificaion tokens.
SECRET=
# and/or verification tokens.
NEXTAUTH_SECRET=secret
AUTH0_ID=
AUTH0_DOMAIN=
AUTH0_SECRET=
AUTH0_ISSUER=
KEYCLOAK_ID=
KEYCLOAK_SECRET=
KEYCLOAK_ISSUER=
IDS4_ID=
IDS4_SECRET=
IDS4_ISSUER=
GITHUB_ID=
GITHUB_SECRET=
TWITCH_ID=
TWITCH_SECRET=
TWITTER_ID=
TWITTER_SECRET=
LINE_ID=
LINE_SECRET=
TRAKT_ID=
TRAKT_SECRET=
# Example configuration for a Gmail account (will need SMTP enabled)
EMAIL_SERVER=smtps://user@gmail.com:password@smtp.gmail.com:465
EMAIL_FROM=user@gmail.com
# You can use any of these as the "DATABASE_URL" for
# databases started with Docker using `npm run db:start`.
# Note: If using with Prisma adapter, you need to use a `.env`
# file rather than a `.env.local` file to configure env vars.
# Postgres: DATABASE_URL=postgres://nextauth:password@127.0.0.1:5432/nextauth?synchronize=true
# MySQL: DATABASE_URL=mysql://nextauth:password@127.0.0.1:3306/nextauth?synchronize=true
# MongoDB: DATABASE_URL=mongodb://nextauth:password@127.0.0.1:27017/nextauth?synchronize=true
DATABASE_URL=
DATABASE_URL=
BOXYHQSAML_ISSUER="https://jackson-demo.boxyhq.com"
BOXYHQSAML_ID="tenant=boxyhq.com&product=saml-demo.boxyhq.com"
BOXYHQSAML_SECRET="dummy"

View File

@@ -1,17 +1,18 @@
import { signIn } from 'next-auth/client'
import { signIn } from "next-auth/react"
export default function AccessDenied () {
export default function AccessDenied() {
return (
<>
<h1>Access Denied</h1>
<p>
<a
href='/api/auth/signin'
href="/api/auth/signin"
onClick={(e) => {
e.preventDefault()
signIn()
}}
>You must be signed in to view this page
>
You must be signed in to view this page
</a>
</p>
</>

View File

@@ -0,0 +1,30 @@
import Link from "next/link"
import styles from "./footer.module.css"
import packageJSON from "package.json"
export default function Footer() {
return (
<footer className={styles.footer}>
<hr />
<ul className={styles.navItems}>
<li className={styles.navItem}>
<a href="https://next-auth.js.org">Documentation</a>
</li>
<li className={styles.navItem}>
<a href="https://www.npmjs.com/package/next-auth">NPM</a>
</li>
<li className={styles.navItem}>
<a href="https://github.com/nextauthjs/next-auth-example">GitHub</a>
</li>
<li className={styles.navItem}>
<Link href="/policy">
<a>Policy</a>
</Link>
</li>
<li className={styles.navItem}>
<em>{packageJSON.version}</em>
</li>
</ul>
</footer>
)
}

View File

@@ -0,0 +1,115 @@
import Link from "next/link"
import { signIn, signOut, 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
// component that works on pages which support both client and server side
// rendering, and avoids any flash incorrect content on initial page load.
export default function Header() {
const { data: session, status } = useSession()
return (
<header>
<noscript>
<style>{".nojs-show { opacity: 1; top: 0; }"}</style>
</noscript>
<div className={styles.signedInStatus}>
<p
className={`nojs-show ${
!session && status === "loading" ? styles.loading : styles.loaded
}`}
>
{!session && (
<>
<span className={styles.notSignedInText}>
You are not signed in
</span>
<a
href="/api/auth/signin"
className={styles.buttonPrimary}
onClick={(e) => {
e.preventDefault()
signIn()
}}
>
Sign in
</a>
</>
)}
{session && (
<>
{session.user.image && (
<img src={session.user.image} className={styles.avatar} />
)}
<span className={styles.signedInText}>
<small>Signed in as</small>
<br />
<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()
}}
>
Sign out
</a>
</>
)}
</p>
</div>
<nav>
<ul className={styles.navItems}>
<li className={styles.navItem}>
<Link href="/">
<a>Home</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/client">
<a>Client</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/server">
<a>Server</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/protected">
<a>Protected</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/protected-ssr">
<a>Protected(SSR)</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/api-example">
<a>API</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/credentials">
<a>Credentials</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/email">
<a>Email</a>
</Link>
</li>
<li className={styles.navItem}>
<Link href="/middleware-protected">
<a>Middleware protected</a>
</Link>
</li>
</ul>
</nav>
</header>
)
}

5
apps/dev/next-env.d.ts vendored Normal file
View File

@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.

9
apps/dev/next.config.js Normal file
View File

@@ -0,0 +1,9 @@
/** @type {import("next").NextConfig} */
module.exports = {
webpack(config) {
config.experiments = { ...config.experiments, topLevelAwait: true }
return config
},
typescript: { ignoreBuildErrors: true },
experimental: { externalDir: true },
}

34
apps/dev/package.json Normal file
View File

@@ -0,0 +1,34 @@
{
"name": "next-auth-app",
"version": "1.0.0",
"description": "NextAuth.js Developer app",
"private": true,
"scripts": {
"clean": "rm -rf .next",
"copy:css": "cpx \"../../packages/next-auth/css/**/*\" src/css --watch",
"watch:css": "cd ../../packages/next-auth && npm run watch:css",
"dev": "npm-run-all --parallel dev:next watch:css copy:css",
"dev:next": "npx next dev",
"build": "npx next build",
"start": "next start",
"email": "npx fake-smtp-server",
"start:email": "npm run email"
},
"license": "ISC",
"dependencies": {
"@next-auth/fauna-adapter": "^1.0.1",
"@next-auth/prisma-adapter": "^1.0.1",
"@prisma/client": "^3.10.0",
"fake-smtp-server": "^0.8.0",
"faunadb": "^4.4.1",
"next": "^12.1.0",
"nodemailer": "^6.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"prisma": "^3.10.0"
}
}

10
apps/dev/pages/_app.js Normal file
View File

@@ -0,0 +1,10 @@
import { SessionProvider } from "next-auth/react"
import "./styles.css"
export default function App({ Component, pageProps }) {
return (
<SessionProvider session={pageProps.session}>
<Component {...pageProps} />
</SessionProvider>
)
}

View File

@@ -0,0 +1,218 @@
import NextAuth, { NextAuthOptions } from "next-auth"
// import EmailProvider from "next-auth/providers/email"
import GitHubProvider from "next-auth/providers/github"
import Auth0Provider from "next-auth/providers/auth0"
import KeycloakProvider from "next-auth/providers/keycloak"
import TwitterProvider, {
TwitterLegacy as TwitterLegacyProvider,
} from "next-auth/providers/twitter"
import CredentialsProvider from "next-auth/providers/credentials"
import IDS4Provider from "next-auth/providers/identity-server4"
import Twitch from "next-auth/providers/twitch"
import GoogleProvider from "next-auth/providers/google"
import FacebookProvider from "next-auth/providers/facebook"
import FoursquareProvider from "next-auth/providers/foursquare"
// import FreshbooksProvider from "next-auth/providers/freshbooks"
import GitlabProvider from "next-auth/providers/gitlab"
import InstagramProvider from "next-auth/providers/instagram"
import LineProvider from "next-auth/providers/line"
import LinkedInProvider from "next-auth/providers/linkedin"
import MailchimpProvider from "next-auth/providers/mailchimp"
import DiscordProvider from "next-auth/providers/discord"
import AzureADProvider from "next-auth/providers/azure-ad"
import SpotifyProvider from "next-auth/providers/spotify"
import CognitoProvider from "next-auth/providers/cognito"
import SlackProvider from "next-auth/providers/slack"
import Okta from "next-auth/providers/okta"
import AzureB2C from "next-auth/providers/azure-ad-b2c"
import OsuProvider from "next-auth/providers/osu"
import AppleProvider from "next-auth/providers/apple"
import PatreonProvider from "next-auth/providers/patreon"
import TraktProvider from "next-auth/providers/trakt"
import WorkOSProvider from "next-auth/providers/workos"
import BoxyHQSAMLProvider from "next-auth/providers/boxyhq-saml"
// import { PrismaAdapter } from "@next-auth/prisma-adapter"
// import { PrismaClient } from "@prisma/client"
// const prisma = new PrismaClient()
// const adapter = PrismaAdapter(prisma)
// import { Client as FaunaClient } from "faunadb"
// import { FaunaAdapter } from "@next-auth/fauna-adapter"
// const client = new FaunaClient({
// secret: process.env.FAUNA_SECRET,
// domain: process.env.FAUNA_DOMAIN,
// })
// const adapter = FaunaAdapter(client)
export const authOptions: NextAuthOptions = {
// adapter,
providers: [
// E-mail
// Start fake e-mail server with `npm run start:email`
// EmailProvider({
// server: {
// host: "127.0.0.1",
// auth: null,
// secure: false,
// port: 1025,
// tls: { rejectUnauthorized: false },
// },
// }),
// Credentials
CredentialsProvider({
name: "Credentials",
credentials: {
password: { label: "Password", type: "password" },
},
async authorize(credentials) {
if (credentials.password === "pw") {
return {
name: "Fill Murray",
email: "bill@fillmurray.com",
image: "https://www.fillmurray.com/64/64",
}
}
return null
},
}),
// OAuth 1
// TwitterLegacyProvider({
// clientId: process.env.TWITTER_LEGACY_ID,
// clientSecret: process.env.TWITTER_LEGACY_SECRET,
// }),
// OAuth 2 / OIDC
TwitterProvider({
// Opt-in to the new Twitter API for now. Should be default in the future.
version: "2.0",
clientId: process.env.TWITTER_ID,
clientSecret: process.env.TWITTER_SECRET,
}),
GitHubProvider({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
Auth0Provider({
clientId: process.env.AUTH0_ID,
clientSecret: process.env.AUTH0_SECRET,
issuer: process.env.AUTH0_ISSUER,
}),
KeycloakProvider({
clientId: process.env.KEYCLOAK_ID,
clientSecret: process.env.KEYCLOAK_SECRET,
issuer: process.env.KEYCLOAK_ISSUER,
}),
Twitch({
clientId: process.env.TWITCH_ID,
clientSecret: process.env.TWITCH_SECRET,
}),
GoogleProvider({
clientId: process.env.GOOGLE_ID,
clientSecret: process.env.GOOGLE_SECRET,
}),
FacebookProvider({
clientId: process.env.FACEBOOK_ID,
clientSecret: process.env.FACEBOOK_SECRET,
}),
FoursquareProvider({
clientId: process.env.FOURSQUARE_ID,
clientSecret: process.env.FOURSQUARE_SECRET,
}),
// FreshbooksProvider({
// clientId: process.env.FRESHBOOKS_ID,
// clientSecret: process.env.FRESHBOOKS_SECRET,
// }),
GitlabProvider({
clientId: process.env.GITLAB_ID,
clientSecret: process.env.GITLAB_SECRET,
}),
InstagramProvider({
clientId: process.env.INSTAGRAM_ID,
clientSecret: process.env.INSTAGRAM_SECRET,
}),
LineProvider({
clientId: process.env.LINE_ID,
clientSecret: process.env.LINE_SECRET,
}),
LinkedInProvider({
clientId: process.env.LINKEDIN_ID,
clientSecret: process.env.LINKEDIN_SECRET,
}),
MailchimpProvider({
clientId: process.env.MAILCHIMP_ID,
clientSecret: process.env.MAILCHIMP_SECRET,
}),
IDS4Provider({
clientId: process.env.IDS4_ID,
clientSecret: process.env.IDS4_SECRET,
issuer: process.env.IDS4_ISSUER,
}),
DiscordProvider({
clientId: process.env.DISCORD_ID,
clientSecret: process.env.DISCORD_SECRET,
}),
AzureADProvider({
clientId: process.env.AZURE_AD_CLIENT_ID,
clientSecret: process.env.AZURE_AD_CLIENT_SECRET,
tenantId: process.env.AZURE_AD_TENANT_ID,
profilePhotoSize: 48,
}),
SpotifyProvider({
clientId: process.env.SPOTIFY_ID,
clientSecret: process.env.SPOTIFY_SECRET,
}),
CognitoProvider({
clientId: process.env.COGNITO_ID,
clientSecret: process.env.COGNITO_SECRET,
issuer: process.env.COGNITO_ISSUER,
}),
Okta({
clientId: process.env.OKTA_ID,
clientSecret: process.env.OKTA_SECRET,
issuer: process.env.OKTA_ISSUER,
}),
SlackProvider({
clientId: process.env.SLACK_ID,
clientSecret: process.env.SLACK_SECRET,
}),
AzureB2C({
clientId: process.env.AZURE_B2C_ID,
clientSecret: process.env.AZURE_B2C_SECRET,
tenantId: process.env.AZURE_B2C_TENANT_ID,
primaryUserFlow: process.env.AZURE_B2C_PRIMARY_USER_FLOW,
}),
OsuProvider({
clientId: process.env.OSU_CLIENT_ID,
clientSecret: process.env.OSU_CLIENT_SECRET,
}),
AppleProvider({
clientId: process.env.APPLE_ID,
clientSecret: process.env.APPLE_SECRET,
}),
PatreonProvider({
clientId: process.env.PATREON_ID,
clientSecret: process.env.PATREON_SECRET,
}),
TraktProvider({
clientId: process.env.TRAKT_ID,
clientSecret: process.env.TRAKT_SECRET,
}),
WorkOSProvider({
clientId: process.env.WORKOS_ID,
clientSecret: process.env.WORKOS_SECRET,
}),
BoxyHQSAMLProvider({
issuer: process.env.BOXYHQSAML_ISSUER,
clientId: process.env.BOXYHQSAML_ID,
clientSecret: process.env.BOXYHQSAML_SECRET,
}),
],
debug: true,
theme: {
colorScheme: "auto",
logo: "https://next-auth.js.org/img/logo/logo-sm.png",
brandColor: "#1786fb",
},
}
export default NextAuth(authOptions)

View File

@@ -1,9 +1,7 @@
// This is an example of how to read a JSON Web Token from an API route
import jwt from 'next-auth/jwt'
const secret = process.env.SECRET
import { getToken } from "next-auth/jwt"
export default async (req, res) => {
const token = await jwt.getToken({ req, secret })
const token = await getToken({ req, secret: process.env.SECRET })
res.send(JSON.stringify(token, null, 2))
}

View File

@@ -0,0 +1,17 @@
// This is an example of to protect an API route
import { getSession } from "next-auth/react"
export default async (req, res) => {
const session = await getSession({ req })
if (session) {
res.send({
content:
"This is protected content. You can access this content because you are signed in.",
})
} else {
res.send({
error: "You must be sign in to view the protected content on this page.",
})
}
}

View File

@@ -1,5 +1,5 @@
// This is an example of how to access a session from an API route
import { getSession } from 'next-auth/client'
import { getSession } from "next-auth/react"
export default async (req, res) => {
const session = await getSession({ req })

View File

@@ -0,0 +1,67 @@
// eslint-disable-next-line no-use-before-define
import * as React from "react"
import { signIn, signOut, useSession } from "next-auth/react"
import Layout from "components/layout"
export default function Page() {
const [response, setResponse] = React.useState(null)
const handleLogin = (options) => async () => {
if (options.redirect) {
return signIn("credentials", options)
}
const response = await signIn("credentials", options)
setResponse(response)
}
const handleLogout = (options) => async () => {
if (options.redirect) {
return signOut(options)
}
const response = await signOut(options)
setResponse(response)
}
const { data: session } = useSession()
if (session) {
return (
<Layout>
<h1>Test different flows for Credentials logout</h1>
<span className="spacing">Default:</span>
<button onClick={handleLogout({ redirect: true })}>Logout</button>
<br />
<span className="spacing">No redirect:</span>
<button onClick={handleLogout({ redirect: false })}>Logout</button>
<br />
<p>Response:</p>
<pre style={{ background: "#eee", padding: 16 }}>
{JSON.stringify(response, null, 2)}
</pre>
</Layout>
)
}
return (
<Layout>
<h1>Test different flows for Credentials login</h1>
<span className="spacing">Default:</span>
<button onClick={handleLogin({ redirect: true, password: "password" })}>
Login
</button>
<br />
<span className="spacing">No redirect:</span>
<button onClick={handleLogin({ redirect: false, password: "password" })}>
Login
</button>
<br />
<span className="spacing">No redirect, wrong password:</span>
<button onClick={handleLogin({ redirect: false, password: "" })}>
Login
</button>
<p>Response:</p>
<pre style={{ background: "#eee", padding: 16 }}>
{JSON.stringify(response, null, 2)}
</pre>
</Layout>
)
}

80
apps/dev/pages/email.js Normal file
View File

@@ -0,0 +1,80 @@
// eslint-disable-next-line no-use-before-define
import * as React from "react"
import { signIn, signOut, useSession } from "next-auth/react"
import Layout from "components/layout"
export default function Page() {
const [response, setResponse] = React.useState(null)
const [email, setEmail] = React.useState("")
const handleChange = (event) => {
setEmail(event.target.value)
}
const handleLogin = (options) => async (event) => {
event.preventDefault()
if (options.redirect) {
return signIn("email", options)
}
const response = await signIn("email", options)
setResponse(response)
}
const handleLogout = (options) => async (event) => {
if (options.redirect) {
return signOut(options)
}
const response = await signOut(options)
setResponse(response)
}
const { data: session } = useSession()
if (session) {
return (
<Layout>
<h1>Test different flows for Email logout</h1>
<span className="spacing">Default:</span>
<button onClick={handleLogout({ redirect: true })}>Logout</button>
<br />
<span className="spacing">No redirect:</span>
<button onClick={handleLogout({ redirect: false })}>Logout</button>
<br />
<p>Response:</p>
<pre style={{ background: "#eee", padding: 16 }}>
{JSON.stringify(response, null, 2)}
</pre>
</Layout>
)
}
return (
<Layout>
<h1>Test different flows for Email login</h1>
<label className="spacing">
Email address:{" "}
<input
type="text"
id="email"
name="email"
value={email}
onChange={handleChange}
/>
</label>
<br />
<form onSubmit={handleLogin({ redirect: true, email })}>
<span className="spacing">Default:</span>
<button type="submit">Sign in with Email</button>
</form>
<form onSubmit={handleLogin({ redirect: false, email })}>
<span className="spacing">No redirect:</span>
<button type="submit">Sign in with Email</button>
</form>
<p>Response:</p>
<pre style={{ background: "#eee", padding: 16 }}>
{JSON.stringify(response, null, 2)}
</pre>
</Layout>
)
}

View File

@@ -0,0 +1,44 @@
export { default } from "next-auth/middleware"
// Other ways to use this middleware
// import withAuth from "next-auth/middleware"
// import { withAuth } from "next-auth/middleware"
// export function middleware(req, ev) {
// return withAuth(req)
// }
// export function middleware(req, ev) {
// return withAuth(req, ev)
// }
// export function middleware(req, ev) {
// return withAuth(req, {
// callbacks: {
// authorized: ({ token }) => !!token,
// },
// })
// }
// export default withAuth(function middleware(req, ev) {
// console.log(req.nextauth.token)
// })
// export default withAuth(
// function middleware(req, ev) {
// console.log(req, ev)
// return undefined // NOTE: `NextMiddleware` should allow returning `void`
// },
// {
// callbacks: {
// authorized: ({ token }) => token.name === "Balázs Orbán",
// }
// }
// )
// export default withAuth({
// callbacks: {
// authorized: ({ token }) => !!token,
// },
// })

View File

@@ -0,0 +1,9 @@
import Layout from "components/layout"
export default function Page() {
return (
<Layout>
<h1>Page protected by Middleware</h1>
</Layout>
)
}

View File

@@ -0,0 +1,48 @@
// This is an example of how to protect content using server rendering
import { getServerSession } from "next-auth/next"
import { authOptions } from "./api/auth/[...nextauth]"
import Layout from "../components/layout"
import AccessDenied from "../components/access-denied"
export default function Page({ content, session }) {
// If no session exists, display access denied message
if (!session) {
return (
<Layout>
<AccessDenied />
</Layout>
)
}
// If session exists, display content
return (
<Layout>
<h1>Protected Page</h1>
<p>
<strong>{content}</strong>
</p>
</Layout>
)
}
export async function getServerSideProps(context) {
const session = await getServerSession(context, authOptions)
let content = null
if (session) {
const hostname = process.env.NEXTAUTH_URL || "http://localhost:3000"
const options = { headers: { cookie: context.req.headers.cookie } }
const res = await fetch(`${hostname}/api/examples/protected`, options)
const json = await res.json()
if (json.content) {
content = json.content
}
}
return {
props: {
session,
content,
},
}
}

View File

@@ -0,0 +1,35 @@
import { useState, useEffect } from "react"
import { useSession } from "next-auth/react"
import Layout from "../components/layout"
export default function Page() {
const { status } = useSession({
required: true,
})
const [content, setContent] = useState()
// Fetch content from protected route
useEffect(() => {
if (status === "loading") return
const fetchData = async () => {
const res = await fetch("/api/examples/protected")
const json = await res.json()
if (json.content) {
setContent(json.content)
}
}
fetchData()
}, [status])
if (status === "loading") return <Layout>Loading...</Layout>
// If session exists, display content
return (
<Layout>
<h1>Protected Page</h1>
<p>
<strong>{content}</strong>
</p>
</Layout>
)
}

View File

@@ -1,7 +1,7 @@
import { getSession } from 'next-auth/client'
import Layout from '../components/layout'
import { getSession } from "next-auth/react"
import Layout from "../components/layout"
export default function Page () {
export default function Page() {
// As this page uses Server Side Rendering, the `session` will be already
// populated on render without needing to go through a loading stage.
// This is possible because of the shared context configured in `_app.js` that
@@ -11,27 +11,31 @@ export default function Page () {
<Layout>
<h1>Server Side Rendering</h1>
<p>
This page uses the universal <strong>getSession()</strong> method in <strong>getServerSideProps()</strong>.
This page uses the universal <strong>getSession()</strong> method in{" "}
<strong>getServerSideProps()</strong>.
</p>
<p>
Using <strong>getSession()</strong> in <strong>getServerSideProps()</strong> is the recommended approach if you need to
support Server Side Rendering with authentication.
Using <strong>getSession()</strong> in{" "}
<strong>getServerSideProps()</strong> is the recommended approach if you
need to support Server Side Rendering with authentication.
</p>
<p>
The advantage of Server Side Rendering is this page does not require client side JavaScript.
The advantage of Server Side Rendering is this page does not require
client side JavaScript.
</p>
<p>
The disadvantage of Server Side Rendering is that this page is slower to render.
The disadvantage of Server Side Rendering is that this page is slower to
render.
</p>
</Layout>
)
}
// Export the `session` prop to use sessions with Server Side Rendering
export async function getServerSideProps (context) {
export async function getServerSideProps(context) {
return {
props: {
session: await getSession(context)
}
session: await getSession(context),
},
}
}

View File

@@ -1,10 +1,12 @@
body {
font-family: -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
"Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
"Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
padding: 0 1rem 1rem 1rem;
max-width: 680px;
margin: 0 auto;
background: #fff;
color: #333;
color: var(--color-text);
}
li,

View File

@@ -0,0 +1,57 @@
datasource db {
provider = "sqlite"
url = "file:./dev.db"
}
generator client {
provider = "prisma-client-js"
}
model Account {
id String @id @default(cuid())
userId String
type String
provider String
providerAccountId String
refresh_token String?
access_token String?
expires_at Int?
token_type String?
scope String?
id_token String?
session_state String?
oauth_token_secret String?
oauth_token String?
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
user User @relation(fields: [userId], references: [id])
@@unique([provider, providerAccountId])
}
model Session {
id String @id @default(cuid())
sessionToken String @unique
userId String
expires DateTime
user User @relation(fields: [userId], references: [id])
}
model User {
id String @id @default(cuid())
name String?
email String? @unique
emailVerified DateTime?
image String?
accounts Account[]
sessions Session[]
}
model VerificationToken {
identifier String
token String @unique
expires DateTime
@@unique([identifier, token])
}

25
apps/dev/tsconfig.json Normal file
View File

@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "esnext",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"incremental": true,
"jsx": "preserve",
"baseUrl": ".",
"paths": {
"next-auth": ["../../packages/next-auth/src"],
"next-auth/*": ["../../packages/next-auth/src/*"]
}
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules", "jest.config.js"]
}

View File

@@ -0,0 +1,10 @@
# https://next-auth.js.org/providers/github
GITHUB_ID=
GITHUB_SECRET=
# https://next-auth.js.org/configuration/options#nextauth_url
NEXTAUTH_URL=http://localhost:3000
# https://next-auth.js.org/configuration/options#nextauth_secret
# openssl rand -base64 32
NEXTAUTH_SECRET=

7
apps/example-gatsby/.gitignore vendored Normal file
View File

@@ -0,0 +1,7 @@
node_modules
.env.development
.cache
yarn.lock
.vscode
public
.vercel

View File

@@ -0,0 +1,111 @@
> The example repository is maintained from a [monorepo](https://github.com/nextauthjs/next-auth/tree/main/apps/example-gatsby). 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>
<p align="center">
Open Source. Full Stack. Own Your Data.
</p>
<p align="center" style="align: center;">
<a href="https://npm.im/next-auth">
<img alt="npm" src="https://img.shields.io/npm/v/next-auth?color=green&label=next-auth">
</a>
<a href="https://bundlephobia.com/result?p=next-auth-example">
<img src="https://img.shields.io/bundlephobia/minzip/next-auth?label=next-auth" alt="Bundle Size"/>
</a>
<a href="https://www.npmtrends.com/next-auth">
<img src="https://img.shields.io/npm/dm/next-auth?label=next-auth%20downloads" alt="Downloads" />
</a>
</p>
</p>
## Overview
NextAuth.js is a complete open source authentication solution.
This is an example application that shows how `next-auth` 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.
The deployed version can be found at [`next-auth-gatsby-example.vercel.app`](https://next-auth-gatsby-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), 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 [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
```
git clone https://github.com/nextauthjs/next-auth-gatsby-example.git
cd next-auth-gatsby-example
npm install
```
### 2. Configure your local environment
Copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):
```
cp .env.local.example .env.local
```
Add details for one or more providers (e.g. Google, Twitter, GitHub, Email, etc).
#### Database
A database is needed to persist user accounts and to support email sign in. However, you can still use NextAuth.js for authentication without a database by using OAuth for authentication. If you do not specify a database, [JSON Web Tokens](https://jwt.io/introduction) will be enabled by default.
You **can** skip configuring a database and come back to it later if you want.
For more information about setting up a database, please check out the following links:
* Docs: [next-auth.js.org/adapters/overview](https://next-auth.js.org/adapters/overview)
* Adapters Repo: [nextauthjs/adapters](https://github.com/nextauthjs/adapters)
### 3. Configure Authentication Providers
1. Review and update options in `nextauth.config.js` as needed.
2. When setting up OAuth, in the developer admin page for each of your OAuth services, you should configure the callback URL to use a callback path of `{server}/api/auth/callback/{provider}`.
e.g. For Google OAuth you would use: `http://localhost:3000/api/auth/callback/google`
A list of configured providers and their callback URLs is available from the endpoint `/api/auth/providers`. You can find more information at https://next-auth.js.org/configuration/providers/oauth
3. You can also choose to specify an SMTP server for passwordless sign in via email.
### 4. Start the application
To run your site locally, use:
```
npm run dev
```
To run it in production mode, use:
```
npm run build
npm run start
```
### 5. Preparing for Production
Follow the [Deployment documentation](https://next-auth.js.org/deployment)
## 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" />
</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

View File

@@ -0,0 +1,9 @@
// Gatsby Functions are not yet supported on Vercel, so you'll need to use the root `api` folder.
import NextAuth from "next-auth/next"
import { authConfig } from "../../nextauth.config"
export default async function handler(req, res) {
const { nextauth, provider, ...rest } = req.query
req.query = { nextauth: [nextauth, provider], ...rest }
return await NextAuth(req, res, authConfig)
}

View File

@@ -0,0 +1,2 @@
// Vercel Functions for Gatsby currently do not support catch-all routes.
export { default } from "../[nextauth]"

View File

@@ -0,0 +1,6 @@
import * as React from "react"
import { SessionProvider } from "next-auth/react"
export const wrapRootElement = ({ element }) => (
<SessionProvider>{element}</SessionProvider>
)

View File

@@ -0,0 +1,31 @@
import GitHubProvider from "next-auth/providers/github"
import CredentialsProvider from "next-auth/providers/credentials"
/** @type {import("next-auth").NextAuthOptions} */
export const authConfig = {
providers: [
CredentialsProvider({
credentials: {
Password: { placeholder: `type "password"`, type: "password" },
},
authorize(credentials) {
if (credentials.Password === "password") {
return {
name: "John Doe",
email: "john@doe.com",
image: "https://www.fillmurray.com/200/200",
}
}
},
}),
GitHubProvider({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET,
}),
],
theme: {
logo: "https://www.gatsbyjs.com/Gatsby-Monogram.svg",
colorScheme: "light",
brandColor: "#663399",
},
}

View File

@@ -0,0 +1,22 @@
{
"name": "next-auth-gatsby",
"private": true,
"scripts": {
"build": "gatsby build",
"dev": "gatsby develop --port 3000",
"dev:local": "vercel dev",
"start": "npm run develop",
"serve": "gatsby serve",
"clean": "gatsby clean"
},
"dependencies": {
"dotenv": "^16.0.0",
"gatsby": "next",
"next-auth": "^4.2.1",
"react": "^17.0.2",
"react-dom": "^17.0.2"
},
"devDependencies": {
"vercel": "^23.1.2"
}
}

View File

@@ -0,0 +1,9 @@
// If your deployment environment supports Gatsby Functions, you won't need the root `api` folder, only this.
import NextAuth from "next-auth/next"
import { authConfig } from "../../nextauth.config"
export default async function handler(req, res) {
req.query.nextauth = req.params.nextauth.split("/")
return await NextAuth(req, res, authConfig)
}

View File

@@ -0,0 +1,70 @@
import * as React from "react"
import * as styles from "./layout.module.css"
import { signIn, signOut, useSession } from "next-auth/react"
export default function Layout({ children }) {
const session = useSession()
return (
<div className={styles.wrapper}>
<header>
<div className={styles.signedInStatus}>
<p
className={`nojs-show ${
session?.status === "loading" ? styles.loading : styles.loaded
}`}
>
{session?.status !== "authenticated" && (
<>
<span className={styles.notSignedInText}>
You are not signed in
</span>
<a
href="/api/auth/signin"
className={styles.buttonPrimary}
onClick={(e) => {
e.preventDefault()
signIn()
}}
>
Sign in
</a>
</>
)}
{session?.status === "authenticated" && (
<>
{session.data.user.image && (
<img
alt={`${session.data.user.name}'s avatar`}
src={session.data.user.image}
className={styles.avatar}
/>
)}
<span className={styles.signedInText}>
<small>Signed in as</small>
<br />
<strong>{session.data.user.email} </strong>
{session.data.user.name
? `(${session.data.user.name})`
: null}
</span>
<a
href="/api/auth/signout"
className={styles.button}
onClick={(e) => {
e.preventDefault()
signOut()
}}
>
Sign out
</a>
</>
)}
</p>
</div>
</header>
<main>{children}</main>
</div>
)
}

View File

@@ -0,0 +1,101 @@
body {
margin: 0;
}
.wrapper {
max-width: 640px;
margin: 0 auto;
font-family: sans-serif;
}
/* Set min-height to avoid page reflow while session loading */
.signedInStatus {
display: block;
min-height: 4rem;
width: 100%;
}
.loading,
.loaded {
position: relative;
top: 0;
opacity: 1;
overflow: hidden;
border-radius: 0 0 0.6rem 0.6rem;
padding: 0.6rem 1rem;
margin: 0;
background-color: rgba(0, 0, 0, 0.05);
transition: all 0.2s ease-in;
}
.loading {
top: -2rem;
opacity: 0;
}
.signedInText,
.notSignedInText {
position: absolute;
padding-top: 0.8rem;
left: 1rem;
right: 6.5rem;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
display: inherit;
z-index: 1;
line-height: 1.3rem;
}
.signedInText {
padding-top: 0rem;
left: 4.6rem;
}
.avatar {
border-radius: 2rem;
float: left;
height: 2.8rem;
width: 2.8rem;
background-color: white;
background-size: cover;
background-repeat: no-repeat;
}
.button,
.buttonPrimary {
float: right;
margin-right: -0.4rem;
font-weight: 500;
border-radius: 0.3rem;
cursor: pointer;
font-size: 1rem;
line-height: 1.4rem;
padding: 0.7rem 0.8rem;
position: relative;
z-index: 10;
background-color: transparent;
color: #555;
}
.buttonPrimary {
background-color: #663399;
border-color: #663399;
color: #fff;
text-decoration: none;
padding: 0.7rem 1.4rem;
}
.buttonPrimary:hover {
box-shadow: inset 0 0 5rem rgba(0, 0, 0, 0.2);
}
.navItems {
margin-bottom: 2rem;
padding: 0;
list-style: none;
}
.navItem {
display: inline-block;
margin-right: 1rem;
}

View File

@@ -0,0 +1,26 @@
import * as React from "react"
import Layout from "../components/layout"
import { useSession } from "next-auth/react"
export default function Home() {
const session = useSession()
return (
<Layout>
<h1>NextAuth.js Example</h1>
<p>
An example site to demonstrate how to use{" "}
<a href="https://next-auth.js.org">NextAuth.js</a> for authentication in
Gatsby.
</p>
{
{
loading: <p>Loading session...</p>,
authenticated: <pre>{JSON.stringify(session?.data, null, 2)}</pre>,
unauthenticated: "Please sign in",
}[session?.status ?? "loading"]
}
</Layout>
)
}

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -0,0 +1,28 @@
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET= # Linux: `openssl rand -hex 32` or go to https://generate-secret.now.sh/32
APPLE_ID=
APPLE_TEAM_ID=
APPLE_PRIVATE_KEY=
APPLE_KEY_ID=
AUTH0_ID=
AUTH0_SECRET=
AUTH0_ISSUER=
FACEBOOK_ID=
FACEBOOK_SECRET=
GITHUB_ID=
GITHUB_SECRET=
GOOGLE_ID=
GOOGLE_SECRET=
TWITTER_ID=
TWITTER_SECRET=
EMAIL_SERVER=smtp://username:password@smtp.example.com:587
EMAIL_FROM=NextAuth <noreply@example.com>
DATABASE_URL=sqlite://localhost/:memory:?synchronize=true

110
apps/example-nextjs/.gitignore vendored Normal file
View File

@@ -0,0 +1,110 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
.vercel
.now
.env.local
.DS_Store

View File

@@ -0,0 +1,114 @@
> 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).
<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>
<p align="center">
Open Source. Full Stack. Own Your Data.
</p>
<p align="center" style="align: center;">
<a href="https://npm.im/next-auth">
<img alt="npm" src="https://img.shields.io/npm/v/next-auth?color=green&label=next-auth">
</a>
<a href="https://bundlephobia.com/result?p=next-auth-example">
<img src="https://img.shields.io/bundlephobia/minzip/next-auth?label=next-auth" alt="Bundle Size"/>
</a>
<a href="https://www.npmtrends.com/next-auth">
<img src="https://img.shields.io/npm/dm/next-auth?label=next-auth%20downloads" alt="Downloads" />
</a>
<a href="https://npm.im/next-auth">
<img src="https://img.shields.io/badge/npm-TypeScript-blue" alt="TypeScript" />
</a>
</p>
</p>
## Overview
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
```
git clone https://github.com/nextauthjs/next-auth-example.git
cd next-auth-example
npm install
```
### 2. Configure your local environment
Copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):
```
cp .env.local.example .env.local
```
Add details for one or more providers (e.g. Google, Twitter, GitHub, Email, etc).
#### Database
A database is needed to persist user accounts and to support email sign in. However, you can still use NextAuth.js for authentication without a database by using OAuth for authentication. If you do not specify a database, [JSON Web Tokens](https://jwt.io/introduction) will be enabled by default.
You **can** skip configuring a database and come back to it later if you want.
For more information about setting up a database, please check out the following links:
* Docs: [next-auth.js.org/adapters/overview](https://next-auth.js.org/adapters/overview)
* Adapters Repo: [nextauthjs/adapters](https://github.com/nextauthjs/adapters)
### 3. Configure Authentication Providers
1. Review and update options in `pages/api/auth/[...nextauth].js` as needed.
2. When setting up OAuth, in the developer admin page for each of your OAuth services, you should configure the callback URL to use a callback path of `{server}/api/auth/callback/{provider}`.
e.g. For Google OAuth you would use: `http://localhost:3000/api/auth/callback/google`
A list of configured providers and their callback URLs is available from the endpoint `/api/auth/providers`. You can find more information at https://next-auth.js.org/configuration/providers/oauth
3. You can also choose to specify an SMTP server for passwordless sign in via email.
### 4. Start the application
To run your site locally, use:
```
npm run dev
```
To run it in production mode, use:
```
npm run build
npm run start
```
### 5. Preparing for Production
Follow the [Deployment documentation](https://next-auth.js.org/deployment)
## 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" />
</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

View File

@@ -0,0 +1,20 @@
import { signIn } from "next-auth/react"
export default function AccessDenied() {
return (
<>
<h1>Access Denied</h1>
<p>
<a
href="/api/auth/signin"
onClick={(e) => {
e.preventDefault()
signIn()
}}
>
You must be signed in to view this page
</a>
</p>
</>
)
}

View File

@@ -0,0 +1,14 @@
.footer {
margin-top: 2rem;
}
.navItems {
margin-bottom: 1rem;
padding: 0;
list-style: none;
}
.navItem {
display: inline-block;
margin-right: 1rem;
}

Some files were not shown because too many files have changed in this diff Show More