- Redesign the Identity module with a richer domain model. - Extend the User entity to support username, Authentik integration, activity tracking, and storage information. - Add Role and Permission domain models with many-to-many relationships. - Implement RBAC foundation using UserRole, RolePermission, and UserPermission mappings. - Add user storage quota and usage fields with default values. - Introduce Authentik identifiers and synchronization metadata. - Refactor user domain logic for role and permission management. - Update Prisma schema to support the new identity architecture. - Improve JWT authentication and permission guard integration. - Update repositories, handlers, controllers, mappers, DTOs, and Swagger configuration. - Refresh environment configuration and project dependencies.
109 lines
2.3 KiB
Plaintext
109 lines
2.3 KiB
Plaintext
// Prisma schema
|
|
// Basic User model for RayLab Core
|
|
|
|
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
|
|
authentikId String? @unique
|
|
authentikUserId String? @unique
|
|
authentikSubject String? @unique
|
|
|
|
username String @unique
|
|
email String @unique
|
|
|
|
|
|
isActive Boolean @default(true)
|
|
|
|
// storage (in bytes)
|
|
storageQuota BigInt @default(10737418240)
|
|
storageUsed BigInt @default(0)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
deletedAt DateTime?
|
|
lastSeenAt DateTime?
|
|
lastSyncedAt DateTime?
|
|
syncStatus String?
|
|
|
|
roles UserRole[]
|
|
permissions UserPermission[]
|
|
|
|
}
|
|
|
|
model Role {
|
|
id String @id @default(uuid())
|
|
|
|
code String @unique
|
|
name String
|
|
description String?
|
|
|
|
isDefault Boolean @default(false)
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
users UserRole[]
|
|
permissions RolePermission[]
|
|
}
|
|
|
|
model Permission {
|
|
id String @id @default(uuid())
|
|
|
|
code String @unique
|
|
name String
|
|
description String?
|
|
|
|
createdAt DateTime @default(now())
|
|
updatedAt DateTime @updatedAt
|
|
|
|
roles RolePermission[]
|
|
users UserPermission[]
|
|
}
|
|
|
|
model UserRole {
|
|
userId String
|
|
roleId String
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
|
|
|
assignedAt DateTime @default(now())
|
|
assignedBy String
|
|
|
|
@@id([userId, roleId])
|
|
}
|
|
|
|
model RolePermission {
|
|
roleId String
|
|
permissionId String
|
|
|
|
role Role @relation(fields: [roleId], references: [id], onDelete: Cascade)
|
|
permission Permission @relation(fields: [permissionId], references: [id], onDelete: Cascade)
|
|
|
|
assignedAt DateTime @default(now())
|
|
assignedBy String
|
|
|
|
@@id([roleId, permissionId])
|
|
}
|
|
|
|
model UserPermission {
|
|
userId String
|
|
permissionId String
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
permission Permission @relation(fields: [permissionId], references: [id], onDelete: Cascade)
|
|
|
|
assignedAt DateTime @default(now())
|
|
assignedBy String
|
|
|
|
@@id([userId, permissionId])
|
|
} |