Why is my custom PermissionEvaluator not working?

后端 未结 1 699
一向
一向 2021-02-06 14:16

I can’t understand why my security doesn’t work properly. Method hasPermission() in Evaluator class not even called. I think there is something wrong with my security config.

1条回答
  •  执念已碎
    2021-02-06 15:16

    This is likely due to the fact that the tag needs to be in the same context as your Spring MVC configuration otherwise your controllers will not be post processed. This is discussed in the FAQ.

    So for example, if your web.xml looks like the following:

    
    
        contextConfigLocation
        
            /WEB-INF/spring/*.xml
        
    
    
    
        springSecurityFilterChain
        org.springframework.web.filter.DelegatingFilterProxy
    
    
    
      springSecurityFilterChain
      /*
    
    
    
    
        org.springframework.web.context.ContextLoaderListener
    
    
    
        spring
        org.springframework.web.servlet.DispatcherServlet
        
            contextConfigLocation
            /WEB-INF/mvc/*.xml
        
    
    

    To support method security on your controllers ensure the tag is defined in a location within /WEB-INF/mvc/*.xml. Note that the remainder of the configuration should remain where it is. If you want to support method security on your services, you likely also need in the parent (i.e. where it likely is now).

    If this does not help, please post your web.xml or WebApplicationInitializer's if you are not using web.xml

    0 讨论(0)
提交回复
热议问题