Spring Security Allows Unauthorized User Access to Restricted URL from a Forward

后端 未结 2 621
醉话见心
醉话见心 2021-01-17 06:45

Spring Security 3.2.0.RC2

Given:

@Override
protected void configure(HttpSecurity httpSecurity) throws Exception {
    httpSecurity
        .authorize         


        
2条回答
  •  天命终不由人
    2021-01-17 07:40

    If you are using web.xml to configure your filter, try this:

    
        springSecurityFilterChain
        org.springframework.web.filter.DelegatingFilterProxy
    
    
    
        springSecurityFilterChain
        /*
        FORWARD 
        REQUEST
    
    

    ...or use the Servlet3 Java-based Config equivalent, which is to extend AbstractSecurityWebApplicationInitializer and override the getSecurityDispatcherTypes() method:

    public class YourSecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
    
        protected  EnumSet getSecurityDispatcherTypes() {
            // Return dispatcher types here, in your case you'll want the defaults, 
            // which are DispatcherType.REQUEST and DispatcherType.ERROR
            // ...as well as the one you need for your use case: DispatcherType.FORWARD
        }
    
    }
    

    I typed that here, so hopefully there are no errors. Should get you going, though.

提交回复
热议问题