89 lines
2.9 KiB
Plaintext
89 lines
2.9 KiB
Plaintext
// VR-MCP — OAuth 2.1 authorization state for remote MCP clients.
|
|
//
|
|
// Deliberately keeps bare tenant/user id scalars so the MCP auth module can
|
|
// evolve independently from the account core schema.
|
|
|
|
model McpOAuthClient {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
clientId String @unique
|
|
clientName String
|
|
redirectUris Json
|
|
grantTypes Json @default("[\"authorization_code\",\"refresh_token\"]")
|
|
scopes Json @default("[\"mcp:read\"]")
|
|
contacts Json?
|
|
metadata Json?
|
|
active Boolean @default(true)
|
|
|
|
authorizationCodes McpOAuthAuthorizationCode[]
|
|
accessTokens McpOAuthAccessToken[]
|
|
refreshTokens McpOAuthRefreshToken[]
|
|
|
|
@@index([active, createdAt], name: "mcp_oauth_client_active_created_idx")
|
|
}
|
|
|
|
model McpOAuthAuthorizationCode {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
clientId String
|
|
userId String
|
|
tenantId String
|
|
tenantSlug String
|
|
codeHash String @unique
|
|
redirectUri String
|
|
scopes Json
|
|
resource String
|
|
codeChallenge String
|
|
codeChallengeMethod String
|
|
expiresAt DateTime
|
|
consumedAt DateTime?
|
|
|
|
client McpOAuthClient @relation(fields: [clientId], references: [id], onDelete: Cascade)
|
|
|
|
@@index([clientId, expiresAt], name: "mcp_oauth_code_client_expires_idx")
|
|
@@index([tenantId, userId], name: "mcp_oauth_code_tenant_user_idx")
|
|
}
|
|
|
|
model McpOAuthAccessToken {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
clientId String
|
|
userId String
|
|
tenantId String
|
|
tenantSlug String
|
|
tokenHash String @unique
|
|
scopes Json
|
|
resource String
|
|
expiresAt DateTime
|
|
revokedAt DateTime?
|
|
refreshTokenId String?
|
|
|
|
client McpOAuthClient @relation(fields: [clientId], references: [id], onDelete: Cascade)
|
|
refreshToken McpOAuthRefreshToken? @relation(fields: [refreshTokenId], references: [id], onDelete: SetNull)
|
|
|
|
@@index([tenantId, userId], name: "mcp_oauth_access_tenant_user_idx")
|
|
@@index([clientId, expiresAt], name: "mcp_oauth_access_client_expires_idx")
|
|
}
|
|
|
|
model McpOAuthRefreshToken {
|
|
id String @id @default(cuid())
|
|
createdAt DateTime @default(now())
|
|
rotatedAt DateTime?
|
|
clientId String
|
|
userId String
|
|
tenantId String
|
|
tenantSlug String
|
|
tokenHash String @unique
|
|
scopes Json
|
|
resource String
|
|
expiresAt DateTime
|
|
revokedAt DateTime?
|
|
|
|
client McpOAuthClient @relation(fields: [clientId], references: [id], onDelete: Cascade)
|
|
accessTokens McpOAuthAccessToken[]
|
|
|
|
@@index([tenantId, userId], name: "mcp_oauth_refresh_tenant_user_idx")
|
|
@@index([clientId, expiresAt], name: "mcp_oauth_refresh_client_expires_idx")
|
|
}
|