Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>@kungfuters is correct that the first step is ensuring the Filter is intercepting that request in the first place. To do so with a web.xml you would use the following:</p> <pre><code>&lt;filter&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt; &lt;/filter&gt; &lt;filter-mapping&gt; &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt; &lt;url-pattern&gt;/*&lt;/url-pattern&gt; &lt;dispatcher&gt;FORWARD&lt;/dispatcher&gt; &lt;!-- Include FORWARD here --&gt; &lt;dispatcher&gt;REQUEST&lt;/dispatcher&gt; &lt;/filter-mapping&gt; </code></pre> <p>To do so with Java Configuration you would use the following:</p> <pre><code>public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer { protected EnumSet&lt;DispatcherType&gt; getSecurityDispatcherTypes() { return return EnumSet.of(DispatcherType.REQUEST, DispatcherType.ERROR, DispatcherType.ASYNC, DispatcherType.FORWARD); } } </code></pre> <p>The last piece is that the FilterSecurityInterceptor (the piece that ensures URLs are protected) by default will only intercept the REQUEST and not additional dispatches (i.e. forwards). This is done because it is quite rare to protect the URLs that are forwarded to (typically you would protect the URL that does the forwarding). To enable that you need to use the following with xml configuration you need to use <a href="http://docs.spring.io/spring-security/site/docs/3.2.x-SNAPSHOT/reference/htmlsingle/#nsa-http-once-per-request" rel="noreferrer">http@once-per-request=true</a>:</p> <pre><code>&lt;http once-per-request="true"&gt; &lt;!-- ... --&gt; &lt;/http&gt; </code></pre> <p>Similarly, there is a oncePerRequest property within Java Configuration that can be used. For example:</p> <pre><code>@Override protected void configure(HttpSecurity httpSecurity) throws Exception { httpSecurity .authorizeRequests() .filterSecurityInterceptorOncePerRequest(false) // make sure to grant access to any login page you are forwarding to .antMatchers("/restricted/login").permitAll() .antMatchers("/restricted/**").hasRole("admin") .anyRequest().authenticated() .and() .formLogin() .permitAll() // etc ; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload