fix(auth): warn at startup when HFS_AUTH_AUDIENCE is unset#266
Open
smunini wants to merge 1 commit into
Open
Conversation
Auth requires an issuer at boot to prevent cross-service token reuse, but audience stays optional, and with it unset every token from that issuer is accepted -- including tokens minted for a different client of the same issuer. That is the same reuse the issuer check guards against, one level finer. Audience stays optional so an open demo deployment keeps working; the absence is now logged at WARN instead of appearing as an unremarkable `audience=None` on the info-level "Authentication ENABLED" line, so an operator who forgot the variable in production has something they will actually notice.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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.
Follow-up from the security review of #229.
Auth requires an issuer at boot (
main.rs, "Require issuer validation to prevent cross-service token reuse"), but audience stays optional. WithHFS_AUTH_AUDIENCEunset,validate_audisfalseand every token from the configured issuer is accepted — including tokens minted for a different client of the same issuer. That is the same cross-service reuse the issuer check guards against, one level finer.Why a warning and not a hard failure
Audience must stay optional: an open demo deployment relies on accepting any token from its issuer, and requiring the variable at boot would break that. Today the absence is invisible — it appears as an unremarkable
audience=Noneon the info-level "Authentication ENABLED" line — so an operator who simply forgot the variable in production has nothing to notice.This logs it at
WARNinstead. Demo mode keeps working; the production misconfiguration gets loud.Verified by running the binary
HFS_AUTH_ENABLED=false(open demo)Authentication is DISABLED, no new warningHFS_AUTH_AUDIENCEHFS_AUTH_AUDIENCE=hfs-api