Add Username Remapping & Uppercase Group Names Support in OAuth2 Authentication Filter #410
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.
This pull request introduces two new features and some refactoring improvements in the OAuth2 authentication filter:
New Features
Username Remapping from idToken Claims:
idToken
only once using a helper (JWTHelper
).principalKey
anduniqueUsername
, and the incoming username (from the principal claim) matches the expected value, it is remapped to the value found in the unique username claim.Enforce Uppercase Group Names:
groupNamesUppercase
has been added.Changes in Code and Tests
Refactoring:
The code has been refactored so that idToken decoding/validation is done only once, and the result is reused for username remapping.
Updated addAuthoritiesFromToken:
This method now checks the configuration for groupNamesUppercase and uses uppercase for group lookup/insertion if enabled. Users are correctly assigned to these groups.
Unit Tests:
Documentation
New configuration parameters have been introduced and should be documented in our developer guide or configuration reference:
principalKey
:The name of the claim in the idToken that represents the principal (original username).
uniqueUsername
:The name of the claim in the idToken that contains the unique username. If the incoming username matches the value from principalKey, it will be replaced with this unique username.
groupNamesUppercase
:A boolean flag that, when enabled, forces the filter to convert group names from token claims to uppercase before lookup or creation. This parameter helps maintain consistency in group names and prevents issues related to case sensitivity.
Please review the changes and tests, and let me know if further modifications are needed.