-
Notifications
You must be signed in to change notification settings - Fork 6.2k
Closed
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is validtype: bugA general bugA general bug
Description
Describe the bug
After updating to Spring Security 6.1.4 (as part of Spring Boot 3.1.4), the authentication context is not being populated and SecurityContextHolder.getContext().getAuthentication() returns null.
The issue seems to come from updating this concrete dependency:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>6.1.4</version>
</dependency>
Version 6.1.3 works fine.
After further investigation, it turns out this particular code in our application causes the authentication object to be null, but not sure why:
@Configuration
@EnableMethodSecurity
public class MethodSecurityConfig {
@Bean
static MethodSecurityExpressionHandler methodSecurityExpressionHandler() {
SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
return new DefaultMethodSecurityExpressionHandler();
}
}
Expected behavior
Authentication context should be populated from the HTTP request Authentication header (JWT Bearer token).
The setup is a standard Spring Boot application with Spring MVC and Spring Security (Web Security Config).
Let me know if you need more information.
Regards,
Momchil
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
status: invalidAn issue that we don't feel is validAn issue that we don't feel is validtype: bugA general bugA general bug