Repository navigation
fix: ignore trailing # comments in tokens/clients/groups files - #5
Merged
Merged
Conversation
Only whole-line comments were skipped, so `tok acme rw # ci runner` scoped the token to org "runner" and `prompt-admins rw # platform team` issued tokens with org "team". A field starting with # now ends the line, and a second org (or second expiry) is rejected instead of the last one silently winning. Fixes #2 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What was wrong
Only whole-line
#comments were skipped. In a trailing comment every word became a field, and any non-keyword word was taken as the org (last one wins):authn.LoadTokens):<tok> acme rw # ci runner→ token scoped to orgrunner.clients.txt/groups.txt(configLines/parseGrant):prompt-admins rw # platform team(the README's own example) → tokens issued withorg:"team".Fix
#(after the token / client id / group) ends the line.LoadTokensreturns an error;priompt-auth serveexits with<file>: client|group <name>: two orgs (...)).LoadTokensalso rejects two expiries.Tests
New:
TestLoadTokensTrailingComment,TestLoadTokensRejectsExtraFields(authn),TestConfigTrailingComments,TestParseGrantRejectsExtraFields(cmd/priompt-auth).Before the fix (on
main):After:
GOWORK=off go build ./... && go vet ./... && go test ./...Live run:
priompt-auth serve -clients-file clients.txtwithci-bot sha256:… acme rw # ci runner, thenPOST /token(client_credentials), decoded claims:And a line with no
#(ci-bot sha256:abcd acme rw ci runner) now refuses to start:Fixes #2
🤖 Generated with Claude Code