Fix: Configure passkey RPID and origin
Set `rpID` and `rpName` for passkey authentication. This is crucial for WebAuthn to correctly identify the relying party and establish secure credentials. Additionally, set the `origin` to ensure consistent communication between the client and server during passkey operations.
This commit is contained in:
parent
f24779f26a
commit
a59c092172
1 changed files with 8 additions and 2 deletions
|
|
@ -1,8 +1,9 @@
|
||||||
import { betterAuth } from 'better-auth';
|
import { betterAuth } from 'better-auth';
|
||||||
import { organization, magicLink } from 'better-auth/plugins';
|
import { organization, magicLink } from 'better-auth/plugins';
|
||||||
import { passkey } from '@better-auth/passkey'; // separate package!
|
import { passkey } from '@better-auth/passkey';
|
||||||
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
|
import { drizzleAdapter } from 'better-auth/adapters/drizzle';
|
||||||
import { db } from '@/db';
|
import { db } from '@/db';
|
||||||
|
import * as schema from '@/db/schema';
|
||||||
|
|
||||||
const baseURL = process.env.BETTER_AUTH_URL || 'http://localhost:3001';
|
const baseURL = process.env.BETTER_AUTH_URL || 'http://localhost:3001';
|
||||||
|
|
||||||
|
|
@ -10,13 +11,18 @@ export const auth = betterAuth({
|
||||||
baseURL,
|
baseURL,
|
||||||
database: drizzleAdapter(db, {
|
database: drizzleAdapter(db, {
|
||||||
provider: 'pg',
|
provider: 'pg',
|
||||||
|
schema,
|
||||||
}),
|
}),
|
||||||
emailAndPassword: {
|
emailAndPassword: {
|
||||||
enabled: true,
|
enabled: true,
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
organization(),
|
organization(),
|
||||||
passkey(),
|
passkey({
|
||||||
|
rpID: new URL(baseURL).hostname,
|
||||||
|
rpName: 'Bagsy',
|
||||||
|
origin: baseURL,
|
||||||
|
}),
|
||||||
magicLink({
|
magicLink({
|
||||||
sendMagicLink: async ({ email, url }) => {
|
sendMagicLink: async ({ email, url }) => {
|
||||||
console.log(`Magic link for ${email}: ${url}`);
|
console.log(`Magic link for ${email}: ${url}`);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue