From b9ff0b5de6d2035c5f5d05115bae24b04e83ddf3 Mon Sep 17 00:00:00 2001 From: Milo Schwartz Date: Sat, 16 Nov 2024 22:48:10 -0500 Subject: [PATCH] move middlewares out of auth --- server/{routers/auth => middlewares}/getUserOrgs.ts | 0 server/middlewares/index.ts | 10 ++++++++++ server/{routers/auth => middlewares}/verifyAdmin.ts | 0 .../auth => middlewares}/verifyOrgAccess.ts | 0 .../auth => middlewares}/verifyResourceAccess.ts | 0 .../auth => middlewares}/verifyRoleAccess.ts | 0 .../auth => middlewares}/verifySetResourceUsers.ts | 0 .../auth => middlewares}/verifySiteAccess.ts | 0 .../auth => middlewares}/verifyTargetAccess.ts | 0 .../auth => middlewares}/verifyUserAccess.ts | 0 .../auth => middlewares}/verifyUserHasAction.ts | 0 .../auth => middlewares}/verifyUserInRole.ts | 0 .../auth => middlewares}/verifyUserIsOrgOwner.ts | 0 server/routers/auth/index.ts | 11 ----------- server/routers/external.ts | 13 +++++-------- 15 files changed, 15 insertions(+), 19 deletions(-) rename server/{routers/auth => middlewares}/getUserOrgs.ts (100%) rename server/{routers/auth => middlewares}/verifyAdmin.ts (100%) rename server/{routers/auth => middlewares}/verifyOrgAccess.ts (100%) rename server/{routers/auth => middlewares}/verifyResourceAccess.ts (100%) rename server/{routers/auth => middlewares}/verifyRoleAccess.ts (100%) rename server/{routers/auth => middlewares}/verifySetResourceUsers.ts (100%) rename server/{routers/auth => middlewares}/verifySiteAccess.ts (100%) rename server/{routers/auth => middlewares}/verifyTargetAccess.ts (100%) rename server/{routers/auth => middlewares}/verifyUserAccess.ts (100%) rename server/{routers/auth => middlewares}/verifyUserHasAction.ts (100%) rename server/{routers/auth => middlewares}/verifyUserInRole.ts (100%) rename server/{routers/auth => middlewares}/verifyUserIsOrgOwner.ts (100%) diff --git a/server/routers/auth/getUserOrgs.ts b/server/middlewares/getUserOrgs.ts similarity index 100% rename from server/routers/auth/getUserOrgs.ts rename to server/middlewares/getUserOrgs.ts diff --git a/server/middlewares/index.ts b/server/middlewares/index.ts index a5a5329b..c7ada386 100644 --- a/server/middlewares/index.ts +++ b/server/middlewares/index.ts @@ -3,3 +3,13 @@ export * from "./rateLimit"; export * from "./formatError"; export * from "./verifySession"; export * from "./verifyUser"; +export * from "./verifyOrgAccess"; +export * from "./getUserOrgs"; +export * from "./verifySiteAccess"; +export * from "./verifyResourceAccess"; +export * from "./verifyTargetAccess"; +export * from "./verifyRoleAccess"; +export * from "./verifyUserAccess"; +export * from "./verifyAdmin"; +export * from "./verifySetResourceUsers"; +export * from "./verifyUserInRole"; diff --git a/server/routers/auth/verifyAdmin.ts b/server/middlewares/verifyAdmin.ts similarity index 100% rename from server/routers/auth/verifyAdmin.ts rename to server/middlewares/verifyAdmin.ts diff --git a/server/routers/auth/verifyOrgAccess.ts b/server/middlewares/verifyOrgAccess.ts similarity index 100% rename from server/routers/auth/verifyOrgAccess.ts rename to server/middlewares/verifyOrgAccess.ts diff --git a/server/routers/auth/verifyResourceAccess.ts b/server/middlewares/verifyResourceAccess.ts similarity index 100% rename from server/routers/auth/verifyResourceAccess.ts rename to server/middlewares/verifyResourceAccess.ts diff --git a/server/routers/auth/verifyRoleAccess.ts b/server/middlewares/verifyRoleAccess.ts similarity index 100% rename from server/routers/auth/verifyRoleAccess.ts rename to server/middlewares/verifyRoleAccess.ts diff --git a/server/routers/auth/verifySetResourceUsers.ts b/server/middlewares/verifySetResourceUsers.ts similarity index 100% rename from server/routers/auth/verifySetResourceUsers.ts rename to server/middlewares/verifySetResourceUsers.ts diff --git a/server/routers/auth/verifySiteAccess.ts b/server/middlewares/verifySiteAccess.ts similarity index 100% rename from server/routers/auth/verifySiteAccess.ts rename to server/middlewares/verifySiteAccess.ts diff --git a/server/routers/auth/verifyTargetAccess.ts b/server/middlewares/verifyTargetAccess.ts similarity index 100% rename from server/routers/auth/verifyTargetAccess.ts rename to server/middlewares/verifyTargetAccess.ts diff --git a/server/routers/auth/verifyUserAccess.ts b/server/middlewares/verifyUserAccess.ts similarity index 100% rename from server/routers/auth/verifyUserAccess.ts rename to server/middlewares/verifyUserAccess.ts diff --git a/server/routers/auth/verifyUserHasAction.ts b/server/middlewares/verifyUserHasAction.ts similarity index 100% rename from server/routers/auth/verifyUserHasAction.ts rename to server/middlewares/verifyUserHasAction.ts diff --git a/server/routers/auth/verifyUserInRole.ts b/server/middlewares/verifyUserInRole.ts similarity index 100% rename from server/routers/auth/verifyUserInRole.ts rename to server/middlewares/verifyUserInRole.ts diff --git a/server/routers/auth/verifyUserIsOrgOwner.ts b/server/middlewares/verifyUserIsOrgOwner.ts similarity index 100% rename from server/routers/auth/verifyUserIsOrgOwner.ts rename to server/middlewares/verifyUserIsOrgOwner.ts diff --git a/server/routers/auth/index.ts b/server/routers/auth/index.ts index b47ff648..b6ce3a01 100644 --- a/server/routers/auth/index.ts +++ b/server/routers/auth/index.ts @@ -4,19 +4,8 @@ export * from "./logout"; export * from "./verifyTotp"; export * from "./requestTotpSecret"; export * from "./disable2fa"; -export * from "./verifyOrgAccess"; -export * from "./getUserOrgs"; -export * from "./verifySiteAccess"; -export * from "./verifyResourceAccess"; -export * from "./verifyTargetAccess"; -export * from "./verifyRoleAccess"; -export * from "./verifyUserAccess"; -export * from "./verifyAdmin"; -// export * from "./verifySuperUser"; export * from "./verifyEmail"; export * from "./requestEmailVerificationCode"; export * from "./changePassword"; export * from "./requestPasswordReset"; export * from "./resetPassword"; -export * from "./verifyUserInRole"; -export * from "./verifySetResourceUsers"; \ No newline at end of file diff --git a/server/routers/external.ts b/server/routers/external.ts index b7d5dee6..62c5ac0b 100644 --- a/server/routers/external.ts +++ b/server/routers/external.ts @@ -11,21 +11,18 @@ import { rateLimitMiddleware, verifySessionMiddleware, verifySessionUserMiddleware, -} from "@server/middlewares"; -import { verifyOrgAccess, - getUserOrgs, verifySiteAccess, verifyResourceAccess, verifyTargetAccess, verifyRoleAccess, + verifySetResourceUsers, verifyUserAccess, - verifyUserInRole, - verifySetResourceUsers -} from "./auth"; -import { verifyUserHasAction } from "./auth/verifyUserHasAction"; + getUserOrgs, +} from "@server/middlewares"; +import { verifyUserHasAction } from "../middlewares/verifyUserHasAction"; import { ActionsEnum } from "@server/auth/actions"; -import { verifyUserIsOrgOwner } from "./auth/verifyUserIsOrgOwner"; +import { verifyUserIsOrgOwner } from "../middlewares/verifyUserIsOrgOwner"; import { createNewt, getToken } from "./newt"; // Root routes