Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4512

Wicket session id not up to date due to Tomcat session fixation protection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.4.20
    • 1.4.21
    • wicket
    • None
    • Tomcat 7.0.23

    Description

      While using a form based login with a security constraint in web.xml and killing the session on page start the value of 'WebSession.get().getId()' is not equal to '((ServletWebRequest) RequestCycle.get().getRequest()).getHttpServletRequest().getSession(false).getId()'.

      This is due to Tomcat's session fixation protection in Tomat 7.0.

      We implemented the following workaround:

      new HttpSessionStore() {
      public Session lookup(Request request) {
      String sessionId = getSessionId(request, false);
      LOG.debug("AbstractHttpSessionStore#lookup() [sessionId={}]", sessionId);
      if (sessionId != null) {
      WebRequest webRequest = toWebRequest(request);
      Session session = (Session)getAttribute(webRequest, Session.SESSION_ATTRIBUTE_NAME);

      // it cannot be okay if the session id's are not equal!!!
      if (null != session && !sessionId.equals(session.getId())) {
      try

      { Field f = Session.class.getDeclaredField("id"); f.setAccessible(true); f.set(session, null); // it will be resolved later from the httpSession }

      catch (Exception e)

      { throw new IllegalStateException(e); }

      }
      return session;
      }
      return null;
      }
      }

      Attachments

        1. sessionIdProblem.zip
          12 kB
          Thomas Rohde
        2. 0001-WICKET-4512-don-t-store-session-id-longer-than-neede.patch
          1 kB
          Carl-Eric Menzel

        Issue Links

          Activity

            People

              cmenzel Carl-Eric Menzel
              tro Thomas Rohde
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: