Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

refactor(rate-limit): remove unused self-hosted rate limit config

Calvin360b52fbcc02
diff --git a/backend-go/internal/ee/services/license/types.go b/backend-go/internal/ee/services/license/types.go
index 3143c79692..69cea251a0 100644
--- a/backend-go/internal/ee/services/license/types.go
+++ b/backend-go/internal/ee/services/license/types.go
@@ -67,7 +67,6 @@ type FeatureSet struct {
PitRecovery bool `json:"pitRecovery"`
IPAllowlisting bool `json:"ipAllowlisting"`
RBAC bool `json:"rbac"`
- CustomRateLimits bool `json:"customRateLimits"`
CustomAlerts bool `json:"customAlerts"`
AuditLogs bool `json:"auditLogs"`
AuditLogsRetentionDays IntOrBool `json:"auditLogsRetentionDays"`
diff --git a/backend-go/internal/ee/services/ratelimit/ratelimit.go b/backend-go/internal/ee/services/ratelimit/ratelimit.go
index 71e280ab06..9866e00089 100644
--- a/backend-go/internal/ee/services/ratelimit/ratelimit.go
+++ b/backend-go/internal/ee/services/ratelimit/ratelimit.go
@@ -59,7 +59,7 @@ func NewService(_ context.Context, logger *slog.Logger, deps *Deps) *Service {
})
limiter := httprate.NewRateLimiter(
- DefaultLimits.ReadLimit,
+ GlobalLimit,
defaultWindowLength,
httprate.WithKeyFuncs(httprate.KeyByRealIP),
httprate.WithLimitCounter(counter),
@@ -89,7 +89,7 @@ func (s *Service) Middleware(preset Preset) func(http.Handler) http.Handler {
}
}
-// GlobalMiddleware returns the baseline rate limiter (600/min).
+// GlobalMiddleware returns the baseline rate limiter (GlobalLimit per minute).
// Use this for routes that don't need plan-based dynamic limits.
func (s *Service) GlobalMiddleware() func(http.Handler) http.Handler {
if !s.enabled {
diff --git a/backend-go/internal/ee/services/ratelimit/types.go b/backend-go/internal/ee/services/ratelimit/types.go
index 1f98470751..af05b7a0f8 100644
--- a/backend-go/internal/ee/services/ratelimit/types.go
+++ b/backend-go/internal/ee/services/ratelimit/types.go
@@ -28,9 +28,12 @@ type Limits struct {
ProjectCreationLimit int
}
-// DefaultLimits are the instance-wide defaults (matching Node.js).
+// GlobalLimit is the per-IP baseline applied to routes without a preset, matching globalRateLimiterCfg in Node.
+const GlobalLimit = 600
+
+// DefaultLimits must match DEFAULT_RATE_LIMITS in backend/src/server/config/rateLimiter.ts.
var DefaultLimits = Limits{
- ReadLimit: 600,
+ ReadLimit: 60,
WriteLimit: 200,
SecretsLimit: 60,
AuthRateLimit: 60,
diff --git a/backend/CLAUDE.md b/backend/CLAUDE.md
index 7b8331d38c..e4c743b8dd 100644
--- a/backend/CLAUDE.md
+++ b/backend/CLAUDE.md
@@ -339,7 +339,7 @@ judgment. Two adjustments to that rule, both small enough to enumerate:
Three things are first-party outright, because they sit outside an org and the nav boundary doesn't
reach them:
- account self-management (user, password, MFA, sessions, login, signup, notifications, announcements)
-- super-admin routes (`v1/admin-router.ts`, `ee/v1/rate-limit-router.ts`), where `verifySuperAdmin` reads
+- super-admin routes (`v1/admin-router.ts`), where `verifySuperAdmin` reads
`user.superAdmin` rather than an ability
- `POST /v2/organizations`, and the org reads that return more than the token's org: `GET /v1/organization`,
`GET /v1/organization/accessible-with-sub-orgs`, `GET /v1/organization/:organizationId`. All pass
@@ -676,7 +676,7 @@ Queue handler factories (e.g., `src/services/secret/secret-queue.ts`) follow the
Recurring work runs through the cron manager in `src/lib/cron/cron-job.ts` (`cronJobFactory`). A single instance is constructed in `src/server/routes/index.ts` (~line 541) and injected as `cronJob` into any service that needs to schedule periodic work. The factory exposes `register`, `start`, and `stop`; `start` is called once after construction, and `stop` is invoked during graceful shutdown to drain in-flight handlers.
-**Only `general-workers` pods start the manager's timers**, so only they execute a scheduled handler; every pod still calls `register`. The separate `cronJobs` array in `src/server/routes/index.ts` is deliberately **not** gated: those refresh the process's own caches (license, rate limits, env overrides), not fleet work.
+**Only `general-workers` pods start the manager's timers**, so only they execute a scheduled handler; every pod still calls `register`. The separate `cronJobs` array in `src/server/routes/index.ts` is deliberately **not** gated: those refresh the process's own caches (license, env overrides), not fleet work.
**Per-process refreshes use `startLocalRefresh` (`src/lib/cron/local-refresh.ts`), never the cron manager and never a raw `new CronJob`.** The cron manager runs a job once per fleet, which would leave every other pod's in-memory state stale; a wall-clock cron pattern makes every pod fire in the same second. The helper starts each process at a random offset within one interval (random per process on purpose, unlike the manager's deterministic hash), skips a tick while the previous run is in flight, logs and swallows errors, and unrefs its timers. Its `stop()` handle is what goes in `cronJobs`. It records `infisical.local_refresh.*` on the `InfisicalCore` meter, labelled by `name` as `job.name`, so a new refresh needs no metric code; keep `name` a fixed string. A failing refresh keeps retrying on every tick rather than giving up after N failures, because stopping would freeze the pod's state at whatever it last loaded. The `consecutive_failures` gauge (reset on success) is the alerting signal.
diff --git a/backend/src/@types/fastify.d.ts b/backend/src/@types/fastify.d.ts
index a4a231ce2c..4ab5e5561c 100644
--- a/backend/src/@types/fastify.d.ts
+++ b/backend/src/@types/fastify.d.ts
@@ -63,7 +63,6 @@ import { TProjectEventsService } from "@app/ee/services/project-events/project-e
import { TProjectEventsSSEService } from "@app/ee/services/project-events/project-events-sse-service";
import { TProjectTemplateServiceFactory } from "@app/ee/services/project-template/project-template-types";
import { TProxiedServiceServiceFactory } from "@app/ee/services/proxied-service/proxied-service-service";
-import { RateLimitConfiguration, TRateLimitServiceFactory } from "@app/ee/services/rate-limit/rate-limit-types";
import { TRelayServiceFactory } from "@app/ee/services/relay/relay-service";
import { TResourceAuthMethodServiceFactory } from "@app/ee/services/resource-auth-method/resource-auth-method-service";
import { TSamlConfigServiceFactory } from "@app/ee/services/saml-config/saml-config-types";
@@ -76,6 +75,7 @@ import { TSecretScanningV2ServiceFactory } from "@app/ee/services/secret-scannin
import { TSubOrgServiceFactory } from "@app/ee/services/sub-org/sub-org-service";
import { TTrustedIpServiceFactory } from "@app/ee/services/trusted-ip/trusted-ip-types";
import { RequestMemoizer } from "@app/lib/request-context/request-memoizer";
+import { RateLimitConfiguration } from "@app/server/config/rateLimiter";
import { TAuthMode } from "@app/server/plugins/auth/inject-identity";
import { TAccountRecoveryServiceFactory } from "@app/services/account-recovery/account-recovery-service";
import { TAdditionalPrivilegeServiceFactory } from "@app/services/additional-privilege/additional-privilege-service";
@@ -409,7 +409,6 @@ declare module "fastify" {
dynamicSecretLease: TDynamicSecretLeaseServiceFactory;
emailDomain: TEmailDomainServiceFactory;
secretSharing: TSecretSharingServiceFactory;
- rateLimit: TRateLimitServiceFactory;
userActivation: TUserActivationServiceFactory;
userEngagement: TUserEngagementServiceFactory;
externalKms: TExternalKmsServiceFactory;
diff --git a/backend/src/ee/routes/v1/index.ts b/backend/src/ee/routes/v1/index.ts
index 2cc8d0a103..8886e60d7a 100644
--- a/backend/src/ee/routes/v1/index.ts
+++ b/backend/src/ee/routes/v1/index.ts
@@ -42,7 +42,6 @@ import { registerPkiInstallationRouter } from "./pki-installation-router";
import { registerProjectRoleRouter } from "./project-role-router";
import { registerProjectRouter } from "./project-router";
import { registerProxiedServiceRouter } from "./proxied-service-router";
-import { registerRateLimitRouter } from "./rate-limit-router";
import { registerRelayRouter } from "./relay-router";
import { registerRemovedProductTombstoneRouter } from "./removed-product-tombstone-router";
import { registerSamlRouter } from "./saml-router";
@@ -90,7 +89,6 @@ export const registerV1EERoutes = async (server: FastifyZodProvider) => {
await server.register(registerAccessApprovalPolicyRouter, { prefix: "/access-approvals/policies" });
await server.register(registerAccessApprovalRequestRouter, { prefix: "/access-approvals/requests" });
- await server.register(registerRateLimitRouter, { prefix: "/rate-limit" });
await server.register(
async (dynamicSecretRouter) => {
diff --git a/backend/src/ee/routes/v1/rate-limit-router.ts b/backend/src/ee/routes/v1/rate-limit-router.ts
deleted file mode 100644
index f37745f0db..0000000000
--- a/backend/src/ee/routes/v1/rate-limit-router.ts
+++ /dev/null
@@ -1,76 +0,0 @@
-import { z } from "zod";
-
-import { RateLimitSchema } from "@app/db/schemas";
-import { NotFoundError } from "@app/lib/errors";
-import { readLimit } from "@app/server/config/rateLimiter";
-import { verifySuperAdmin } from "@app/server/plugins/auth/superAdmin";
-import { verifyAuth } from "@app/server/plugins/auth/verify-auth";
-import { AuthMode } from "@app/services/auth/auth-type";
-
-export const registerRateLimitRouter = async (server: FastifyZodProvider) => {
- server.route({
- method: "GET",
- url: "/",
- config: {
- rateLimit: readLimit
- },
- schema: {
- response: {
- 200: z.object({
- rateLimit: RateLimitSchema
- })
- }
- },
- onRequest: (req, res, done) => {
- verifyAuth([AuthMode.JWT])(req, res, () => {
- verifySuperAdmin(req, res, done);
- });
- },
- handler: async () => {
- const rateLimit = await server.services.rateLimit.getRateLimits();
- if (!rateLimit) {
- throw new NotFoundError({
- name: "Get Rate Limit Error",
- message: "Rate limit configuration does not exist."
- });
- }
- return { rateLimit };
- }
- });
-
- server.route({
- method: "PUT",
- url: "/",
- config: {
- rateLimit: readLimit
- },
- onRequest: (req, res, done) => {
- verifyAuth([AuthMode.JWT])(req, res, () => {
- verifySuperAdmin(req, res, done);
- });
- },
-
- schema: {
- body: z.object({
- readRateLimit: z.number(),
- writeRateLimit: z.number(),
- secretsRateLimit: z.number(),
- authRateLimit: z.number(),
- inviteUserRateLimit: z.number(),
- mfaRateLimit: z.number(),
- publicEndpointLimit: z.number(),
- identityCreationLimit: z.number(),
- projectCreationLimit: z.number()
- }),
- response: {
- 200: z.object({
- rateLimit: RateLimitSchema
- })
- }
- },
- handler: async (req) => {
- const rateLimit = await server.services.rateLimit.updateRateLimit(req.body);
- return { rateLimit };
- }
- });
-};
diff --git a/backend/src/ee/services/license/__mocks__/license-fns.ts b/backend/src/ee/services/license/__mocks__/license-fns.ts
index 3bf41b977c..de99d76372 100644
--- a/backend/src/ee/services/license/__mocks__/license-fns.ts
+++ b/backend/src/ee/services/license/__mocks__/license-fns.ts
@@ -15,7 +15,6 @@ export const getDefaultOnPremFeatures = () => {
pitRecovery: false,
ipAllowlisting: true,
rbac: false,
- customRateLimits: false,
customAlerts: false,
auditLogs: false,
auditLogsRetentionDays: 0,
diff --git a/backend/src/ee/services/license/license-fns.ts b/backend/src/ee/services/license/license-fns.ts
index ae1f3624f0..7322fd9d1f 100644
--- a/backend/src/ee/services/license/license-fns.ts
+++ b/backend/src/ee/services/license/license-fns.ts
@@ -66,7 +66,6 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({
pitRecovery: false,
ipAllowlisting: false,
rbac: false,
- customRateLimits: false,
customAlerts: false,
auditLogs: false,
auditLogsRetentionDays: 0,
diff --git a/backend/src/ee/services/license/license-types.ts b/backend/src/ee/services/license/license-types.ts
index 2889f5d4a1..23ffd14070 100644
--- a/backend/src/ee/services/license/license-types.ts
+++ b/backend/src/ee/services/license/license-types.ts
@@ -60,7 +60,6 @@ export type TFeatureSet = {
pitRecovery: false;
ipAllowlisting: false;
rbac: false;
- customRateLimits: false;
customAlerts: false;
auditLogs: false;
auditLogsRetentionDays: 0;
diff --git a/backend/src/ee/services/rate-limit/rate-limit-dal.ts b/backend/src/ee/services/rate-limit/rate-limit-dal.ts
deleted file mode 100644
index 36b717cc4c..0000000000
--- a/backend/src/ee/services/rate-limit/rate-limit-dal.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-import { TDbClient } from "@app/db";
-import { TableName } from "@app/db/schemas";
-import { ormify, TOrmify } from "@app/lib/knex";
-
-export type TRateLimitDALFactory = TOrmify<TableName.RateLimit>;
-
-export const rateLimitDALFactory = (db: TDbClient): TRateLimitDALFactory => ormify(db, TableName.RateLimit, {});
diff --git a/backend/src/ee/services/rate-limit/rate-limit-service.ts b/backend/src/ee/services/rate-limit/rate-limit-service.ts
deleted file mode 100644
index 1538a859a5..0000000000
--- a/backend/src/ee/services/rate-limit/rate-limit-service.ts
+++ /dev/null
@@ -1,109 +0,0 @@
-import { startLocalRefresh } from "@app/lib/cron/local-refresh";
-import { logger } from "@app/lib/logger";
-
-import { TLicenseServiceFactory } from "../license/license-service";
-import { TRateLimitDALFactory } from "./rate-limit-dal";
-import { RateLimitConfiguration, TRateLimit, TRateLimitServiceFactory } from "./rate-limit-types";
-
-let rateLimitMaxConfiguration: RateLimitConfiguration = {
- readLimit: 60,
- publicEndpointLimit: 30,
- writeLimit: 200,
- secretsLimit: 60,
- authRateLimit: 60,
- inviteUserRateLimit: 30,
- mfaRateLimit: 20,
- identityCreationLimit: 30,
- projectCreationLimit: 30
-};
-
-Object.freeze(rateLimitMaxConfiguration);
-
-export const getRateLimiterConfig = () => {
- return rateLimitMaxConfiguration;
-};
-
-type TRateLimitServiceFactoryDep = {
- rateLimitDAL: TRateLimitDALFactory;
- licenseService: Pick<TLicenseServiceFactory, "onPremFeatures">;
-};
-
-export const rateLimitServiceFactory = ({
- rateLimitDAL,
- licenseService
-}: TRateLimitServiceFactoryDep): TRateLimitServiceFactory => {
- const DEFAULT_RATE_LIMIT_CONFIG_ID = "00000000-0000-0000-0000-000000000000";
-
- const $findOrCreateRateLimit = async (): Promise<TRateLimit> => {
- const rateLimit = await rateLimitDAL.findOne({ id: DEFAULT_RATE_LIMIT_CONFIG_ID });
- if (rateLimit) return rateLimit;
- return rateLimitDAL.create({
- // @ts-expect-error id is kept as fixed because there should only be one rate limit config per instance
- id: DEFAULT_RATE_LIMIT_CONFIG_ID
- });
- };
-
- const getRateLimits: TRateLimitServiceFactory["getRateLimits"] = async () => {
- try {
- return await $findOrCreateRateLimit();
- } catch (err) {
- logger.error(err, "Error fetching rate limits");
- return undefined;
- }
- };
-
- const updateRateLimit: TRateLimitServiceFactory["updateRateLimit"] = async (updates) => {
- return rateLimitDAL.updateById(DEFAULT_RATE_LIMIT_CONFIG_ID, updates);
- };
-
- const $syncRateLimitConfiguration = async () => {
- const rateLimit = await $findOrCreateRateLimit();
- const newRateLimitMaxConfiguration: typeof rateLimitMaxConfiguration = {
- readLimit: rateLimit.readRateLimit,
- publicEndpointLimit: rateLimit.publicEndpointLimit,
- writeLimit: rateLimit.writeRateLimit,
- secretsLimit: rateLimit.secretsRateLimit,
- authRateLimit: rateLimit.authRateLimit,
- inviteUserRateLimit: rateLimit.inviteUserRateLimit,
- mfaRateLimit: rateLimit.mfaRateLimit,
- identityCreationLimit: rateLimit.identityCreationLimit,
- projectCreationLimit: rateLimit.projectCreationLimit
- };
-
- logger.info(newRateLimitMaxConfiguration, "syncRateLimitConfiguration: rate limit configuration");
- Object.freeze(newRateLimitMaxConfiguration);
- rateLimitMaxConfiguration = newRateLimitMaxConfiguration;
- };
-
- const syncRateLimitConfiguration: TRateLimitServiceFactory["syncRateLimitConfiguration"] = async () => {
- try {
- await $syncRateLimitConfiguration();
- } catch (error) {
- logger.error(error, "Error syncing rate limit configurations");
- }
- };
-
- const initializeBackgroundSync: TRateLimitServiceFactory["initializeBackgroundSync"] = async () => {
- if (!licenseService.onPremFeatures.customRateLimits) {
- logger.info("Current license does not support custom rate limit configuration");
- return;
- }
-
- logger.info("Setting up background sync process for rate limits");
- // initial sync upon startup
- await syncRateLimitConfiguration();
-
- return startLocalRefresh({
- name: "rate-limit-config-sync",
- intervalMs: 10 * 60 * 1000,
- task: $syncRateLimitConfiguration
- });
- };
-
- return {
- getRateLimits,
- updateRateLimit,
- initializeBackgroundSync,
- syncRateLimitConfiguration
- };
-};
diff --git a/backend/src/ee/services/rate-limit/rate-limit-types.ts b/backend/src/ee/services/rate-limit/rate-limit-types.ts
deleted file mode 100644
index d46f490662..0000000000
--- a/backend/src/ee/services/rate-limit/rate-limit-types.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-import { TLocalRefreshHandle } from "@app/lib/cron/local-refresh";
-
-export type TRateLimitUpdateDTO = {
- readRateLimit: number;
- writeRateLimit: number;
- secretsRateLimit: number;
- authRateLimit: number;
- inviteUserRateLimit: number;
- mfaRateLimit: number;
- publicEndpointLimit: number;
- identityCreationLimit: number;
- projectCreationLimit: number;
-};
-
-export type TRateLimit = {
- id: string;
- createdAt: Date;
- updatedAt: Date;
-} & TRateLimitUpdateDTO;
-
-export type RateLimitConfiguration = {
- readLimit: number;
- publicEndpointLimit: number;
- writeLimit: number;
- secretsLimit: number;
- authRateLimit: number;
- inviteUserRateLimit: number;
- mfaRateLimit: number;
- identityCreationLimit: number;
- projectCreationLimit: number;
-};
-
-export type TRateLimitServiceFactory = {
- getRateLimits: () => Promise<TRateLimit | undefined>;
- updateRateLimit: (updates: TRateLimitUpdateDTO) => Promise<TRateLimit>;
- initializeBackgroundSync: () => Promise<TLocalRefreshHandle | undefined>;
- syncRateLimitConfiguration: () => Promise<void>;
-};
diff --git a/backend/src/server/config/rateLimiter.ts b/backend/src/server/config/rateLimiter.ts
index db45230f5a..c52daf13d8 100644
--- a/backend/src/server/config/rateLimiter.ts
+++ b/backend/src/server/config/rateLimiter.ts
@@ -4,6 +4,33 @@ import { getConfig } from "@app/lib/config/env";
import { buildRedisFromConfig } from "@app/lib/config/redis";
import { RateLimitError } from "@app/lib/errors";
+export type RateLimitConfiguration = {
+ readLimit: number;
+ publicEndpointLimit: number;
+ writeLimit: number;
+ secretsLimit: number;
+ authRateLimit: number;
+ inviteUserRateLimit: number;
+ mfaRateLimit: number;
+ identityCreationLimit: number;
+ projectCreationLimit: number;
+};
+
+// Requests without an org, and the limits the license server does not set per plan, use these.
+// Read, write and secrets limits come from the org's plan (see inject-rate-limits.ts).
+// Mirrored in backend-go/internal/ee/services/ratelimit/types.go.
+export const DEFAULT_RATE_LIMITS: Readonly<RateLimitConfiguration> = Object.freeze({
+ readLimit: 60,
+ publicEndpointLimit: 30,
+ writeLimit: 200,
+ secretsLimit: 60,
+ authRateLimit: 60,
+ inviteUserRateLimit: 30,
+ mfaRateLimit: 20,
+ identityCreationLimit: 30,
+ projectCreationLimit: 30
+});
+
export const globalRateLimiterCfg = (): RateLimitPluginOptions => {
const appCfg = getConfig();
const redis = appCfg.isRedisConfigured ? buildRedisFromConfig(appCfg, "rate-limiter") : null;
diff --git a/backend/src/server/plugins/inject-rate-limits.ts b/backend/src/server/plugins/inject-rate-limits.ts
index 20a4b9244c..d21e76dd19 100644
--- a/backend/src/server/plugins/inject-rate-limits.ts
+++ b/backend/src/server/plugins/inject-rate-limits.ts
@@ -1,45 +1,28 @@
import fp from "fastify-plugin";
-import { getRateLimiterConfig } from "@app/ee/services/rate-limit/rate-limit-service";
-import { getConfig } from "@app/lib/config/env";
import { requestMemoKeys } from "@app/lib/request-context/memo-keys";
import { requestMemoize } from "@app/lib/request-context/request-memoizer";
+import { DEFAULT_RATE_LIMITS } from "@app/server/config/rateLimiter";
export const injectRateLimits = fp(async (server) => {
server.decorateRequest("rateLimits");
server.addHook("onRequest", async (req) => {
- const appCfg = getConfig();
-
- const instanceRateLimiterConfig = getRateLimiterConfig();
if (!req.auth?.orgId) {
- // for public endpoints, we always use the instance-wide default rate limits
- req.rateLimits = instanceRateLimiterConfig;
+ req.rateLimits = DEFAULT_RATE_LIMITS;
return;
}
const { orgId } = req.auth;
- const { rateLimits, customRateLimits } = await requestMemoize(requestMemoKeys.licensePlan(orgId), () =>
+ const { rateLimits } = await requestMemoize(requestMemoKeys.licensePlan(orgId), () =>
server.services.license.getPlan(orgId)
);
- if (customRateLimits && !appCfg.isCloud) {
- // we do this because for self-hosted/dedicated instances, we want custom rate limits to be based on admin configuration
- // note that the syncing of custom rate limit happens on the instanceRateLimiterConfig object
- req.rateLimits = instanceRateLimiterConfig;
- return;
- }
-
- // we're using the null coalescing operator in order to handle outdated licenses
+ // the null coalescing handles plans cached before a limit was added to them
req.rateLimits = {
- readLimit: rateLimits?.readLimit ?? instanceRateLimiterConfig.readLimit,
- writeLimit: rateLimits?.writeLimit ?? instanceRateLimiterConfig.writeLimit,
- secretsLimit: rateLimits?.secretsLimit ?? instanceRateLimiterConfig.secretsLimit,
- publicEndpointLimit: instanceRateLimiterConfig.publicEndpointLimit,
- authRateLimit: instanceRateLimiterConfig.authRateLimit,
- inviteUserRateLimit: instanceRateLimiterConfig.inviteUserRateLimit,
- mfaRateLimit: instanceRateLimiterConfig.mfaRateLimit,
- identityCreationLimit: instanceRateLimiterConfig.identityCreationLimit,
- projectCreationLimit: instanceRateLimiterConfig.projectCreationLimit
+ ...DEFAULT_RATE_LIMITS,
+ readLimit: rateLimits?.readLimit ?? DEFAULT_RATE_LIMITS.readLimit,
+ writeLimit: rateLimits?.writeLimit ?? DEFAULT_RATE_LIMITS.writeLimit,
+ secretsLimit: rateLimits?.secretsLimit ?? DEFAULT_RATE_LIMITS.secretsLimit
};
});
});
diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.ts
index dc6ca82338..213dc69efd 100644
--- a/backend/src/server/routes/index.ts
+++ b/backend/src/server/routes/index.ts
@@ -174,8 +174,6 @@ import { projectTemplateUserMembershipDALFactory } from "@app/ee/services/projec
import { proxiedServiceCredentialDALFactory } from "@app/ee/services/proxied-service/proxied-service-credential-dal";
import { proxiedServiceDALFactory } from "@app/ee/services/proxied-service/proxied-service-dal";
import { proxiedServiceServiceFactory } from "@app/ee/services/proxied-service/proxied-service-service";
-import { rateLimitDALFactory } from "@app/ee/services/rate-limit/rate-limit-dal";
-import { rateLimitServiceFactory } from "@app/ee/services/rate-limit/rate-limit-service";
import { instanceRelayConfigDalFactory } from "@app/ee/services/relay/instance-relay-config-dal";
import { orgRelayConfigDalFactory } from "@app/ee/services/relay/org-relay-config-dal";
import { relayDalFactory } from "@app/ee/services/relay/relay-dal";
@@ -680,7 +678,6 @@ export const registerRoutes = async (
const orgMembershipDAL = orgMembershipDALFactory(db);
const userActivationDAL = userActivationDALFactory(db);
const incidentContactDAL = incidentContactDALFactory(db);
- const rateLimitDAL = rateLimitDALFactory(db);
const projectDAL = projectDALFactory(db);
const projectAccessRequestDAL = projectAccessRequestDALFactory(db);
@@ -1736,11 +1733,6 @@ export const registerRoutes = async (
usageMeteringService
});
- const rateLimitService = rateLimitServiceFactory({
- rateLimitDAL,
- licenseService
- });
-
const secretScanningQueue = secretScanningQueueFactory({
telemetryService,
smtpService,
@@ -4522,7 +4514,6 @@ export const registerRoutes = async (
secretReplication: secretReplicationService,
secretTag: secretTagService,
secretValidationRule: secretValidationRuleService,
- rateLimit: rateLimitService,
folder: folderService,
resourceMetadata: resourceMetadataService,
secretImport: secretImportService,
@@ -4692,14 +4683,10 @@ export const registerRoutes = async (
}
// Not gated by run mode, unlike the cron manager above: these refresh this process's own caches
- // (env overrides, license plan, rate limits, admin integration config), so an API pod that stopped
+ // (env overrides, license plan, admin integration config), so an API pod that stopped
// running them would serve stale config rather than shed background work.
const cronJobs: TLocalRefreshHandle[] = [];
if (appCfg.isProductionMode) {
- const rateLimitSyncJob = await rateLimitService.initializeBackgroundSync();
- if (rateLimitSyncJob) {
- cronJobs.push(rateLimitSyncJob);
- }
const licenseSyncJob = await licenseService.initializeBackgroundSync();
if (licenseSyncJob) {
cronJobs.push(licenseSyncJob);
diff --git a/backend/src/services/license-client/feature-mapping.ts b/backend/src/services/license-client/feature-mapping.ts
index 5a7ec25d36..84110726b3 100644
--- a/backend/src/services/license-client/feature-mapping.ts
+++ b/backend/src/services/license-client/feature-mapping.ts
@@ -136,10 +136,6 @@ const platformMappings: TFeatureMapping[] = [
v2Key: "gateway_pool",
v1Field: "gatewayPool"
},
- {
- v2Key: "custom_rate_limits",
- v1Field: "customRateLimits"
- },
{
v2Key: "custom_alerts",
v1Field: "customAlerts"
diff --git a/frontend/src/hooks/api/index.tsx b/frontend/src/hooks/api/index.tsx
index eee0b0efdd..62cb7135a7 100644
--- a/frontend/src/hooks/api/index.tsx
+++ b/frontend/src/hooks/api/index.tsx
@@ -55,7 +55,6 @@ export * from "./projectIdentity";
export * from "./projectIdentityMembership";
export * from "./projects";
export * from "./projectUserAdditionalPrivilege";
-export * from "./rateLimit";
export * from "./relays";
export * from "./roles";
export * from "./scim";
diff --git a/frontend/src/hooks/api/rateLimit/index.ts b/frontend/src/hooks/api/rateLimit/index.ts
deleted file mode 100644
index f3f81b1c96..0000000000
--- a/frontend/src/hooks/api/rateLimit/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export { useUpdateRateLimit } from "./mutation";
-export { useGetRateLimit } from "./queries";
diff --git a/frontend/src/hooks/api/rateLimit/mutation.ts b/frontend/src/hooks/api/rateLimit/mutation.ts
deleted file mode 100644
index d2aea631ba..0000000000
--- a/frontend/src/hooks/api/rateLimit/mutation.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { useMutation, useQueryClient } from "@tanstack/react-query";
-
-import { apiRequest } from "@app/config/request";
-
-import { rateLimitQueryKeys } from "./queries";
-import { TRateLimit } from "./types";
-
-export const useUpdateRateLimit = () => {
- const queryClient = useQueryClient();
-
- return useMutation<TRateLimit, object, TRateLimit>({
- mutationFn: async (opt) => {
- const { data } = await apiRequest.put<{ rateLimit: TRateLimit }>("/api/v1/rate-limit", opt);
- return data.rateLimit;
- },
- onSuccess: (data) => {
- queryClient.setQueryData(rateLimitQueryKeys.rateLimit(), data);
- queryClient.invalidateQueries({ queryKey: rateLimitQueryKeys.rateLimit() });
- }
- });
-};
diff --git a/frontend/src/hooks/api/rateLimit/queries.ts b/frontend/src/hooks/api/rateLimit/queries.ts
deleted file mode 100644
index 5a52ff74bf..0000000000
--- a/frontend/src/hooks/api/rateLimit/queries.ts
+++ /dev/null
@@ -1,34 +0,0 @@
-import { useQuery, UseQueryOptions } from "@tanstack/react-query";
-
-import { apiRequest } from "@app/config/request";
-
-import { TRateLimit } from "./types";
-
-export const rateLimitQueryKeys = {
- rateLimit: () => ["rate-limit"] as const
-};
-
-const fetchRateLimit = async () => {
- const { data } = await apiRequest.get<{ rateLimit: TRateLimit }>("/api/v1/rate-limit");
- return data.rateLimit;
-};
-
-export const useGetRateLimit = ({
- options = {}
-}: {
- options?: Omit<
- UseQueryOptions<
- TRateLimit,
- unknown,
- TRateLimit,
- ReturnType<typeof rateLimitQueryKeys.rateLimit>
- >,
- "queryKey" | "queryFn"
- >;
-} = {}) =>
- useQuery({
- queryKey: rateLimitQueryKeys.rateLimit(),
- queryFn: fetchRateLimit,
- ...options,
- enabled: options?.enabled ?? true
- });
diff --git a/frontend/src/hooks/api/rateLimit/types.ts b/frontend/src/hooks/api/rateLimit/types.ts
deleted file mode 100644
index 53b075ce43..0000000000
--- a/frontend/src/hooks/api/rateLimit/types.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-export type TRateLimit = {
- readRateLimit: number;
- writeRateLimit: number;
- secretsRateLimit: number;
- authRateLimit: number;
- inviteUserRateLimit: number;
- mfaRateLimit: number;
- publicEndpointLimit: number;
-};
diff --git a/frontend/src/hooks/api/subscriptions/types.ts b/frontend/src/hooks/api/subscriptions/types.ts
index 215fe04cdf..d194cf104c 100644
--- a/frontend/src/hooks/api/subscriptions/types.ts
+++ b/frontend/src/hooks/api/subscriptions/types.ts
@@ -27,7 +27,6 @@ export type SubscriptionPlan = {
auditLogStreamLimit: number;
auditLogStreams: boolean;
customAlerts: boolean;
- customRateLimits: boolean;
pitRecovery: boolean;
githubOrgSync: boolean;
subOrganization?: boolean;
diff --git a/tests/fakes/license/features.go b/tests/fakes/license/features.go
index 6177c250c7..7325f34531 100644
--- a/tests/fakes/license/features.go
+++ b/tests/fakes/license/features.go
@@ -10,7 +10,6 @@ var (
CertManager = Feature{V2: "cert_manager", V1: "certManager"}
CrossProjectSecretSharing = Feature{V2: "cross_project_secret_sharing", V1: "crossProjectSecretSharing"}
CustomAlerts = Feature{V2: "custom_alerts", V1: "customAlerts"}
- CustomRateLimits = Feature{V2: "custom_rate_limits", V1: "customRateLimits"}
DynamicSecret = Feature{V2: "dynamic_secret", V1: "dynamicSecret"}
EnforceGoogleSSO = Feature{V2: "enforce_google_sso", V1: "enforceGoogleSSO"}
EnforceMFA = Feature{V2: "enforce_mfa", V1: "enforceMfa"}
@@ -93,7 +92,6 @@ var All = []Feature{
CertManager,
CrossProjectSecretSharing,
CustomAlerts,
- CustomRateLimits,
DynamicSecret,
EnforceGoogleSSO,
EnforceMFA,