api: API key authentication with rotation and grace period
- Add ApiKey Prisma model (keyHash, expiresAt, revokedAt) - Protect /api/v1/* routes with Authorization: Bearer header check in hooks - create rotateApiKey() utility: normal (48h grace) and emergency (immediate) - Add Super-only /admin/api-keys page for key rotation with one-time reveal - Fix roleId check by using parent layout's DB-fetched adminUser - Add API Keys link to admin sidebar
This commit is contained in:
@@ -397,6 +397,7 @@ export const ModelName = {
|
||||
ProclamationCategory: 'ProclamationCategory',
|
||||
ProclamationCategorySubscriptionLevel: 'ProclamationCategorySubscriptionLevel',
|
||||
LicenseKey: 'LicenseKey',
|
||||
ApiKey: 'ApiKey',
|
||||
SubscriptionLevel: 'SubscriptionLevel'
|
||||
} as const
|
||||
|
||||
@@ -413,7 +414,7 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
omit: GlobalOmitOptions
|
||||
}
|
||||
meta: {
|
||||
modelProps: "user" | "profile" | "address" | "session" | "account" | "userRole" | "verification" | "proclamation" | "userProclamations" | "solfeggioFrequency" | "proclamationCategory" | "proclamationCategorySubscriptionLevel" | "licenseKey" | "subscriptionLevel"
|
||||
modelProps: "user" | "profile" | "address" | "session" | "account" | "userRole" | "verification" | "proclamation" | "userProclamations" | "solfeggioFrequency" | "proclamationCategory" | "proclamationCategorySubscriptionLevel" | "licenseKey" | "apiKey" | "subscriptionLevel"
|
||||
txIsolationLevel: TransactionIsolationLevel
|
||||
}
|
||||
model: {
|
||||
@@ -1379,6 +1380,80 @@ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runt
|
||||
}
|
||||
}
|
||||
}
|
||||
ApiKey: {
|
||||
payload: Prisma.$ApiKeyPayload<ExtArgs>
|
||||
fields: Prisma.ApiKeyFieldRefs
|
||||
operations: {
|
||||
findUnique: {
|
||||
args: Prisma.ApiKeyFindUniqueArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload> | null
|
||||
}
|
||||
findUniqueOrThrow: {
|
||||
args: Prisma.ApiKeyFindUniqueOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload>
|
||||
}
|
||||
findFirst: {
|
||||
args: Prisma.ApiKeyFindFirstArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload> | null
|
||||
}
|
||||
findFirstOrThrow: {
|
||||
args: Prisma.ApiKeyFindFirstOrThrowArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload>
|
||||
}
|
||||
findMany: {
|
||||
args: Prisma.ApiKeyFindManyArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload>[]
|
||||
}
|
||||
create: {
|
||||
args: Prisma.ApiKeyCreateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload>
|
||||
}
|
||||
createMany: {
|
||||
args: Prisma.ApiKeyCreateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
createManyAndReturn: {
|
||||
args: Prisma.ApiKeyCreateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload>[]
|
||||
}
|
||||
delete: {
|
||||
args: Prisma.ApiKeyDeleteArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload>
|
||||
}
|
||||
update: {
|
||||
args: Prisma.ApiKeyUpdateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload>
|
||||
}
|
||||
deleteMany: {
|
||||
args: Prisma.ApiKeyDeleteManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateMany: {
|
||||
args: Prisma.ApiKeyUpdateManyArgs<ExtArgs>
|
||||
result: BatchPayload
|
||||
}
|
||||
updateManyAndReturn: {
|
||||
args: Prisma.ApiKeyUpdateManyAndReturnArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload>[]
|
||||
}
|
||||
upsert: {
|
||||
args: Prisma.ApiKeyUpsertArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.PayloadToResult<Prisma.$ApiKeyPayload>
|
||||
}
|
||||
aggregate: {
|
||||
args: Prisma.ApiKeyAggregateArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.AggregateApiKey>
|
||||
}
|
||||
groupBy: {
|
||||
args: Prisma.ApiKeyGroupByArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.ApiKeyGroupByOutputType>[]
|
||||
}
|
||||
count: {
|
||||
args: Prisma.ApiKeyCountArgs<ExtArgs>
|
||||
result: runtime.Types.Utils.Optional<Prisma.ApiKeyCountAggregateOutputType> | number
|
||||
}
|
||||
}
|
||||
}
|
||||
SubscriptionLevel: {
|
||||
payload: Prisma.$SubscriptionLevelPayload<ExtArgs>
|
||||
fields: Prisma.SubscriptionLevelFieldRefs
|
||||
@@ -1648,6 +1723,18 @@ export const LicenseKeyScalarFieldEnum = {
|
||||
export type LicenseKeyScalarFieldEnum = (typeof LicenseKeyScalarFieldEnum)[keyof typeof LicenseKeyScalarFieldEnum]
|
||||
|
||||
|
||||
export const ApiKeyScalarFieldEnum = {
|
||||
id: 'id',
|
||||
keyPrefix: 'keyPrefix',
|
||||
keyHash: 'keyHash',
|
||||
createdAt: 'createdAt',
|
||||
expiresAt: 'expiresAt',
|
||||
revokedAt: 'revokedAt'
|
||||
} as const
|
||||
|
||||
export type ApiKeyScalarFieldEnum = (typeof ApiKeyScalarFieldEnum)[keyof typeof ApiKeyScalarFieldEnum]
|
||||
|
||||
|
||||
export const SubscriptionLevelScalarFieldEnum = {
|
||||
id: 'id',
|
||||
name: 'name',
|
||||
@@ -1872,6 +1959,7 @@ export type GlobalOmitConfig = {
|
||||
proclamationCategory?: Prisma.ProclamationCategoryOmit
|
||||
proclamationCategorySubscriptionLevel?: Prisma.ProclamationCategorySubscriptionLevelOmit
|
||||
licenseKey?: Prisma.LicenseKeyOmit
|
||||
apiKey?: Prisma.ApiKeyOmit
|
||||
subscriptionLevel?: Prisma.SubscriptionLevelOmit
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user