Skip to content

move some hardcoded ratelimits for the api to env vars#2332

Merged
notAreYouScared merged 3 commits into
pelican-dev:mainfrom
O2theC:o2thec/more-ratelimit-configs
May 19, 2026
Merged

move some hardcoded ratelimits for the api to env vars#2332
notAreYouScared merged 3 commits into
pelican-dev:mainfrom
O2theC:o2thec/more-ratelimit-configs

Conversation

@O2theC
Copy link
Copy Markdown
Contributor

@O2theC O2theC commented May 13, 2026

while making an app using the api i ran into ratelimits that didn't make sense, turns out there are ratelimits outside of the client and application api rate limits, this moves the ones i found, including the auth and password reset ratelimits to using env vars for configuration .

ideally this would be in admin panel area where the client and application api ratelimits are but i know practically nothing about php, larvel , filament or the other things this project uses. i have programmed a decent amt and it turns combining that with some copy pasting and a linter/syntax checker ends up working out ok.

feel free to suggest better names for the config values, whether for naming conventions or something else

my main concern is that these ratelimits are able to be configured in a docker environment without needing to override the file via docker volume bind

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 13, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0982db4e-ffa7-4efc-974c-a8c7c4b3aa36

📥 Commits

Reviewing files that changed from the base of the PR and between c98f974 and 1800627.

📒 Files selected for processing (1)
  • config/http.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • config/http.php

📝 Walkthrough

Walkthrough

Rate limit values were moved to env-backed entries in config/http.php. Resource and route rate limiters now read periods and limits from that config instead of using hardcoded per-minute values.

Changes

Rate Limit Configuration and Consumption

Layer / File(s) Summary
Rate limit configuration schema
config/http.php
The rate_limit configuration block now sources period and limit values from environment variables (APP_API_*) for client, application, auth, password reset, websocket, backup restore, database create, subuser create, file pull, and default rate limits, with numeric defaults.
Resource-specific rate limiters
app/Enums/ResourceLimit.php
ResourceLimit::limit() replaces hardcoded Limit::perMinute(...) with Limit::perMinutes(...) constructed from http.rate_limit.*_period and http.rate_limit.* for Websocket, BackupRestore, DatabaseCreate, SubuserCreate, and FilePull.
Route-based rate limiters
app/Providers/RouteServiceProvider.php
configureRateLimiting() now reads http.rate_limit.password_reset_period/password_reset for the forgot-password route and http.rate_limit.auth_period/auth for other auth routes; local comment updated to reference env-backed configuration.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: moving hardcoded rate limits to environment variables for API configuration.
Description check ✅ Passed The description is related to the changeset, explaining the motivation for moving rate limits to env vars and the author's context.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@O2theC
Copy link
Copy Markdown
Contributor Author

O2theC commented May 13, 2026

I have read the CLA Document and I hereby sign the CLA

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
config/http.php (1)

4-13: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update the configuration comment to reflect the expanded scope.

The comment still only mentions "client and internal (application) APIs" but the configuration now includes many additional rate limits (auth, password reset, websocket, backup restore, database create, subuser create, file pull, and default). Additionally, it should mention that these values are configurable via environment variables.

📝 Suggested comment update
     /*
     |--------------------------------------------------------------------------
     | API Rate Limits
     |--------------------------------------------------------------------------
     |
-    | Defines the rate limit for the number of requests per minute that can be
-    | executed against both the client and internal (application) APIs over the
-    | defined period (by default, 1 minute).
+    | Defines rate limits for various API endpoints and resources. Each rate
+    | limit consists of a period (in minutes) and a maximum number of requests
+    | allowed within that period. All values can be configured via environment
+    | variables and include sensible defaults.
     |
     */
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@config/http.php` around lines 4 - 13, The comment block above API rate limits
in config/http.php is outdated—update the multi-line comment that documents "API
Rate Limits" to list the full set of rate-limited categories (auth, password
reset, websocket, backup restore, database create, subuser create, file pull,
default, client/internal APIs) and note that each limit is configurable via
environment variables; change the descriptive text in the existing comment block
(the one wrapping the API Rate Limits section) to briefly describe the expanded
scope and mention env var configurability so future readers can find and adjust
limits for keys like auth, password_reset, websocket, backup_restore,
database_create, subuser_create, file_pull and default.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/Providers/RouteServiceProvider.php`:
- Around line 70-76: The default authentication rate limiter defined in
RateLimiter::for('authentication') is missing the per-IP scoping present in the
forgot-password branch; update the default Limit returned from
Limit::perMinutes(config('http.rate_limit.auth_period'),
config('http.rate_limit.auth')) to include ->by($request->ip()) so it is keyed
per client IP (same pattern used when
$request->route()->named('auth.post.forgot-password')).

---

Outside diff comments:
In `@config/http.php`:
- Around line 4-13: The comment block above API rate limits in config/http.php
is outdated—update the multi-line comment that documents "API Rate Limits" to
list the full set of rate-limited categories (auth, password reset, websocket,
backup restore, database create, subuser create, file pull, default,
client/internal APIs) and note that each limit is configurable via environment
variables; change the descriptive text in the existing comment block (the one
wrapping the API Rate Limits section) to briefly describe the expanded scope and
mention env var configurability so future readers can find and adjust limits for
keys like auth, password_reset, websocket, backup_restore, database_create,
subuser_create, file_pull and default.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8f096904-8b79-4ec7-aebe-cd52ca6cf04b

📥 Commits

Reviewing files that changed from the base of the PR and between 11a1581 and 1396ecc.

📒 Files selected for processing (3)
  • app/Enums/ResourceLimit.php
  • app/Providers/RouteServiceProvider.php
  • config/http.php

Comment thread app/Providers/RouteServiceProvider.php
@O2theC
Copy link
Copy Markdown
Contributor Author

O2theC commented May 13, 2026

adjusted some of the comments based on coderabbitai suggestions

@notAreYouScared notAreYouScared requested a review from Boy132 May 19, 2026 09:56
@notAreYouScared notAreYouScared merged commit 8f7dbe5 into pelican-dev:main May 19, 2026
16 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 19, 2026
@Boy132 Boy132 linked an issue May 19, 2026 that may be closed by this pull request
3 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants