Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds hints for Authentication manager #12366

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
import java.util.List;
import java.util.stream.Stream;

import org.springframework.aop.SpringProxy;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdeleuze Should we move SpringProxy, Advised and DecoratingProxy to the Spring Framework ? They can be useful for other

import org.springframework.aop.framework.Advised;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.core.DecoratingProxy;
import org.springframework.security.access.expression.SecurityExpressionOperations;
import org.springframework.security.access.expression.SecurityExpressionRoot;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.authentication.AccountExpiredException;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.CredentialsExpiredException;
Expand All @@ -49,6 +53,7 @@
* {@link RuntimeHintsRegistrar} for core classes
*
* @author Marcus Da Coregio
* @author Nikita Konev
* @since 6.0
*/
class CoreSecurityRuntimeHints implements RuntimeHintsRegistrar {
Expand All @@ -61,6 +66,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
hints.resources().registerResourceBundle("org.springframework.security.messages");
registerDefaultJdbcSchemaFileHint(hints);
registerSecurityContextHints(hints);
registerJdkProxyHints(hints);
}

private void registerMethodSecurityHints(RuntimeHints hints) {
Expand Down Expand Up @@ -104,4 +110,9 @@ private void registerSecurityContextHints(RuntimeHints hints) {
(builder) -> builder.withMembers(MemberCategory.INVOKE_PUBLIC_METHODS));
}

private void registerJdkProxyHints(RuntimeHints hints) {
hints.proxies().registerJdkProxy(AuthenticationManager.class, SpringProxy.class, Advised.class,
DecoratingProxy.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;

import org.springframework.aop.SpringProxy;
import org.springframework.aop.framework.Advised;
import org.springframework.aot.hint.MemberCategory;
import org.springframework.aot.hint.RuntimeHints;
import org.springframework.aot.hint.RuntimeHintsRegistrar;
import org.springframework.aot.hint.TypeReference;
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
import org.springframework.core.DecoratingProxy;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.security.access.expression.SecurityExpressionOperations;
import org.springframework.security.access.expression.SecurityExpressionRoot;
import org.springframework.security.authentication.AbstractAuthenticationToken;
import org.springframework.security.authentication.AccountExpiredException;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.AuthenticationServiceException;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.authentication.CredentialsExpiredException;
Expand All @@ -59,6 +63,7 @@
* Tests for {@link CoreSecurityRuntimeHints}
*
* @author Marcus Da Coregio
* @author Nikita Konev
*/
class CoreSecurityRuntimeHintsTests {

Expand Down Expand Up @@ -144,4 +149,10 @@ void securityContextHasHints() {
.withMemberCategories(MemberCategory.INVOKE_PUBLIC_METHODS)).accepts(this.hints);
}

@Test
void authenticationManagerHasHints() {
assertThat(RuntimeHintsPredicates.proxies().forInterfaces(AuthenticationManager.class, SpringProxy.class,
Advised.class, DecoratingProxy.class)).accepts(this.hints);
}

}