Skip to content

Commit 9fe8949

Browse files
florian42jzheaux
authored andcommitted
Add @transient to OAuth2IntrospectionAuthenticationToken
fixes gh-6829
1 parent e159223 commit 9fe8949

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

config/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/resource/OAuth2ResourceServerConfigurerTests.java

+16
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,22 @@ public void requestWhenDefaultConfiguredThenSessionIsNotCreated()
564564
assertThat(result.getRequest().getSession(false)).isNull();
565565
}
566566

567+
@Test
568+
public void requestWhenIntrospectionConfiguredThenSessionIsNotCreated()
569+
throws Exception {
570+
571+
this.spring.register(RestOperationsConfig.class, OpaqueTokenConfig.class, BasicController.class).autowire();
572+
mockRestOperations(json("Active"));
573+
574+
MvcResult result = this.mvc.perform(get("/authenticated")
575+
.with(bearerToken("token")))
576+
.andExpect(status().isOk())
577+
.andExpect(content().string("test-subject"))
578+
.andReturn();
579+
580+
assertThat(result.getRequest().getSession(false)).isNull();
581+
}
582+
567583
@Test
568584
public void requestWhenUsingDefaultsAndNoBearerTokenThenSessionIsCreated()
569585
throws Exception {

oauth2/oauth2-resource-server/src/main/java/org/springframework/security/oauth2/server/resource/authentication/OAuth2IntrospectionAuthenticationToken.java

+2
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import org.springframework.security.core.GrantedAuthority;
2424
import org.springframework.security.core.SpringSecurityCoreVersion;
25+
import org.springframework.security.core.Transient;
2526
import org.springframework.security.oauth2.core.OAuth2AccessToken;
2627
import org.springframework.util.Assert;
2728

@@ -36,6 +37,7 @@
3637
* @author Josh Cummings
3738
* @since 5.2
3839
*/
40+
@Transient
3941
public class OAuth2IntrospectionAuthenticationToken
4042
extends AbstractOAuth2TokenAuthenticationToken<OAuth2AccessToken> {
4143

0 commit comments

Comments
 (0)