- User.sessionVersion + jwt-callback revalidation rejects deleted-user,
cross-database, and stale-version tokens (fixes cross-worktree stay-logged-in)
- POST /api/auth/revoke ("sign out everywhere") bumps sessionVersion
- proxy: deny-by-default /api with public allowlist + CORS preflight passthrough;
anchored static-asset allowlist closes the path.includes(".") bypass
- harden session cookie options (httpOnly/sameSite/secure) and cut maxAge to 7 days
- unify https/secure-context detection in isHttpsDeployment() so the cookie
writer (auth) and edge reader (proxy) never disagree on the __Secure- prefix
- augment next-auth User/Session/JWT types
Verified: 1009/1009 tests, build exit 0, live HTTP reproduction of all gates.
125 lines
3.3 KiB
Plaintext
125 lines
3.3 KiB
Plaintext
generator client {
|
|
provider = "prisma-client-js"
|
|
output = "../src/generated/prisma"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
tenantId String?
|
|
email String
|
|
name String
|
|
hashedPassword String
|
|
role String @default("user")
|
|
// Bumping this invalidates all of the user's existing JWT sessions.
|
|
// The JWT embeds the value at sign-in; the auth jwt callback rejects any
|
|
// token whose value no longer matches the DB (logout-everywhere / revoke).
|
|
sessionVersion Int @default(0)
|
|
createdAt DateTime @default(now())
|
|
favorites Favorite[]
|
|
memberships WorkspaceMember[]
|
|
apiKeys UserApiKey[]
|
|
|
|
@@unique([tenantId, email])
|
|
@@map("users")
|
|
}
|
|
|
|
model Favorite {
|
|
id String @id @default(uuid())
|
|
tenantId String?
|
|
entityId String
|
|
pluginId String
|
|
label String
|
|
pluginName String
|
|
lastSeen DateTime @default(now())
|
|
userId String
|
|
notes String?
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, entityId])
|
|
@@map("favorites")
|
|
}
|
|
|
|
model InstalledPlugin {
|
|
id String @id @default(uuid())
|
|
tenantId String?
|
|
pluginId String
|
|
version String
|
|
config String @default("{}")
|
|
enabled Boolean @default(true)
|
|
installedAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([tenantId, pluginId])
|
|
@@map("installed_plugins")
|
|
}
|
|
|
|
model Setting {
|
|
id String @id @default(uuid())
|
|
tenantId String?
|
|
key String
|
|
value String
|
|
|
|
@@unique([tenantId, key])
|
|
@@map("settings")
|
|
}
|
|
|
|
model Workspace {
|
|
id String @id @default(uuid())
|
|
name String
|
|
subdomain String @unique
|
|
status String @default("trialing")
|
|
plan String @default("basic")
|
|
stripeCustomerId String?
|
|
stripeSubscriptionId String?
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
members WorkspaceMember[]
|
|
|
|
@@map("workspaces")
|
|
}
|
|
|
|
model WorkspaceMember {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
workspaceId String
|
|
role String @default("member")
|
|
joinedAt DateTime @default(now())
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
workspace Workspace @relation(fields: [workspaceId], references: [id], onDelete: Cascade)
|
|
|
|
@@unique([userId, workspaceId])
|
|
@@map("workspace_members")
|
|
}
|
|
|
|
model MarketplaceCredential {
|
|
id String @id @default(uuid())
|
|
tenantId String?
|
|
version String
|
|
salt String
|
|
nonce String
|
|
ciphertext String
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
@@unique([tenantId])
|
|
@@map("marketplace_credentials")
|
|
}
|
|
|
|
model UserApiKey {
|
|
id String @id @default(uuid())
|
|
userId String
|
|
tenantId String?
|
|
prefix String @unique
|
|
hashedSecret String
|
|
name String
|
|
createdAt DateTime @default(now())
|
|
lastUsedAt DateTime?
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
|
|
@@map("user_api_keys")
|
|
}
|