Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/api/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,15 @@ const api = {
});
}; // End of processRequest helper function

// Cache-only rate limit check (fast path, no metadata fetch)
// If config is cached, apply rate limiting now
// If not cached, metadata validation functions will handle it
if (request.bucketName && config.rateLimiting?.enabled && !rateLimitApiActions.includes(apiMethod)) {
const applyRateLimit = request.bucketName
&& config.rateLimiting?.enabled
&& !rateLimitApiActions.includes(apiMethod) // Don't limit any rate limit admin actions
&& !request.isInternalServiceRequest; // Don't limit any calls from internal services

if (applyRateLimit) {
// Cache-only rate limit check (fast path, no metadata fetch)
// If config is cached, apply rate limiting now
// If not cached, metadata validation functions will handle it
const cachedConfig = getRateLimitFromCache(request.bucketName);

if (cachedConfig !== undefined) {
Expand Down
3 changes: 2 additions & 1 deletion lib/metadata/metadataUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ function checkRateLimitIfNeeded(bucket, bucketName, request, log, callback) {
// Skip if already checked or not enabled
if (request.rateLimitAlreadyChecked
|| !config.rateLimiting?.enabled
|| rateLimitApiActions.includes(request.apiMethod)) {
|| rateLimitApiActions.includes(request.apiMethod)
|| request.isInternalServiceRequest) {
return process.nextTick(callback, null);
}

Expand Down
1 change: 1 addition & 0 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ class S3Server {
* @returns {undefined}
*/
internalRouteRequest(req, res) {
req.isInternalServiceRequest = true; // eslint-disable-line no-param-reassign
req.bypassUserBucketPolicies = true; // eslint-disable-line no-param-reassign
return this.routeRequest(req, res);
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@zenko/cloudserver",
"version": "9.2.11",
"version": "9.2.12",
"description": "Zenko CloudServer, an open-source Node.js implementation of a server handling the Amazon S3 protocol",
"main": "index.js",
"engines": {
Expand Down
Loading