You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@casbin.apache.org by hs...@apache.org on 2026/03/29 13:32:00 UTC

(casbin-gateway) branch master updated (09f2400 -> 3561e26)

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

hsluoyz pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-gateway.git


 discard 09f2400  feat: add UrlPathRule
    omit 17244fa  feat: fix dockerfile missing package (tzdata) (#160)
    omit c47729a  feat: Introduce runtime configuration for the frontend via `config.js` to allow dynamic updates without rebuilding the Docker image (#159)
     new 87936ab  feat: fix dockerfile missing package (tzdata) (#160)
     new 3561e26  feat: add UrlPathRule

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (09f2400)
            \
             N -- N -- N   refs/heads/master (3561e26)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 README.md             | 24 ------------------------
 web/public/config.js  | 24 ------------------------
 web/public/index.html |  2 --
 web/src/Conf.js       |  6 ++----
 4 files changed, 2 insertions(+), 54 deletions(-)
 delete mode 100644 web/public/config.js


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@casbin.apache.org
For additional commands, e-mail: commits-help@casbin.apache.org


(casbin-gateway) 01/02: feat: fix dockerfile missing package (tzdata) (#160)

Posted by hs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-gateway.git

commit 87936ab4c85831252685c72d580d8feab3f103ca
Author: Paweł Markowski <pm...@gmail.com>
AuthorDate: Mon Feb 16 12:43:24 2026 +0100

    feat: fix dockerfile missing package (tzdata) (#160)
---
 Dockerfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Dockerfile b/Dockerfile
index 91eaacb..fc4c663 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,7 +14,7 @@ LABEL MAINTAINER="https://caswaf.org/"
 
 COPY --from=BACK /go/src/caswaf/ ./
 COPY --from=BACK /usr/bin/wait-for-it ./
-RUN mkdir -p web/build && apk add --no-cache bash coreutils
+RUN mkdir -p web/build && apk add --no-cache bash coreutils tzdata
 COPY --from=FRONT /web/build /web/build
 ENTRYPOINT ["./wait-for-it", "db:3306", "--", "./server"]
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@casbin.apache.org
For additional commands, e-mail: commits-help@casbin.apache.org


(casbin-gateway) 02/02: feat: add UrlPathRule

Posted by hs...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

hsluoyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/casbin-gateway.git

commit 3561e266d8abed574b070058d5f5a698daa51416
Author: Yang Luo <hs...@gmail.com>
AuthorDate: Sun Mar 29 21:23:34 2026 +0800

    feat: add UrlPathRule
---
 rule/rule.go                      |  2 ++
 rule/rule_url_path.go             | 62 +++++++++++++++++++++++++++++++++++++++
 web/src/RuleEditPage.js           | 13 ++++++++
 web/src/components/UaRuleTable.js | 39 ++++++++++++++++++------
 4 files changed, 107 insertions(+), 9 deletions(-)

diff --git a/rule/rule.go b/rule/rule.go
index 0468c3f..4c689da 100644
--- a/rule/rule.go
+++ b/rule/rule.go
@@ -42,6 +42,8 @@ func CheckRules(ruleIds []string, r *http.Request) (*RuleResult, error) {
 		switch rule.Type {
 		case "User-Agent":
 			ruleObj = &UaRule{}
+		case "URL Path":
+			ruleObj = &UrlPathRule{}
 		case "IP":
 			ruleObj = &IpRule{}
 		case "WAF":
diff --git a/rule/rule_url_path.go b/rule/rule_url_path.go
new file mode 100644
index 0000000..93ef412
--- /dev/null
+++ b/rule/rule_url_path.go
@@ -0,0 +1,62 @@
+// Copyright 2024 The casbin Authors. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package rule
+
+import (
+	"fmt"
+	"net/http"
+	"regexp"
+	"strings"
+
+	"github.com/casbin/caswaf/object"
+)
+
+type UrlPathRule struct{}
+
+func (r *UrlPathRule) checkRule(expressions []*object.Expression, req *http.Request) (*RuleResult, error) {
+	path := req.URL.Path
+	for _, expression := range expressions {
+		pattern := expression.Value
+		reason := fmt.Sprintf("expression matched: \"%s %s %s\"", path, expression.Operator, expression.Value)
+		switch expression.Operator {
+		case "contains":
+			if strings.Contains(path, pattern) {
+				return &RuleResult{Reason: reason}, nil
+			}
+		case "does not contain":
+			if !strings.Contains(path, pattern) {
+				return &RuleResult{Reason: reason}, nil
+			}
+		case "equals":
+			if path == pattern {
+				return &RuleResult{Reason: reason}, nil
+			}
+		case "does not equal":
+			if strings.Compare(path, pattern) != 0 {
+				return &RuleResult{Reason: reason}, nil
+			}
+		case "match":
+			isHit, err := regexp.MatchString(pattern, path)
+			if err != nil {
+				return nil, err
+			}
+			if isHit {
+				return &RuleResult{Reason: reason}, nil
+			}
+		}
+	}
+
+	return nil, nil
+}
diff --git a/web/src/RuleEditPage.js b/web/src/RuleEditPage.js
index 57c7b60..65b1e47 100644
--- a/web/src/RuleEditPage.js
+++ b/web/src/RuleEditPage.js
@@ -99,6 +99,7 @@ class RuleEditPage extends React.Component {
                   {value: "WAF", text: "WAF"},
                   {value: "IP", text: "IP"},
                   {value: "User-Agent", text: "User-Agent"},
+                  {value: "URL Path", text: "URL Path"},
                   {value: "IP Rate Limiting", text: i18next.t("rule:IP Rate Limiting")},
                   {value: "Compound", text: i18next.t("rule:Compound")},
                 ].map((item, index) => <Option key={index} value={item.value}>{item.text}</Option>)
@@ -144,6 +145,18 @@ class RuleEditPage extends React.Component {
                 />
               ) : null
             }
+            {
+              this.state.rule.type === "URL Path" ? (
+                <UaRuleTable
+                  kind="urlPath"
+                  title={"URL Paths"}
+                  table={this.state.rule.expressions}
+                  ruleName={this.state.rule.name}
+                  account={this.props.account}
+                  onUpdateTable={(value) => {this.updateRuleField("expressions", value);}}
+                />
+              ) : null
+            }
             {
               this.state.rule.type === "IP Rate Limiting" ? (
                 <IpRateRuleTable
diff --git a/web/src/components/UaRuleTable.js b/web/src/components/UaRuleTable.js
index 3d4e92d..c5fe6ef 100644
--- a/web/src/components/UaRuleTable.js
+++ b/web/src/components/UaRuleTable.js
@@ -25,19 +25,31 @@ class UaRuleTable extends React.Component {
     super(props);
     this.state = {
       classes: props,
-      defaultRules: [
-        {
-          name: "Current User-Agent",
-          operator: "equals",
-          value: window.navigator.userAgent,
-        },
-      ],
     };
     if (this.props.table.length === 0) {
       this.restore();
     }
   }
 
+  getDefaultRules() {
+    if (this.props.kind === "urlPath") {
+      return [
+        {
+          name: "Example",
+          operator: "contains",
+          value: "/.git/config",
+        },
+      ];
+    }
+    return [
+      {
+        name: "Current User-Agent",
+        operator: "equals",
+        value: window.navigator.userAgent,
+      },
+    ];
+  }
+
   updateTable(table) {
     this.props.onUpdateTable(table);
   }
@@ -48,7 +60,12 @@ class UaRuleTable extends React.Component {
   }
 
   addRow(table) {
-    const row = {name: `New UA Rule - ${table.length}`, operator: "equals", value: ""};
+    const isPath = this.props.kind === "urlPath";
+    const row = {
+      name: isPath ? `New URL Path Rule - ${table.length}` : `New UA Rule - ${table.length}`,
+      operator: isPath ? "contains" : "equals",
+      value: "",
+    };
     if (table === undefined) {
       table = [];
     }
@@ -73,7 +90,7 @@ class UaRuleTable extends React.Component {
   }
 
   restore() {
-    this.updateTable(this.state.defaultRules);
+    this.updateTable(this.getDefaultRules());
   }
 
   renderTable(table) {
@@ -169,4 +186,8 @@ class UaRuleTable extends React.Component {
   }
 }
 
+UaRuleTable.defaultProps = {
+  kind: "userAgent",
+};
+
 export default UaRuleTable;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@casbin.apache.org
For additional commands, e-mail: commits-help@casbin.apache.org