Host identity SCEP rate limit. - #31038
Conversation
📝 WalkthroughWalkthroughThis change adds a rate limit to the SCEP certificate enrollment endpoint, ensuring hosts cannot request certificates too frequently. It introduces a cooldown period, stores certificate creation timestamps, updates error handling to return HTTP 429 on rate limiting, and includes integration tests to verify correct behavior. Changes
Sequence Diagram(s)sequenceDiagram
participant Host as Host
participant SCEP as SCEP Endpoint
participant Depot as HostIdentitySCEPDepot
participant DB as Database
Host->>SCEP: Request SCEP certificate (CSR)
SCEP->>Depot: Store certificate for host
Depot->>DB: Check for existing certificate by host
DB-->>Depot: Return existing certificate (with CreatedAt)
Depot-->>SCEP: Return error if within cooldown, else proceed
alt Within cooldown
SCEP-->>Host: HTTP 429 Too Many Requests
else Not within cooldown
Depot->>DB: Store new certificate
SCEP-->>Host: Return issued certificate
end
Possibly related PRs
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (8)
🧰 Additional context used🧠 Learnings (7)server/datastore/mysql/host_identity_scep.go (2)cmd/fleet/serve.go (4)server/datastore/mysql/mysql.go (3)ee/server/service/hostidentity/scep.go (3)ee/server/integrationtest/hostidentity/suite.go (2)ee/server/service/hostidentity/depot/depot.go (3)ee/server/integrationtest/hostidentity/scep_rate_limit_test.go (1)🧬 Code Graph Analysis (1)cmd/fleet/serve.go (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
🔇 Additional comments (16)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #31038 +/- ##
========================================
Coverage 64.32% 64.33%
========================================
Files 1892 1893 +1
Lines 185748 186082 +334
Branches 5354 5354
========================================
+ Hits 119483 119714 +231
- Misses 56892 56977 +85
- Partials 9373 9391 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
Fixes #30989
Checklist for submitter
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Chores