pull/715/head
Travis Fischer 2025-05-23 14:46:39 +07:00
rodzic af9e4411e9
commit 5b23dd92ed
3 zmienionych plików z 20 dodań i 3 usunięć

Wyświetl plik

@ -3,7 +3,7 @@ import { betterAuth } from 'better-auth'
import { drizzleAdapter } from 'better-auth/adapters/drizzle'
import { username } from 'better-auth/plugins'
import { createIdForModel, db } from '@/db'
import { createIdForModel, db, type ModelType } from '@/db'
import { env } from './env'
@ -13,7 +13,10 @@ export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: 'pg'
}),
trustedOrigins: ['http://localhost:6013'],
trustedOrigins: [
// Used for an oauth redirect when authenticating via the CLI
'http://localhost:6013'
],
emailAndPassword: {
enabled: true
},
@ -61,7 +64,7 @@ export const auth = betterAuth({
},
advanced: {
database: {
generateId: ({ model }) => createIdForModel(model as any)
generateId: ({ model }) => createIdForModel(model as ModelType)
}
},
plugins: [

Wyświetl plik

@ -21,6 +21,12 @@ export async function authWithGitHub({
const port = await getPort({ port: preferredPort })
const app = new Hono()
if (port !== preferredPort) {
throw new Error(
`Port ${preferredPort} is required to authenticate with GitHub, but it is already in use.`
)
}
let _resolveAuth: any
let _rejectAuth: any
@ -66,6 +72,7 @@ export async function authWithGitHub({
const res = await client.authClient.signIn.social({
provider: 'github',
// TODO: add error url as well
callbackURL: `http://localhost:${port}/callback/github/success`
})
assert(

Wyświetl plik

@ -17,6 +17,13 @@
- decide on approach for auth
- built-in, first-party, tight coupling
- https://www.better-auth.com
- issues
- doesn't allow dynamic social provider config
- awkward schema cli generation and constraints
- awkward cookie-only session support (need JWTs for CLI and SDK)
- client uses dynamic proxy for methods which makes DX awkward
- should be able to use custom `ky`-based client
- drizzle pg adapter requires `Date` timestamps instead of default strings
- https://github.com/toolbeam/openauth
- https://github.com/aipotheosis-labs/aci/tree/main/backend/apps
- https://github.com/NangoHQ/nango