feat(auth): enforce username uniqueness at startup and config reload#268
Merged
feat(auth): enforce username uniqueness at startup and config reload#268
Conversation
Add ValidateUsernameUniqueness() to reject farmer configs where two or more pubkeys share the same username. Duplicate usernames would make audit logs ambiguous and prevent reliable identification. Validation runs in LoadPolicy() alongside the existing pubkey uniqueness check, catching duplicates both at farmer startup and on SIGHUP config reload. Empty/missing usernames are ignored (only explicitly set usernames are checked). - Add ErrDuplicateUsername sentinel error - Add ValidateUsernameUniqueness() in internal/rbac/config.go - Wire into auth.LoadPolicy() in internal/auth/auth.go - Add 6 unit tests for the validator (cross-role, same-role, empty, mixed, no config) - Add 2 integration tests for LoadPolicy (reject/accept)
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
Adds validation to reject farmer configs where two or more pubkeys share the same username. Duplicate usernames make audit logs ambiguous — this catches the misconfiguration early.
Changes
internal/rbac/config.go: AddErrDuplicateUsernamesentinel error andValidateUsernameUniqueness()function that scans theusersconfig section for duplicate username assignments across all roles.internal/auth/auth.go: WireValidateUsernameUniqueness()intoLoadPolicy(), which runs at farmer startup and on SIGHUP config reload.Behavior
Config example that would be rejected