You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2020/08/05 14:12:13 UTC

[sling-org-apache-sling-auth-core] branch master updated: SLING-5483 : Unauthenticated request: getUserPrincipal() doesn't return null for auth.annonymous=true

This is an automated email from the ASF dual-hosted git repository.

cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-auth-core.git


The following commit(s) were added to refs/heads/master by this push:
     new c4f4def  SLING-5483 : Unauthenticated request: getUserPrincipal() doesn't return null for auth.annonymous=true
c4f4def is described below

commit c4f4deffe0590646562d47a7c52b4490859a74ed
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Wed Aug 5 16:11:59 2020 +0200

    SLING-5483 : Unauthenticated request: getUserPrincipal() doesn't return null for auth.annonymous=true
---
 src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java b/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
index c2e876a..6e203cc 100644
--- a/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
+++ b/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
@@ -1287,8 +1287,10 @@ public class SlingAuthenticator implements Authenticator,
             final HttpServletRequest request) {
 
         // HttpService API required attributes
-        request.setAttribute(ServletContextHelper.REMOTE_USER, resolver.getUserID());
         request.setAttribute(ServletContextHelper.AUTHENTICATION_TYPE, authType);
+        if ( authType != null ) {
+            request.setAttribute(ServletContextHelper.REMOTE_USER, resolver.getUserID());
+        }
 
         // resource resolver for down-stream use
         request.setAttribute(REQUEST_ATTRIBUTE_RESOLVER, resolver);