feat: add compatability with gatus security.basic#21
Conversation
|
@z0xca is attempting to deploy a commit to the Sparanoid Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
Next review available in: 45 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. 📝 WalkthroughWalkthroughAdds optional ChangesGatus API Basic Auth
Estimated code review effort: 2 (Simple) | ~10 minutes Sequence Diagram(s)sequenceDiagram
participant getStatuses
participant Env as process.env
participant GatusAPI
getStatuses->>Env: read GATUS_API_USERNAME, GATUS_API_PASSWORD
alt credentials present
getStatuses->>getStatuses: base64 encode username:password
getStatuses->>GatusAPI: fetch with Authorization header
else credentials absent
getStatuses->>GatusAPI: fetch with User-Agent header only
end
Related Issues: None specified. Related PRs: None specified. Suggested labels: documentation, enhancement Suggested reviewers: sparanoid 🐰 A carrot of credentials, base64 tucked in tight, 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
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. Comment |
PR Summary by QodoAdd optional Basic Auth when querying Gatus API
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Code Review by Qodo
1.
|
Greptile SummaryThis PR adds HTTP Basic authentication support for protected Gatus API instances by reading
Confidence Score: 5/5Safe to merge — the auth header is constructed entirely server-side from env vars, credentials are never exposed to the client, and the change is well-scoped to a single fetch utility. The implementation is straightforward: Buffer.from(user:pass).toString('base64') is the correct way to produce a Basic auth token in Node.js, the explicit Record<string, string> type addresses the prior type-safety concern, and the guard correctly skips auth when credentials are absent. No regressions to existing behaviour. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "Update lib/getStatuses.ts" | Re-trigger Greptile |
| if (GATUS_API_USERNAME && GATUS_API_PASSWORD) { | ||
| headers.Authorization = `Basic ${Buffer.from(`${GATUS_API_USERNAME}:${GATUS_API_PASSWORD}`).toString("base64")}`; | ||
| } |
There was a problem hiding this comment.
Silent auth skip with partial credentials
If a user sets GATUS_API_USERNAME but forgets GATUS_API_PASSWORD (or vice versa), no Authorization header is sent and the request will silently return a 401 from Gatus (surfaced only as the generic 'Failed to fetch data' error). A console warning when exactly one variable is present would make misconfiguration much easier to diagnose.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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 @.env.example:
- Around line 25-27: The GATUS credential entries in the env template are in the
wrong order for dotenv-linter. Reorder the two variables in the .env.example
block so the password key comes before the username key, keeping the existing
names and values empty; this is the only change needed.
In `@lib/getStatuses.ts`:
- Around line 13-23: The headers object in getStatuses is being mutated after
being declared as HeadersInit, which does not support direct property assignment
for Authorization. Update the getStatuses function to build headers as a mutable
Record<string, string> (or use a Headers instance and call set()), then keep the
existing Basic auth assignment and fetch call using that same headers variable.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c1959d2e-462e-4d35-b5f1-b7f33789ddcd
📒 Files selected for processing (3)
.env.exampleREADME.mdlib/getStatuses.ts
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This PR adds the ability for STS to authenticate with Gatus via security.basic, which is useful for people that want to only expose STS publicly and not Gatus
Summary by CodeRabbit
New Features
Documentation