Add hints to invoke SecurityContextImpl#getAuthentication
Closes gh-11987
This commit is contained in:
parent
6026f9f70f
commit
db7f52db4e
|
@ -41,6 +41,7 @@ import org.springframework.security.authentication.event.AuthenticationFailureLo
|
|||
import org.springframework.security.authentication.event.AuthenticationFailureProviderNotFoundEvent;
|
||||
import org.springframework.security.authentication.event.AuthenticationFailureProxyUntrustedEvent;
|
||||
import org.springframework.security.authentication.event.AuthenticationFailureServiceExceptionEvent;
|
||||
import org.springframework.security.core.context.SecurityContextImpl;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl;
|
||||
|
||||
|
@ -59,6 +60,7 @@ class CoreSecurityRuntimeHints implements RuntimeHintsRegistrar {
|
|||
registerMethodSecurityHints(hints);
|
||||
hints.resources().registerResourceBundle("org.springframework.security.messages");
|
||||
registerDefaultJdbcSchemaFileHint(hints);
|
||||
registerSecurityContextHints(hints);
|
||||
}
|
||||
|
||||
private void registerMethodSecurityHints(RuntimeHints hints) {
|
||||
|
@ -97,4 +99,9 @@ class CoreSecurityRuntimeHints implements RuntimeHintsRegistrar {
|
|||
hints.resources().registerPattern(JdbcDaoImpl.DEFAULT_USER_SCHEMA_DDL_LOCATION);
|
||||
}
|
||||
|
||||
private void registerSecurityContextHints(RuntimeHints hints) {
|
||||
hints.reflection().registerType(SecurityContextImpl.class,
|
||||
(builder) -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ import org.springframework.security.authentication.event.AuthenticationFailurePr
|
|||
import org.springframework.security.authentication.event.AuthenticationFailureProxyUntrustedEvent;
|
||||
import org.springframework.security.authentication.event.AuthenticationFailureServiceExceptionEvent;
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.core.context.SecurityContextImpl;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
@ -137,4 +138,10 @@ class CoreSecurityRuntimeHintsTests {
|
|||
.forResource("org/springframework/security/core/userdetails/jdbc/users.ddl")).accepts(this.hints);
|
||||
}
|
||||
|
||||
@Test
|
||||
void securityContextHasHints() {
|
||||
assertThat(RuntimeHintsPredicates.reflection().onType(SecurityContextImpl.class)
|
||||
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS)).accepts(this.hints);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue