title: Spring Security - disable security dynamically
body: <p>How can I disable Spring Security dynamically? With the code below, my application requires authentication to access some pages, but I'd like to enable / disable that using property files. Any suggestions?</p>
  
  <ul>
  <li>Spring Security 4</li>
  <li><p>I know about <a href="http://docs.spring.io/spring-security/site/docs/4.0.2.CI-SNAPSHOT/reference/htmlsingle/" rel="nofollow">setting the security attribute to false in the http tag</a> but that requires recompiling code, which is not sufficient for me.</p>
  
  <pre><code>&lt;sec:http&gt;
      &lt;sec:intercept-url pattern="/services/**" access="hasRole('ROLE_USER')"/&gt;
      &lt;sec:intercept-url pattern="/app/**" access="hasRole('ROLE_ADMIN')"/&gt;
  
      &lt;sec:intercept-url pattern="/**" access="isAuthenticated()" /&gt;
      &lt;sec:http-basic /&gt;
  
      &lt;sec:csrf disabled="true" /&gt; 
  &lt;/sec:http&gt;
  </code></pre></li>
  </ul>
  
  <p>Thanks in advance.</p>