Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Merge branch 'main' into kiran/eng-140-integrations-dub-oauth

Kiran K203b06caa71d
diff --cc apps/web/prisma/schema.prisma
index 3f465950e8,9bb76fd438..501d45b74e
--- a/apps/web/prisma/schema.prisma
+++ b/apps/web/prisma/schema.prisma
@@@ -364,68 -382,3 +382,68 @@@ model jackson_ttl
@@index([expiresAt], map: "_jackson_ttl_expires_at")
}
+
- model OAuthClient {
++model OAuthApp {
+ id String @id @default(cuid())
+ projectId String
+ name String
+ website String
+ description String?
+ clientId String @unique
+ clientSecretHashed String
+ redirectUri String
+ scopes String?
+ createdAt DateTime @default(now())
+ updatedAt DateTime @updatedAt
+
+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
+ codes OAuthCode[]
+ accessTokens OAuthAccessToken[]
+
+ @@index(projectId)
+}
+
+model OAuthCode {
+ id String @id @default(cuid())
+ clientId String
+ userId String
+ projectId String // Workspace user granted access to
+ code String @unique
+ redirectUri String
+ expiresAt DateTime
+ createdAt DateTime @default(now())
+
+ project Project @relation(fields: [projectId], references: [id], onDelete: Cascade)
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
+ client OAuthClient @relation(fields: [clientId], references: [clientId], onDelete: Cascade)
+
+ @@index([clientId, code])
+}
+
+model OAuthAccessToken {
+ id String @id @default(cuid())
+ clientId String
+ userId String
+ accessToken String @unique
+ expiresAt DateTime
+ createdAt DateTime @default(now())
+
+ user User @relation(fields: [userId], references: [id], onDelete: Cascade)
+ client OAuthClient @relation(fields: [clientId], references: [clientId], onDelete: Cascade)
+ refreshTokens OAuthRefreshToken[]
+
+ @@index(clientId)
+ @@index(userId)
+}
+
+model OAuthRefreshToken {
+ id String @id @default(cuid())
+ accessTokenId String
+ refreshToken String @unique
+ expiresAt DateTime
+ createdAt DateTime @default(now())
+
+ accessToken OAuthAccessToken @relation(fields: [accessTokenId], references: [id], onDelete: Cascade)
+
+ @@index(accessTokenId)
+}