Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-11825

SlingHttpServletRequestImpl.getUserPrincipal() does not return null for anonymous requests

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Engine 2.14.0
    • Engine 2.15.0
    • Engine
    • None

    Description

      According to https://docs.oracle.com/javaee/6/api/javax/servlet/http/HttpServletRequest.html#getUserPrincipal() the method getUserPrincipal is supposed to return

      null if the user has not been authenticated

      Unfortunately the implementation in https://github.com/apache/sling-org-apache-sling-engine/blob/c31e3ad64cafa0e53f67ad7551b13dc7124ccff6/src/main/java/org/apache/sling/engine/impl/SlingHttpServletRequestImpl.java#L320 seems to violate this contract, as I always get back a non-null value (even if the user was never authenticated).

      The ResourceResolver.adaptTo(Principal.class) will always return a non-null value due to https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/685c50921085941f4cbb1a3ccdbf90bad0605527/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java#L617

      Attachments

        Issue Links

          Activity

            People

              kwin Konrad Windszus
              kwin Konrad Windszus
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: