Conversation
This changes micronaut-security-jwt and oauth2 to depend on Micronaut Validation instead of just depending on `jakarta.validation-api`. The changes uses the `@URL` annotation from Micronaut validation to reject invalid JWKS and OAuth endpoint URLs during configuration binding. This enforces absolute HTTP(S) URLs across OAuth endpoint settings and OpenID JWKS URIs, wires nested endpoint validation, and updates tests and dependencies to cover accepted and rejected URL values. Close: #2245 Close: #2179
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR moves OAuth2 and JWT modules from relying on jakarta.validation-api to using Micronaut Validation so invalid OAuth endpoint URLs and JWKS URIs are rejected early during configuration binding.
Changes:
- Add Micronaut
@URLvalidation to OAuth endpoint configuration URLs and OpenIDjwks-uri, and cascade validation into nested endpoint configs via@Valid. - Add/adjust tests to cover accepted and rejected URL values (OAuth2 + JWKS signature configuration).
- Update module dependencies to use
mnValidation.micronaut.validationand bump the Micronaut platform version catalog.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| security-oauth2/src/test/java/io/micronaut/security/oauth2/configuration/OauthClientConfigurationTest.java | Adds validation-focused tests for OAuth endpoint URLs and OpenID JWKS URI. |
| security-oauth2/src/test/groovy/io/micronaut/security/oauth2/client/condition/PasswordGrantConditionSpec.groovy | Fixes a previously-invalid OpenID token URL test input to match new URL validation. |
| security-oauth2/src/main/java/io/micronaut/security/oauth2/configuration/OauthClientConfigurationProperties.java | Cascades validation into nested endpoint configuration and validates openid.jwks-uri. |
| security-oauth2/src/main/java/io/micronaut/security/oauth2/configuration/OauthClientConfiguration.java | Minor formatting/indent adjustment (no behavioral change). |
| security-oauth2/src/main/java/io/micronaut/security/oauth2/configuration/endpoints/EndpointConfiguration.java | Adds @URL constraint to the endpoint URL contract and provides a shared http/https regex. |
| security-oauth2/build.gradle.kts | Switches to Micronaut Validation as an API dependency for oauth2 module. |
| security-jwt/src/test/java/io/micronaut/security/token/jwt/signature/jwks/JwksSignatureConfigurationPropertiesTest.java | Adds coverage ensuring invalid JWKS signature URLs fail during context startup/binding. |
| security-jwt/src/test/groovy/io/micronaut/security/token/jwt/signature/jwks/JwksProxySpec.groovy | Updates JWKS URL test configuration to use an absolute URL. |
| security-jwt/src/main/java/io/micronaut/security/token/jwt/signature/jwks/JwksSignatureConfigurationProperties.java | Adds @URL validation to the configured JWKS signature URL. |
| security-jwt/build.gradle.kts | Switches to Micronaut Validation as an API dependency for jwt module. |
| gradle/libs.versions.toml | Bumps micronaut-platform version to 5.0.4. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
|
@dstepanov I am a bit worried about making Micronaut Validation a dependency of security. Unfortunately, Micronaut Validation annotations are not in a separate dependency. |
| * @since 1.2.0 | ||
| */ | ||
| public interface EndpointConfiguration { | ||
| String HTTP_OR_HTTPS_URL_REGEX = "(?i)https?://.*"; |
There was a problem hiding this comment.
probably worth adding javadoc to this public constant
| private @Valid RegistrationEndpointConfigurationProperties registration; | ||
| private @Valid UserInfoEndpointConfigurationProperties userInfo; | ||
| private @Valid AuthorizationEndpointConfigurationProperties authorization; | ||
| private @Valid TokenEndpointConfigurationProperties token; | ||
| private @Valid EndSessionConfigurationProperties endSession = new EndSessionConfigurationProperties(); |
There was a problem hiding this comment.
since this cascades validation down, maybe you want to add more tests for different validation use cases



This changes
micronaut-security-jwtandmicronaut-security-oauth2to depend on Micronaut Validation instead of just depending onjakarta.validation-api.The changes uses the
@URLannotation from Micronaut validation to reject invalid JWKS and OAuth endpoint URLs during configuration binding. This enforces absolute HTTP(S) URLs across OAuth endpoint settings and OpenID JWKS URIs, wires nested endpoint validation, and updates tests and dependencies to cover accepted and rejected URL values.Close: #2245
Close: #2179