Class AuthorizeReturnObjectHintsRegistrar

java.lang.Object
org.springframework.security.aot.hint.AuthorizeReturnObjectHintsRegistrar
All Implemented Interfaces:
SecurityHintsRegistrar

public final class AuthorizeReturnObjectHintsRegistrar extends Object implements SecurityHintsRegistrar
A SecurityHintsRegistrar implementation that registers only the classes provided in the constructor.

It also traverses those found types for other return values.

This may be used by an application to register specific Security-adjacent classes that were otherwise missed by Spring Security's reachability scans.

Remember to register this as an infrastructural bean like so:

        @Bean
        @Role(BeanDefinition.ROLE_INFRASTRUCTURE)
        static SecurityHintsRegistrar proxyThese(AuthorizationProxyFactory proxyFactory) {
                return new AuthorizationProxyFactoryHintsRegistrar(proxyFactory, MyClass.class);
        }
 

Note that no object graph traversal is performed in this class. As such, any classes that need an authorization proxy that are missed by Security's default registrars should be listed exhaustively in the constructor.

Since:
6.4
See Also:
  • Constructor Details

    • AuthorizeReturnObjectHintsRegistrar

      public AuthorizeReturnObjectHintsRegistrar(AuthorizationProxyFactory proxyFactory, Class<?>... classes)
    • AuthorizeReturnObjectHintsRegistrar

      public AuthorizeReturnObjectHintsRegistrar(AuthorizationProxyFactory proxyFactory, List<Class<?>> classes)
      Construct this registrar
      Parameters:
      proxyFactory - the proxy factory to use to produce the proxy class implementations to be registered
      classes - the classes to proxy
  • Method Details

    • registerHints

      public void registerHints(org.springframework.aot.hint.RuntimeHints hints, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
      Register hints after preparing them through Security's infrastructural beans
      Specified by:
      registerHints in interface SecurityHintsRegistrar
      Parameters:
      hints - the registration target for any AOT hints
      beanFactory - the bean factory