fix: tolerate trailing slash when matching trusted issuers#1274
fix: tolerate trailing slash when matching trusted issuers#1274telegraphchi wants to merge 4 commits into
Conversation
The JWT authenticator matched the token's "iss" claim against the configured trusted_issuers using an exact string comparison. Otherwise-valid tokens were therefore rejected whenever the configuration and the token disagreed on a trailing slash (e.g. "https://issuer" vs "https://issuer/"). Compare issuers with a single trailing slash trimmed from both sides so the two forms are treated as equivalent, while genuinely different issuers are still rejected. Adds verifier tests for both trailing-slash directions and a negative case. Closes ory#527 Signed-off-by: Mohamad Reza Chegini <mrchcoin@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
📝 WalkthroughWalkthrough
ChangesIssuer trailing-slash normalization
JSONPatch operation documentation
Docker build module file copying
Estimated code review effort🎯 2 (Simple) | ⏱️ ~15 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
The failing The
So the failure reproduces on any PR that relies on the un-pushed local tag, independent of the diff — this change touches no Locally |
The opAllowList in patch.go permits only add, remove, and replace. The JSONPatch.Op comment previously listed all six RFC 6902 ops, which implied unsupported ones (move, copy, test) were valid.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
oryx/openapix/jsonpatch.go (1)
36-41:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAlign
Fromfield docs with the supported operation subset.Line 36 still says
Fromis used with"move", but Line 15 and runtime validation only allow"add","remove", and"replace". Please update this comment (or markFromas currently unsupported/legacy) to avoid contradictory API docs.🤖 Prompt for 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. In `@oryx/openapix/jsonpatch.go` around lines 36 - 41, Update the comment documentation for the `From` field to accurately reflect the supported JSON Patch operations. The current comment states that this field is used with the "move" operation, but based on the operation validation at line 15 and runtime checks, only "add", "remove", and "replace" operations are actually supported. Either remove the reference to the "move" operation from the comment or clarify that the `From` field is currently unsupported or legacy to align the documentation with the actual implementation.
🤖 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.
Outside diff comments:
In `@oryx/openapix/jsonpatch.go`:
- Around line 36-41: Update the comment documentation for the `From` field to
accurately reflect the supported JSON Patch operations. The current comment
states that this field is used with the "move" operation, but based on the
operation validation at line 15 and runtime checks, only "add", "remove", and
"replace" operations are actually supported. Either remove the reference to the
"move" operation from the comment or clarify that the `From` field is currently
unsupported or legacy to align the documentation with the actual implementation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 149e8e4a-b2d3-4cfb-b862-7699d8f688fa
📒 Files selected for processing (1)
oryx/openapix/jsonpatch.go
The replace directives in go.mod point to ./middleware/rpctest and
./oryx. go mod download needs the go.mod and go.sum for each replaced
module to resolve dependencies, but only oryx/go.mod was copied and
oryx/go.sum was being written to the wrong path (proto/go.sum).
Add the missing middleware/rpctest/go.{mod,sum} COPY steps and fix
the oryx/go.sum destination so the scanner Docker build succeeds.
The From field references "move" in its comment, but move and copy are not in the opAllowList. Clarify that From is not used by the currently supported operations (add, remove, replace).
What
Make trusted-issuer matching tolerant of a trailing slash, so a token whose
issclaim and the configuredtrusted_issuersdiffer only by a trailing/is no longer rejected.Why
Issuer matching in
credentials/verifier_default.goused an exact string comparison:This rejects otherwise-valid tokens when the configuration and the token disagree on a trailing slash — e.g.
trusted_issuers: ["https://issuer/"]with a token carryingiss: "https://issuer"(and vice versa). That is the symptom reported in #527.How
A small helper trims a single trailing slash from both the token issuer and each trusted issuer before comparing. Genuinely different issuers are still rejected.
Tests
Added three cases to
TestVerifierDefault:go test ./credentials/ ./pipeline/authn/passes;gofmtandgo vetare clean.Closes #527
Summary by CodeRabbit
/.opfield documentation to reflect onlyadd,remove, andreplace.