Skip to content

Commit

Permalink
Updated docs with new authenticators table
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonw4331 committed Jun 28, 2024
1 parent fe9499d commit 6d2949d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/pages/getting-started/adapters/supabase.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,36 @@ CREATE TABLE IF NOT EXISTS next_auth.verification_tokens

GRANT ALL ON TABLE next_auth.verification_tokens TO postgres;
GRANT ALL ON TABLE next_auth.verification_tokens TO service_role;

--
-- Create authenticators table
-- Optional for WebAuthn support
--
CREATE TABLE IF NOT EXISTS next_auth.authenticators
(
"credentialID" text NOT NULL,
"credentialPublicKey" text NOT NULL,
"userId" uuid,
provider text DEFAULT 'webauthn',
"providerAccountId" text,
counter bigint,
"credentialDeviceType" text,
"credentialBackedUp" boolean,
transports text,
CONSTRAINT authenticators_userId_credentialID_pkey PRIMARY KEY ("userId", "credentialID"),
CONSTRAINT "credentialID_unique" UNIQUE ("credentialID"),
CONSTRAINT "authenticators_userId_fkey" FOREIGN KEY ("userId")
REFERENCES next_auth.users (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE,
CONSTRAINT "authenticators_provider_providerAccountId_fkey" FOREIGN KEY (provider, "providerAccountId")
REFERENCES next_auth.accounts (provider, "providerAccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
);

GRANT ALL ON TABLE next_auth.authenticators TO postgres;
GRANT ALL ON TABLE next_auth.authenticators TO service_role;
```

### Expose the NextAuth schema in Supabase
Expand Down
32 changes: 32 additions & 0 deletions docs/pages/getting-started/providers/passkey.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Passkeys are currently supported in the following adapters / framework packages.
| `@auth/prisma-adapter` | `1.3.3` | [Docs](/getting-started/adapters/prisma) |
| `@auth/unstorage-adapter` | `2.1.0` | [Docs](/getting-started/adapters/unstorage) |
| `@auth/drizzle-adapter` | `1.1.1` | [Docs](/getting-started/adapters/drizzle) |
| `@auth/supabase-adapter` | `1.2.1` | [Docs](/getting-started/adapters/supabase) |

<Steps>
### Install peer dependencies
Expand Down Expand Up @@ -111,6 +112,37 @@ model Authenticator {
```

</Accordion>
<Accordion title="Supabase Migration">

```sql filename="./migration/20240205045487_create_authenticators_schema.sql"
-- CreateTable
CREATE TABLE IF NOT EXISTS next_auth.authenticators
(
"credentialID" text NOT NULL,
"credentialPublicKey" text NOT NULL,
"userId" uuid,
provider text DEFAULT 'webauthn',
"providerAccountId" text,
counter bigint,
"credentialDeviceType" text,
"credentialBackedUp" boolean,
transports text,
CONSTRAINT authenticators_userId_credentialID_pkey PRIMARY KEY ("userId", "credentialID"),
CONSTRAINT "credentialID_unique" UNIQUE ("credentialID"),
CONSTRAINT "authenticators_userId_fkey" FOREIGN KEY ("userId")
REFERENCES next_auth.users (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE,
CONSTRAINT "authenticators_provider_providerAccountId_fkey" FOREIGN KEY (provider, "providerAccountId")
REFERENCES next_auth.accounts (provider, "providerAccountId") MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE CASCADE
);

GRANT ALL ON TABLE next_auth.authenticators TO postgres;
GRANT ALL ON TABLE next_auth.authenticators TO service_role;
```
</Accordion>
<Accordion title="SQL Migration">

This migration works for **PostgreSQL** and **SQLite**.
Expand Down

0 comments on commit 6d2949d

Please sign in to comment.