Skip to content

Commit ea3dad1

Browse files
authored
Merge pull request #12 from pycasbin/issue-11
fix uri bug
2 parents b78a760 + 49ae2e1 commit ea3dad1

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

flask_authz/casbin_enforcer.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ def wrapper(*args, **kwargs):
4848
"Enforce Headers Config: %s\nRequest Headers: %s"
4949
% (self.app.config.get("CASBIN_OWNER_HEADERS"), request.headers)
5050
)
51+
# Set resource URI from request
52+
uri = str(request.path)
5153
for header in self.app.config.get("CASBIN_OWNER_HEADERS"):
5254
if header in request.headers:
5355
# Make Authorization Header Parser standard
@@ -63,7 +65,7 @@ def wrapper(*args, **kwargs):
6365
"decoding is unsupported by flask-casbin at this time"
6466
)
6567
continue
66-
if self.e.enforce(owner, str(request.url_rule), request.method):
68+
if self.e.enforce(owner, uri, request.method):
6769
return func(*args, **kwargs)
6870
else:
6971
# Split header by ',' in case of groups when groups are
@@ -76,7 +78,7 @@ def wrapper(*args, **kwargs):
7678
% (owner.strip('"'), header)
7779
)
7880
if self.e.enforce(
79-
owner.strip('"'), str(request.url_rule), request.method
81+
owner.strip('"'), uri, request.method
8082
):
8183
return func(*args, **kwargs)
8284
else:

0 commit comments

Comments
 (0)