JaynLau commented on issue #181: [SHIRO-682]Uri match fix and unit tests
URL: https://github.com/apache/shiro/pull/181#issuecomment-582269995
 
 
   Can not get the NamedFilterList when request uri is "/".
   ```
   java.lang.IllegalArgumentException: There is no configured chain under the 
name/key [].
        at 
org.apache.shiro.web.filter.mgt.DefaultFilterChainManager.proxy(DefaultFilterChainManager.java:322)
 ~[shiro-web-1.5.0.jar:1.5.0]
        at 
org.apache.shiro.web.filter.mgt.PathMatchingFilterChainResolver.getChain(PathMatchingFilterChainResolver.java:126)
 ~[shiro-web-1.5.0.jar:1.5.0]
        at 
org.apache.shiro.web.servlet.AbstractShiroFilter.getExecutionChain(AbstractShiroFilter.java:415)
 ~[shiro-web-1.5.0.jar:1.5.0]
        at 
org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:448)
 ~[shiro-web-1.5.0.jar:1.5.0]
        at 
org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
 ~[shiro-web-1.5.0.jar:1.5.0]
        at 
org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
 ~[shiro-core-1.5.0.jar:1.5.0]
        at 
org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83) 
~[shiro-core-1.5.0.jar:1.5.0]
        at 
org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:387)
 ~[shiro-core-1.5.0.jar:1.5.0]
        at 
org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
 ~[shiro-web-1.5.0.jar:1.5.0]
   ```
   
   ```
   //the 'chain names' in this implementation are actually path patterns 
defined by the user.  We just use them
   //as the chain name for the FilterChainManager's requirements
   for (String pathPattern : filterChainManager.getChainNames()) {
       if (pathPattern != null && pathPattern.endsWith(DEFAULT_PATH_SEPARATOR)) 
{
           pathPattern = pathPattern.substring(0, pathPattern.length() - 1);
       }
   
       // If the path does match, then pass on to the subclass implementation 
for specific checks:
       if (pathMatches(pathPattern, requestURI)) {
           if (log.isTraceEnabled()) {
               log.trace("Matched path pattern [" + pathPattern + "] for 
requestURI [" + Encode.forHtml(requestURI) + "].  " +
                       "Utilizing corresponding filter chain...");
           }
           return filterChainManager.proxy(originalChain, pathPattern);
       }
   }
   ```
   The value of pathPattern is changed from `"/"` to `""` , matching path 
definition `/ = user` failed.
   Because chainName is `"/"`, not `""`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to