mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 18:27:19 +00:00
misc: added flag to disable rate limit updates via API
This commit is contained in:
@@ -67,3 +67,5 @@ CLIENT_SECRET_GITLAB_LOGIN=
|
|||||||
CAPTCHA_SECRET=
|
CAPTCHA_SECRET=
|
||||||
|
|
||||||
NEXT_PUBLIC_CAPTCHA_SITE_KEY=
|
NEXT_PUBLIC_CAPTCHA_SITE_KEY=
|
||||||
|
|
||||||
|
ALLOW_RATELIMIT_UPDATES=
|
||||||
|
|||||||
@@ -123,7 +123,8 @@ const envSchema = z
|
|||||||
.optional(),
|
.optional(),
|
||||||
INFISICAL_CLOUD: zodStrBool.default("false"),
|
INFISICAL_CLOUD: zodStrBool.default("false"),
|
||||||
MAINTENANCE_MODE: zodStrBool.default("false"),
|
MAINTENANCE_MODE: zodStrBool.default("false"),
|
||||||
CAPTCHA_SECRET: zpStr(z.string().optional())
|
CAPTCHA_SECRET: zpStr(z.string().optional()),
|
||||||
|
ALLOW_RATELIMIT_UPDATES: zodStrBool.default("false")
|
||||||
})
|
})
|
||||||
.transform((data) => ({
|
.transform((data) => ({
|
||||||
...data,
|
...data,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import { CronJob } from "cron";
|
import { CronJob } from "cron";
|
||||||
|
|
||||||
|
import { getConfig } from "@app/lib/config/env";
|
||||||
|
import { ForbiddenRequestError } from "@app/lib/errors";
|
||||||
import { logger } from "@app/lib/logger";
|
import { logger } from "@app/lib/logger";
|
||||||
import { rateLimitMaxConfiguration } from "@app/server/config/rateLimiter";
|
import { rateLimitMaxConfiguration } from "@app/server/config/rateLimiter";
|
||||||
|
|
||||||
@@ -22,6 +24,13 @@ export const rateLimitServiceFactory = ({ rateLimitDAL }: TRateLimitServiceFacto
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateRateLimit = async (updates: TRateLimitUpdateDTO): Promise<TRateLimit> => {
|
const updateRateLimit = async (updates: TRateLimitUpdateDTO): Promise<TRateLimit> => {
|
||||||
|
const appCfg = getConfig();
|
||||||
|
if (!appCfg.ALLOW_RATELIMIT_UPDATES) {
|
||||||
|
throw new ForbiddenRequestError({
|
||||||
|
name: "Rate limit Updates Disabled",
|
||||||
|
message: "Changes to rate limits are disabled"
|
||||||
|
});
|
||||||
|
}
|
||||||
return rateLimitDAL.updateById("00000000-0000-0000-0000-000000000000", updates);
|
return rateLimitDAL.updateById("00000000-0000-0000-0000-000000000000", updates);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user