mirror of
https://github.com/fosrl/pangolin.git
synced 2026-05-17 06:24:32 +00:00
🚧 wip
This commit is contained in:
@@ -10,8 +10,11 @@ import { fromError } from "zod-validation-error";
|
|||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { OpenAPITags, registry } from "@server/openApi";
|
import { OpenAPITags, registry } from "@server/openApi";
|
||||||
|
|
||||||
const setUserResourcesBodySchema = z.strictObject({
|
const setResourcePolicyAcccessControlBodySchema = z.strictObject({
|
||||||
userIds: z.array(z.string())
|
sso: z.boolean(),
|
||||||
|
userIds: z.array(z.string()),
|
||||||
|
roleIds: z.array(z.int().positive()),
|
||||||
|
skipToIdpId: z.string().optional()
|
||||||
});
|
});
|
||||||
|
|
||||||
const setResourcePolicyAccessControlParamsSchema = z.strictObject({
|
const setResourcePolicyAccessControlParamsSchema = z.strictObject({
|
||||||
@@ -22,14 +25,14 @@ registry.registerPath({
|
|||||||
method: "post",
|
method: "post",
|
||||||
path: "/resource-policy/{resourceId}/access-control",
|
path: "/resource-policy/{resourceId}/access-control",
|
||||||
description:
|
description:
|
||||||
"Set access control users for a resource policy, including SSO, users, authentication.",
|
"Set access control users for a resource policy, including SSO, users, roles, Identity provider.",
|
||||||
tags: [OpenAPITags.Resource, OpenAPITags.User],
|
tags: [OpenAPITags.Resource, OpenAPITags.User],
|
||||||
request: {
|
request: {
|
||||||
params: setResourcePolicyAccessControlParamsSchema,
|
params: setResourcePolicyAccessControlParamsSchema,
|
||||||
body: {
|
body: {
|
||||||
content: {
|
content: {
|
||||||
"application/json": {
|
"application/json": {
|
||||||
schema: setUserResourcesBodySchema
|
schema: setResourcePolicyAcccessControlBodySchema
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -43,7 +46,9 @@ export async function setResourceUsers(
|
|||||||
next: NextFunction
|
next: NextFunction
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
try {
|
try {
|
||||||
const parsedBody = setUserResourcesBodySchema.safeParse(req.body);
|
const parsedBody = setResourcePolicyAcccessControlBodySchema.safeParse(
|
||||||
|
req.body
|
||||||
|
);
|
||||||
if (!parsedBody.success) {
|
if (!parsedBody.success) {
|
||||||
return next(
|
return next(
|
||||||
createHttpError(
|
createHttpError(
|
||||||
|
|||||||
Reference in New Issue
Block a user