Add configurable role case sensitivity - #2192
Open
sdelamo wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new security configuration toggle to control whether role comparisons are case-sensitive, defaulting to current behavior (case-sensitive) while enabling an opt-in case-insensitive mode for authorization checks.
Changes:
- Introduces
micronaut.security.roles-case-sensitive(defaulttrue) viaSecurityConfiguration/SecurityConfigurationProperties. - Updates
DefaultRolesFinderto optionally perform case-insensitive role matching (affecting@Secured, intercept URL map rules, andSecurityService.hasRole). - Adds focused Spock tests and updates the security configuration guide documentation.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/docs/guide/securityConfiguration.adoc | Documents the new micronaut.security.roles-case-sensitive toggle and its effect on role comparisons. |
| security/src/main/java/io/micronaut/security/config/SecurityConfiguration.java | Adds a new isRolesCaseSensitive() configuration API (default true). |
| security/src/main/java/io/micronaut/security/config/SecurityConfigurationProperties.java | Binds the new rolesCaseSensitive property with default true. |
| security/src/main/java/io/micronaut/security/token/DefaultRolesFinder.java | Uses the new configuration to switch between case-sensitive vs case-insensitive role matching. |
| security/src/test/groovy/io/micronaut/security/config/SecurityConfigurationPropertiesSpec.groovy | Verifies default and configured values for rolesCaseSensitive. |
| security/src/test/groovy/io/micronaut/security/rules/ConfigurationInterceptUrlMapRuleSpec.groovy | Extends role comparison tests and validates case-insensitive behavior for intercept URL map rules. |
| security/src/test/groovy/io/micronaut/security/authorization/SecuredRolesCaseInsensitiveConfigurationSpec.groovy | Adds an embedded-server spec validating case-insensitive @Secured and SecurityService.hasRole. |
sdelamo
force-pushed
the
paperclip/mng-226-roles-case-sensitive
branch
from
May 22, 2026 10:25
b6c39f2 to
d916703
Compare
sdelamo
force-pushed
the
paperclip/mng-226-roles-case-sensitive
branch
from
May 22, 2026 11:12
d916703 to
aef5435
Compare
|
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
micronaut.security.roles-case-sensitive, defaulting totrueso existing role checks remain case-sensitive.micronaut.security.roles-case-sensitive=falseopt the defaultDefaultRolesFinderinto case-insensitive role comparison for@Secured, intercept URL maps, andSecurityService.hasRole.DefaultRolesFinder(TokenConfiguration)constructor behavior and adds focused tests plus security configuration guide documentation.Verification
./gradlew --no-build-cache :micronaut-security:compileJava :micronaut-security:spotlessCheck./gradlew :micronaut-security:test --tests 'io.micronaut.security.token.DefaultRolesFinderSpec' --tests 'io.micronaut.security.config.SecurityConfigurationPropertiesSpec' --tests 'io.micronaut.security.authorization.SecuredRolesCaseSensitiveSpec' --tests 'io.micronaut.security.authorization.SecuredRolesCaseInsensitiveConfigurationSpec' --tests 'io.micronaut.security.rules.ConfigurationInterceptUrlMapRuleSpec'Focused test result: 28 tests, 28 successes, 0 failures, 0 skipped.
Release Metadata
5.1.x5.1.05.1.0 ReleaseCloses #327.
✨ This message was AI-generated using gpt-5