feat(spiffeid): accept case-insensitive scheme and normalize trust domain#376
Open
maxlambrecht wants to merge 4 commits into
Open
feat(spiffeid): accept case-insensitive scheme and normalize trust domain#376maxlambrecht wants to merge 4 commits into
maxlambrecht wants to merge 4 commits into
Conversation
…main Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
…verage Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
Signed-off-by: Max Lambrecht <maxlambrecht@gmail.com>
e95aa4b to
b8aac6e
Compare
There was a problem hiding this comment.
Pull request overview
Updates the SPIFFE ID parsing/canonicalization behavior in spiffeid to align with the SPIFFE spec by accepting case-insensitive scheme + trust domain input and emitting a canonical lowercase trust domain (while preserving path bytes/case).
Changes:
- Accept case-insensitive
spiffe://scheme during parsing. - Normalize trust domain to lowercase in parsed/canonical IDs and TrustDomain parsing.
- Expand/adjust unit tests around canonicalization behavior and additional authority/path edge cases.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spiffeid/trustdomain.go | Normalizes trust domain input to lowercase for TrustDomainFromString. |
| spiffeid/trustdomain_test.go | Adds coverage for case-insensitive scheme/trust domain and additional authority shapes. |
| spiffeid/require_test.go | Updates RequireTrustDomainFromString expectations for mixed-case inputs. |
| spiffeid/path_test.go | Adds tests for additional path/path-segment validation cases. |
| spiffeid/id.go | Accepts case-insensitive scheme and canonicalizes trust domain to lowercase in FromString. |
| spiffeid/id_test.go | Adds tests for canonicalization/equality and expanded parsing behaviors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+55
to
58
| case len(id) < schemePrefixLen: | ||
| return ID{}, errWrongScheme | ||
| case !strings.EqualFold(id[:schemePrefixLen], schemePrefix): | ||
| return ID{}, errWrongScheme |
Comment on lines
+70
to
+75
| tdNorm := strings.ToLower(id[schemePrefixLen:pathidx]) | ||
| for i := 0; i < len(tdNorm); i++ { | ||
| if !isValidTrustDomainChar(tdNorm[i]) { | ||
| return ID{}, errBadTrustDomainChar | ||
| } | ||
| } |
Comment on lines
+32
to
36
| name := strings.ToLower(idOrName) | ||
| for i := 0; i < len(name); i++ { | ||
| if !isValidTrustDomainChar(name[i]) { | ||
| return TrustDomain{}, errBadTrustDomainChar | ||
| } |
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
Aligns SPIFFE ID parsing with SPIFFE spec: