Repository navigation
feat: accept ordered list of claim names for OIDC username and group claims - #66
Merged
philipgough merged 2 commits intoOct 1, 2026
Conversation
Accept an ordered list of claim names for username_claim and group_claim, trying each in order of preference and using the first match. A single string value still works (backward compatible). - Add StringOrSlice custom type with UnmarshalJSON and MarshalJSON that accepts both "string" and ["list"] JSON forms - Add mapstructure decode hook for StringOrSlice conversion - Update oidcConfig to use StringOrSlice for UsernameClaim/GroupClaim - Refactor checkAuth to iterate claim lists with first-match-wins - Add safety gate: at least one of username or group must match when both claim lists are configured - Update main.go legacy tenant struct for list support via YAML config - Add 7 new test scenarios for claim list behavior (first match, second match, no match, mixed lists) plus 4 StringOrSlice unit tests - All 10 existing test scenarios continue to pass (backward compat) Implements: RHOBS-1795 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
moadz
approved these changes
Oct 1, 2026
|
|
||
| switch v := data.(type) { | ||
| case string: | ||
| return []string{v}, nil |
There was a problem hiding this comment.
is it safer here to just return StringOrSlice{v} ?
Author
There was a problem hiding this comment.
Fixed in d06225b — both conversions are now explicit: StringOrSlice{v} and StringOrSlice(result). Thanks for the review!
AI-generated. Review for accuracy.
| result[i] = s | ||
| } | ||
|
|
||
| return result, nil |
There was a problem hiding this comment.
nit: same as above, instead of implicit conversion we can StringOrSlice(result)
Co-Authored-By: Claude Opus 4.6 <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.
Accept an ordered list of claim names for
username_claimandgroup_claim,trying each in order of preference and using the first match. This enables
multi-tenant OIDC setups where different IdPs use different claim names for
the same concept.
Config (backward compatible)
Implementation
UnmarshalJSON/MarshalJSON— accepts both"string"and["list"]in JSON/YAML configTests (21 total, all pass with -race)
Verification
go test -v -race ./authentication/...✅ 21/21 passmake build✅make test --always-make✅make lint --always-make✅make generate validate✅Ref: RHOBS-1795
AI-generated. Review for accuracy.
@philipgough requested from Slack