mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-06-25 13:32:30 +00:00
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.AuthenticationFailureProviderNotFoundEvent;
|
||||||
import org.springframework.security.authentication.event.AuthenticationFailureProxyUntrustedEvent;
|
import org.springframework.security.authentication.event.AuthenticationFailureProxyUntrustedEvent;
|
||||||
import org.springframework.security.authentication.event.AuthenticationFailureServiceExceptionEvent;
|
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.UsernameNotFoundException;
|
||||||
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl;
|
import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl;
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ class CoreSecurityRuntimeHints implements RuntimeHintsRegistrar {
|
|||||||
registerMethodSecurityHints(hints);
|
registerMethodSecurityHints(hints);
|
||||||
hints.resources().registerResourceBundle("org.springframework.security.messages");
|
hints.resources().registerResourceBundle("org.springframework.security.messages");
|
||||||
registerDefaultJdbcSchemaFileHint(hints);
|
registerDefaultJdbcSchemaFileHint(hints);
|
||||||
|
registerSecurityContextHints(hints);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerMethodSecurityHints(RuntimeHints hints) {
|
private void registerMethodSecurityHints(RuntimeHints hints) {
|
||||||
@ -97,4 +99,9 @@ class CoreSecurityRuntimeHints implements RuntimeHintsRegistrar {
|
|||||||
hints.resources().registerPattern(JdbcDaoImpl.DEFAULT_USER_SCHEMA_DDL_LOCATION);
|
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.AuthenticationFailureProxyUntrustedEvent;
|
||||||
import org.springframework.security.authentication.event.AuthenticationFailureServiceExceptionEvent;
|
import org.springframework.security.authentication.event.AuthenticationFailureServiceExceptionEvent;
|
||||||
import org.springframework.security.core.AuthenticationException;
|
import org.springframework.security.core.AuthenticationException;
|
||||||
|
import org.springframework.security.core.context.SecurityContextImpl;
|
||||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
@ -137,4 +138,10 @@ class CoreSecurityRuntimeHintsTests {
|
|||||||
.forResource("org/springframework/security/core/userdetails/jdbc/users.ddl")).accepts(this.hints);
|
.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…
x
Reference in New Issue
Block a user