feat(api-key): Allow revoking in the future, and enforce the secret key (#6484)

Since there is quite a bit of code here already, I'll do the middleware changes in a separate PR
This commit is contained in:
Stevche Radevski
2024-02-27 10:37:32 +00:00
committed by GitHub
parent ca463ae9a9
commit 690e8c2e09
13 changed files with 357 additions and 120 deletions
@@ -16,6 +16,7 @@ export const POST = async (
input: {
selector: { id: req.params.id },
revoke: {
...(req.validatedBody as Omit<RevokeApiKeyDTO, "revoked_by">),
revoked_by: req.auth.actor_id,
} as RevokeApiKeyDTO,
},
@@ -37,7 +37,7 @@ export const POST = async (
const { result, errors } = await updateApiKeysWorkflow(req.scope).run({
input: {
selector: { id: req.params.id },
update: req.validatedBody,
update: req.validatedBody as UpdateApiKeyDTO,
},
throwOnError: false,
})
@@ -3,6 +3,7 @@ import { Type } from "class-transformer"
import {
IsArray,
IsEnum,
IsNumber,
IsOptional,
IsString,
ValidateNested,
@@ -65,6 +66,10 @@ export class AdminPostApiKeysApiKeyReq {
title: string
}
export class AdminRevokeApiKeysApiKeyReq {}
export class AdminRevokeApiKeysApiKeyReq {
@IsOptional()
@IsNumber()
revoke_in?: number
}
export class AdminDeleteApiKeysApiKeyReq {}