Results 1 to 4 of 4

Thread: Check Session on Same IP Address

  1. #1

    Default Check Session on Same IP Address

    Is there a way of checking that the session has stayed on the same IP address - to stop someone stealing the cookie and hijacking the session from another IP address?

    I know how to put the IP address into the session - during authentication, but I don't know how to put in a hook that checks things during every page request.

  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 should be able to do this with a simple servlet filter which checks the IP address from the request against the original one.
    Spring - by Pivotal
    twitter @tekul

  3. #3

    Default

    Thanks, that would be a simple, obvious solution!

    If it fails I guess the answer is to put a redirect to the logout page in the response?

    Just out of interest does the 'hook' I mentioned exist in Spring Security - one that calls code when the authentication against the stored session is performed? I assume Spring security rechecks the credentials on each request - or does it just assume that everything is okay if a session with the authority merely exists?

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

    Default

    The user is authenticated once for the session - thereafter the session token is what ties the user to the originally authenticated identity. The credentials aren't checked on each request - the request doesn't typically contain them, so how would they be checked?
    Spring - by Pivotal
    twitter @tekul

Posting Permissions

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