java - Prevent redirect to login for Spring Security -


i have spring mvc + spring security project.

<http auto-config="true" access-denied-page="/security/accessdenied" use-expressions="true" disable-url-rewriting="true">  ...  <intercept-url pattern="/dashboard/myaccount/**" access="hasanyrole('role_person', 'role_dealer')"/> ...  <form-login login-page="/security/login" authentication-failure-url="/security/login?error=true"                 default-target-url="/security/success" username-parameter="email"                 password-parameter="secret"/> <logout invalidate-session="true" logout-success-url="/index" logout-url="/security/logout"/> 

if user goes login page, if successful redirected "/security/success" more stuff in controller session object (record userid, ...etc)

my problem when guest user going /dashboard/myaccount (which requires auth), being redirected login page (which don't want, prefer 404 thrown). after spring security not redirecting /security/success. instead redirected /dashboard/myaccount.

i prefer find way disable redirection login page in case of guest trying access auth page.

is way this?

tnx

we add new authenticationentrypoint:

<http auto-config="true" access-denied-page="/security/accessdenied" use-expressions="true"       disable-url-rewriting="true" entry-point-ref="authenticationentrypoint"/>  <beans:bean id="authenticationentrypoint" class="a.b.c..authenticationentrypoint">     <beans:constructor-arg name="loginurl" value="/security/login"/> </beans:bean>  public class authenticationentrypoint extends loginurlauthenticationentrypoint {         public authenticationentrypoint(string loginurl)  {         super(loginurl);     }      @override     public void commence(httpservletrequest request, httpservletresponse response, authenticationexception authexception) throws ioexception, servletexception {         response.senderror(403, "forbidden");     } } 

Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -