You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by as...@apache.org on 2017/05/09 10:15:28 UTC
svn commit: r1794520 -
/sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
Author: asanso
Date: Tue May 9 10:15:27 2017
New Revision: 1794520
URL: http://svn.apache.org/viewvc?rev=1794520&view=rev
Log:
SLING-6053 - SlingAuthenticator identifies wrong sibling node with AuthenticationInfo
Modified:
sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
Modified: sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java?rev=1794520&r1=1794519&r2=1794520&view=diff
==============================================================================
--- sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java (original)
+++ sling/trunk/bundles/auth/core/src/main/java/org/apache/sling/auth/core/impl/SlingAuthenticator.java Tue May 9 10:15:27 2017
@@ -543,7 +543,7 @@ public class SlingAuthenticator implemen
final Collection<AbstractAuthenticationHandlerHolder> holderList = holdersArray[m];
if ( holderList != null ) {
for (AbstractAuthenticationHandlerHolder holder : holderList) {
- if (path.startsWith(holder.path)) {
+ if (isNodeRequiresAuthHandler(path, holder.path)) {
log.debug("login: requesting authentication using handler: {}",
holder);
@@ -604,7 +604,7 @@ public class SlingAuthenticator implemen
final Collection<AbstractAuthenticationHandlerHolder> holderSet = holdersArray[m];
if (holderSet != null) {
for (AbstractAuthenticationHandlerHolder holder : holderSet) {
- if (path.startsWith(holder.path)) {
+ if (isNodeRequiresAuthHandler(path, holder.path)) {
log.debug("logout: dropping authentication using handler: {}",
holder);
@@ -723,7 +723,7 @@ public class SlingAuthenticator implemen
final Collection<AbstractAuthenticationHandlerHolder> local = localArray[m];
if (local != null) {
for (AbstractAuthenticationHandlerHolder holder : local) {
- if (path.startsWith(holder.path)) {
+ if (isNodeRequiresAuthHandler(path, holder.path)){
final AuthenticationInfo authInfo = holder.extractCredentials(
request, response);
@@ -917,7 +917,7 @@ public class SlingAuthenticator implemen
final Collection<AuthenticationRequirementHolder> holders = holderSetArray[m];
if (holders != null) {
for (AuthenticationRequirementHolder holder : holders) {
- if (path.startsWith(holder.path)) {
+ if (isNodeRequiresAuthHandler(path, holder.path)) {
return !holder.requiresAuthentication();
}
}
@@ -928,6 +928,34 @@ public class SlingAuthenticator implemen
return false;
}
+ private boolean isNodeRequiresAuthHandler(String path, String holderPath) {
+ if (path == null || holderPath == null) {
+ return false;
+ }
+
+ if (("/").equals(holderPath)) {
+ return true;
+ }
+
+ int holderPathLength = holderPath.length();
+
+ if (path.length() < holderPathLength) {
+ return false;
+ }
+
+ if (path.equals(holderPath)) {
+ return true;
+ }
+
+ if (path.startsWith(holderPath)) {
+ if (path.charAt(holderPathLength) == '/' || path.charAt(holderPathLength) == '.') {
+ return true;
+ }
+ }
+ return false;
+ }
+
+
/**
* Returns credentials to use for anonymous resource access. If an anonymous
* user is configued, this returns an {@link AuthenticationInfo} instance