Results 1 to 5 of 5

Thread: Log in on same page

  1. #1
    Join Date
    Jan 2009
    Posts
    12

    Default Log in on same page

    Im very new to this spring-framework and to spring security. But i got stucked on this...

    If a user log in, they are forced to a target URL, in this case the root, "/". By the property "defaultTargetUrl".

    Code:
    	<bean id="customAuthenticationProcessingFilter"
    		class="org.springframework.security.ui.webapp.AuthenticationProcessingFilter">
    		<security:custom-filter position="AUTHENTICATION_PROCESSING_FILTER" />
    		<property name="defaultTargetUrl" value="/" />
    		<property name="authenticationManager" ref="authenticationManager" />
    		<property name="authenticationFailureUrl" value="/login_failed.html" />
    		<property name="targetUrlResolver" ref="roleBasedTargetUrlResolver" />
    		<property name="rememberMeServices" ref="rememberMeServices" />
    		<property name="invalidateSessionOnSuccessfulAuthentication" value="true"/>
    	</bean>

    But I want this senario:

    The user is somewhere on the site. And log in and stil is on same page as before he/she logged in. The user "stay" on the same page.

    I need any help I can get. Please.

  2. #2
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    You can use the Referer header as the redirect location. Alternatively, you'd have to track the actual page they were on.
    Spring - by Pivotal
    twitter @tekul

  3. #3
    Join Date
    Jan 2009
    Posts
    12

    Default

    Quote Originally Posted by Luke Taylor View Post
    You can use the Referer header as the redirect location. Alternatively, you'd have to track the actual page they were on.
    Wierd, there isnt any easy way to be on the same page? You must set a targetURL?

  4. #4
    Luke Taylor is offline Senior Member Acegi Security System TeamSpring Team
    Join Date
    Aug 2004
    Location
    Glasgow, Scotland
    Posts
    3,449

    Default

    As I said, you can use the Referer header. That is an easy way. You are using a custom TargetUrlResolver, so you will have to code it in there.

    What do you find weird? There needs to be a redirect after login to tell the browser where to go and you need to obtain the location information from somewhere.
    Spring - by Pivotal
    twitter @tekul

  5. #5
    Join Date
    Jan 2009
    Posts
    12

    Default

    Hm Ok! I got this:
    Code:
    String bla = currentRequest.getHeader("referer");
    But I need to get this into a https. And write this:
    Code:
    bla = bla.replaceAll("http", "https");
    seems like a bad ide. Any suggestions?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •