diff --git a/backend/src/api/routes/admin.ts b/backend/src/api/routes/admin.ts index 2fe6e0b96..d04b4aae9 100644 --- a/backend/src/api/routes/admin.ts +++ b/backend/src/api/routes/admin.ts @@ -1,11 +1,24 @@ // import joi from "joi"; import { Router } from "express"; import { authenticateRequest } from "../../middlewares/auth"; -import { asyncHandler, checkIfUserIsAdmin } from "../../middlewares/api-utils"; +import { + asyncHandler, + checkIfUserIsAdmin, + validateConfiguration, +} from "../../middlewares/api-utils"; import * as AdminController from "../controllers/admin"; const router = Router(); +router.use( + validateConfiguration({ + criteria: (configuration) => { + return configuration.admin.endpointsEnabled; + }, + invalidMessage: "Admin endpoints are currently disabled.", + }) +); + router.get( "/", authenticateRequest({ diff --git a/backend/src/constants/base-configuration.ts b/backend/src/constants/base-configuration.ts index 36836107e..236d0272e 100644 --- a/backend/src/constants/base-configuration.ts +++ b/backend/src/constants/base-configuration.ts @@ -22,6 +22,9 @@ export const BASE_CONFIGURATION: MonkeyTypes.Configuration = { submissionsEnabled: false, maxFavorites: 0, }, + admin: { + endpointsEnabled: false, + }, apeKeys: { endpointsEnabled: false, acceptKeys: false, @@ -202,6 +205,16 @@ export const CONFIGURATION_FORM_SCHEMA: ObjectSchema }, }, }, + admin: { + type: "object", + label: "Admin", + fields: { + endpointsEnabled: { + type: "boolean", + label: "Endpoints Enabled", + }, + }, + }, apeKeys: { type: "object", label: "Ape Keys", diff --git a/backend/src/types/types.d.ts b/backend/src/types/types.d.ts index 9489b59f9..0bada4963 100644 --- a/backend/src/types/types.d.ts +++ b/backend/src/types/types.d.ts @@ -62,6 +62,9 @@ declare namespace MonkeyTypes { maxMail: number; }; }; + admin: { + endpointsEnabled: boolean; + }; apeKeys: { endpointsEnabled: boolean; acceptKeys: boolean;