Wei Han created KNOX-1157:
-----------------------------

             Summary: Scoped rewrite rules are treated as global rules in some 
cases
                 Key: KNOX-1157
                 URL: https://issues.apache.org/jira/browse/KNOX-1157
             Project: Apache Knox
          Issue Type: Bug
            Reporter: Wei Han
            Assignee: Sumit Gupta
            Priority: Minor
         Attachments: 
0001-bug-fix-use-a-map-to-store-all-rules-in-ScopedMatche.patch

https://issues.apache.org/jira/browse/KNOX-711 introduced the concept of 
'scope' for rewrite rules. A rewrite rule can be applied to an input url only 
if they share the same scope, unless the rule is explicitly defined as 'global' 
rules. 

However given the following rewrite.xml, and input url "/foo/bar" with role 
service-1, the second rule(service-2) will win because the second rule is more 
specific, even the scope is different from the input url. 

    <rule name="service-1/test-rule-8" dir="OUT" pattern="/foo/{**}">
        <rewrite template="/foo/service-1" />
    </rule>

    <rule name="service-2/test-rule-9" dir="OUT" pattern="/foo/bar">
        <rewrite template="/foo/service-2" />
    </rule>

The root cause is the templates for these two rules are different, so in 
ScopedMatcher.java(https://github.com/apache/knox/commit/286e02a44dfb5f9ee101007b46bcb8ee47fa62d7#diff-6cffc9c391024e27c73a85ba8e736e60R118),
 we don't create a separate matcher and the two rules share the same matcher 
object. 

My proposal is to change the implementation to create a brand new matcher for 
each scope, and store them in a map keyed by scope name.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to