Register Authorization Proxied Type

Closes gh-16106
This commit is contained in:
Josh Cummings 2024-11-15 15:07:09 -07:00
parent 8971fb953d
commit 69cbe12a7b
No known key found for this signature in database
GPG Key ID: A306A51F43B8E5A5
3 changed files with 8 additions and 5 deletions

View File

@ -119,8 +119,10 @@ public final class AuthorizeReturnObjectHintsRegistrar implements SecurityHintsR
}
if (SpringProxy.class.isAssignableFrom(proxied)) {
hints.reflection()
.registerType(proxied, MemberCategory.INVOKE_PUBLIC_METHODS, MemberCategory.PUBLIC_FIELDS,
MemberCategory.DECLARED_FIELDS);
.registerType(clazz, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS)
.registerType(proxied, MemberCategory.INVOKE_DECLARED_CONSTRUCTORS,
MemberCategory.INVOKE_DECLARED_METHODS, MemberCategory.DECLARED_FIELDS);
}
}

View File

@ -46,8 +46,9 @@ public class AuthorizeReturnObjectCoreHintsRegistrarTests {
context.refresh();
RuntimeHints hints = new RuntimeHints();
this.registrar.registerHints(hints, context.getBeanFactory());
assertThat(hints.reflection().typeHints().map((hint) -> hint.getType().getName()))
.containsOnly(cglibClassName(MyObject.class), cglibClassName(MySubObject.class));
assertThat(hints.reflection().typeHints().map((hint) -> hint.getType().getName())).containsOnly(
cglibClassName(MyObject.class), cglibClassName(MySubObject.class), MyObject.class.getName(),
MySubObject.class.getName());
assertThat(hints.proxies()
.jdkProxyHints()
.flatMap((hint) -> hint.getProxiedInterfaces().stream())

View File

@ -40,7 +40,7 @@ public class AuthorizeReturnObjectHintsRegistrarTests {
RuntimeHints hints = new RuntimeHints();
registrar.registerHints(hints, null);
assertThat(hints.reflection().typeHints().map((hint) -> hint.getType().getName()))
.containsOnly(cglibClassName(MyObject.class));
.containsOnly(cglibClassName(MyObject.class), MyObject.class.getName());
assertThat(hints.proxies()
.jdkProxyHints()
.flatMap((hint) -> hint.getProxiedInterfaces().stream())