feat: add token-authenticated cron trigger for weather refresh#4
Merged
giancarloerra merged 1 commit intomainfrom Mar 10, 2026
Merged
feat: add token-authenticated cron trigger for weather refresh#4giancarloerra merged 1 commit intomainfrom
giancarloerra merged 1 commit intomainfrom
Conversation
Add public POST /api/weather/refresh/trigger?key=… endpoint so external cron services (cron-job.org, GitHub Actions) can trigger weather refresh without session auth. Key is generated from Settings UI, stored as SHA-256 hash in Redis, and rate-limited separately (3 req/min).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a public, token-authenticated trigger endpoint for external cron services to refresh weather data without needing session/cookie auth.
Motivation
The
POST /api/weather/refreshendpoint sits behindrequireAuth, which requires a session cookie. External cron services like cron-job.org and GitHub Actions cannot send cookies, so scheduled weather refreshes fail whenMASTER_PASSWORDis enabled.Changes
POST /api/weather/refresh/trigger?key=…— public endpoint placed beforerequireAuth, validated by a high-entropy token (SHA-256 hashed, constant-time comparison)GET/POST/DELETE /api/settings/cron-token— protected endpoints to manage the trigger key (generate, rotate, revoke)CRON_TRIGGER_TOKENenv var override (consistent with other API key patterns)/api/settingsresponse withcronTriggerstatus.env.examplewithCRON_TRIGGER_TOKENTesting
npm run lintpassesnpm run typecheckpassesnpm testpassesBreaking changes
No breaking changes. Existing
POST /api/weather/refresh(manual/UI) is unchanged. The new trigger endpoint is additive.Screenshots (if applicable)