title: Prevent redirect to login for Spring Security
body: <p>I have Spring MVC + Spring Security project.</p>
  
  <pre><code>&lt;http auto-config="true" access-denied-page="/security/accessDenied" use-expressions="true" disable-url-rewriting="true"&gt;
  
  ... 
  &lt;intercept-url pattern="/dashboard/myaccount/**" access="hasAnyRole('ROLE_PERSON', 'ROLE_DEALER')"/&gt;
  ...
  
  &lt;form-login login-page="/security/login" authentication-failure-url="/security/login?error=true"
                  default-target-url="/security/success" username-parameter="email"
                  password-parameter="secret"/&gt;
  &lt;logout invalidate-session="true" logout-success-url="/index" logout-url="/security/logout"/&gt;
  </code></pre>
  
  <p>If a user goes to login page, if successful will be redirected to "/security/success" where I do more stuff in the controller with the session object (record userID, ...etc)</p>
  
  <p>My problem is when an GUEST user is going to /dashboard/myaccount (which requires AUTH), he is being redirected to LOGIN page (Which I don't want, I prefer a 404 thrown). After that Spring Security is not redirecting to /security/success. Instead is redirected to /dashboard/myaccount.</p>
  
  <p>I would prefer to find a way to disable completely this redirection to login page in case of GUEST trying to access a AUTH page.</p>
  
  <p>Is any way to do this? </p>
  
  <p>Tnx</p>