Announcement Announcement Module
Collapse
No announcement yet.
Why is spring security including the context path? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Why is spring security including the context path?

    Hi,

    I'm using Spring 3.0. When Spring security is redirecting, it is including the context-path of my app, which I want to eliminate because it is causing a 404. In my securityContext.xml I have ...

    Code:
                    <form-login login-page="/../account/login" login-processing-url="/account/do-login"
                            default-target-url="/account/edit-profile" authentication-failure-url="/../account/login"
                            always-use-default-target="false" authentication-success-handler-ref="successHandler" />
    Notice the "default-target-url" above. It does not include my context-path, yet the redirect does (from the logs)

    Code:
    org.springframework.security.web.DefaultRedirectStrategy  - Redirecting to '/ltourism/account/edit-profile'
    How can I eliminate the context path "ltourism"? I tried hard-coding a redirect in a SuccessHandler, but to no avail ...

    Code:
    @Component("successHandler")
    public class SuccessHandler extends SimpleUrlAuthenticationSuccessHandler {
    
    	protected final Logger log = Logger.getLogger(SuccessHandler.class);
    
    	private RequestCache requestCache = new HttpSessionRequestCache();
    
    	public SuccessHandler() {
    		super("/account/edit-profile");
    	}
    
    	@Override
    	public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws ServletException, IOException {
    		SavedRequest savedRequest = requestCache.getRequest(request, response);
    
    		if (savedRequest == null) {
    			log.debug("savedRequest is null");
    			String targetUrl = "/account/edit-profile";
    			if (targetUrl.contains("/ltourism"))
    				targetUrl = targetUrl.replace("/ltourism", "");			
    			log.debug("sending redirect to " + targetUrl);
    			getRedirectStrategy().sendRedirect(request, response, targetUrl);
Working...
X