Allow cookie token reading without cookie auth mode - #2204
Open
sdelamo wants to merge 2 commits into
Open
Conversation
Co-Authored-By: Paperclip <noreply@paperclip.ing>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR decouples access-token cookie reading from the Cookie/IDToken authentication mode, allowing services to opt-in to cookie token consumption via configuration without also enabling cookie login/logout handlers.
Changes:
- Introduces a new
TokenCookieEnabledConditionthat enables cookie token reading when either cookie/idtoken auth mode is active ormicronaut.security.token.cookie.enabled=trueis explicitly set. - Updates
CookieTokenReaderandTokenCookieConfigurationPropertiesto use the new condition instead ofCookieBasedAuthenticationModeCondition. - Documents the independent opt-in and adds test coverage verifying the reader/configuration can load without cookie auth mode while login/logout handlers remain disabled.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/docs/guide/securityFilter/builtInAuthenticationFetchers/tokenAuthenticationFetcher/tokenReaders/cookieTokenReader.adoc | Documents explicit opt-in for cookie token reading independent of cookie auth mode. |
| src/main/docs/guide/authenticationStrategies/jwt/reader/cookieToken.adoc | Adds documentation noting micronaut.security.token.cookie.enabled=true enables reading without cookie login/logout handlers. |
| security/src/main/java/io/micronaut/security/token/cookie/TokenCookieEnabledCondition.java | Adds a condition to gate cookie token reading by cookie auth mode or explicit enablement. |
| security/src/main/java/io/micronaut/security/token/cookie/TokenCookieConfigurationProperties.java | Switches config properties bean gating to the new condition. |
| security/src/main/java/io/micronaut/security/token/cookie/CookieTokenReader.java | Switches token reader bean gating to the new condition. |
| security-jwt/src/test/groovy/io/micronaut/security/token/jwt/cookie/CookieEnabledSpec.groovy | Adds tests for explicit opt-in without cookie auth mode and ensures login/logout handlers remain disabled. |
Co-Authored-By: Paperclip <noreply@paperclip.ing>
|
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.



Fixes #962
Summary
micronaut.security.token.cookie.enabled=trueis explicitly setValidation
./gradlew :micronaut-security:compileJava :micronaut-security-jwt:test --tests io.micronaut.security.token.jwt.cookie.CookieEnabledSpec --no-daemon./gradlew :micronaut-security:checkstyleMain --no-daemon(build successful; existing generated descriptor Javadoc warning remains)Release Metadata
5.1.x5.1.05.1.0 Release✨ This message was AI-generated using gpt-5.5