Class PrePostAuthorizeExpressionBeanHintsRegistrar

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

public final class PrePostAuthorizeExpressionBeanHintsRegistrar extends Object implements SecurityHintsRegistrar
A SecurityHintsRegistrar that scans all provided classes for methods that use PreAuthorize or PostAuthorize and registers hints for the beans used within the security expressions.

It will also scan return types of methods annotated with AuthorizeReturnObject.

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 registerThese() {
                return new PrePostAuthorizeExpressionBeanHintsRegistrar(MyClass.class);
        }
 
Since:
6.4
See Also:
  • SecurityHintsAotProcessor
  • Constructor Details

    • PrePostAuthorizeExpressionBeanHintsRegistrar

      public PrePostAuthorizeExpressionBeanHintsRegistrar(Class<?>... toVisit)
    • PrePostAuthorizeExpressionBeanHintsRegistrar

      public PrePostAuthorizeExpressionBeanHintsRegistrar(List<Class<?>> toVisit)
  • Method Details

    • registerHints

      public void registerHints(org.springframework.aot.hint.RuntimeHints hints, org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
      Description copied from interface: SecurityHintsRegistrar
      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