Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-8690

MainServlet expects HttpServletRequest.getRemoteUser() to return valid liferay user id instead of userName

    Details

    • Type: Bug
    • Status: Closed
    • Resolution: Duplicate
    • Affects Version/s: 5.2.3, 6.0.6 GA
    • Fix Version/s: 5.2.3, 6.0.6 GA
    • Component/s: Application Security
    • Labels:
      None
    • Environment:
      Windows XP SP3 - development workstation
      Jboss 4.3 GA CP06
      Liferay 5.2.3
      IIS 6.0 Web Server - for SPNEGO handshake with the Active Directory Server
      Internet Explorer 7.0

      Description

      I resolved the issue posted by me at http://issues.liferay.com/browse/LPS-8637 by creating a custom filter. In the custom filter, I changed the if condition in AutoLoginFilter.java from

      if ((remoteUser == null) && (jUserName == null))

      to

      if ((remoteUser != null) || (jUserName != null))

      By doing the above change, I was able to call my custom auto.login.hooks implementation when remoteUser was passed via the HTTP header.

      My web.xml filter setting is as below.

      <filter>
      <filter-name>Custom Auto Login Filter</filter-name>
      <filter-class>com.custom.liferay.portal.servlet.filters.autologin.CustomAutoLoginFilter</filter-class>
      </filter>
      <filter-mapping>
      <filter-name>Custom Auto Login Filter</filter-name>
      <url-pattern>/web/guest</url-pattern>
      </filter-mapping>

      The problem that I am having now is that when I sign out, I get the error message

      ERROR [MainServlet:794] com.liferay.portal.NoSuchUserException: No User exists with the primary key 0

      I stepped through the code and found out that MainServlet.java is expecting remoteUser to be a userid. This is working OK during the auto login process because the AutoLoginFilter wraps the userid in the ProtectedServletRequest and it is available to MainServlet. But, when the user clicks logout it doesn't wrap the the userid in the ProtectedServletRequest resulting in the above error. To provide the userid to MainServlet through ProtectedServletRequest, I created a custom LogoutPageAction called CustomLogoutPageAction and also added the following entries in portal-ext.properties.

      default.logout.page.path=/liferay-ext/web/guest/logout
      logout.events.post=com.custom.liferay.portal.events.CustomLogoutPageAction

      But, I am still getting the same error. What do I need to change to fix the logout issue?

      I am also attaching the custom files for your reference.

      Thanks,
      Kamal

      Note: Since, I cannot attach more than 3 files, I am copy/pasting the portal-ext.properties file below:

      ##

        1. You can override portal.properties by specifying your own settings in this
        2. file.
          ##
          portal.ctx=/liferay-ext
          jdbc.default.jndi.name=jdbc/LiferayPool
          auto.login.hooks=com.custom.liferay.portal.security.auth.SpnegoAutoLogin
            1. The below lines send the user to the main page when they login instead of their private homes
              auth.forward.by.last.path=true
              default.landing.page.path=/liferay-ext/web/guest/login
              ##default.landing.page.path=/group/myjbhunt/
              login.events.post=com.liferay.portal.events.LoginPostAction,com.liferay.portal.events.DefaultLandingPageAction
        3. End redirect
          default.logout.page.path=/liferay-ext/web/guest/logout
          logout.events.post=com.custom.liferay.portal.events.CustomLogoutPageAction

        Attachments

        1. CustomAutoLoginFilter.java
          8 kB
          Kamal Pasha Shaikh
        2. CustomLogoutPageAction.java
          4 kB
          Kamal Pasha Shaikh
        3. SpnegoAutoLogin.java
          3 kB
          Kamal Pasha Shaikh

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 33 weeks, 6 days ago

                  Packages

                  Version Package
                  5.2.3
                  6.0.6 GA