Skip to content

Commit

Permalink
Check middleware supports python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ronenh committed Jan 30, 2024
1 parent 5c634ec commit d37ed88
Show file tree
Hide file tree
Showing 8 changed files with 233 additions and 205 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
run: |
poetry install
poetry run pyright .
- name: Run tests
run: |
poetry run pytest -vv
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ aserto = AsertoMiddleware(**aserto_options)


@app.route("/api/users/<id>", methods=["GET"])
@aserto.authorize
@aserto
def api_user(id: str) -> Response:
# Raises an AuthorizationError if the `GET.api.users.__id`
# policy returns a decision of "allowed = false"
# policy returns a decision of "allowed = false"
...
```

Expand All @@ -104,7 +104,7 @@ def id_mapper() -> str:

@app.route("/resource/<asset>", methods=["GET"])
@requires_auth
@aserto.check(objType="resource", objIdMapper=id_mapper, relationName="can_read").authorize
@aserto.check(objType="resource", objIdMapper=id_mapper, relationName="can_read")
def get_resource(asset: str):
return {"message": "Hello from GET /resource/" + asset}

Expand All @@ -117,7 +117,7 @@ The `check` function accepts options that configure the object, subject, and rel

```py
def check(
self,
self,
objId: Optional[str] = "",
objType: Optional[str] = "",
objIdMapper: Optional[StringMapper] = None,
Expand Down Expand Up @@ -153,4 +153,4 @@ class Obj:

`policyPath` sets the name of the policy module to evaluate in check calls. It defaults to `check`.

`policyRoot` sets the root of the policy module. For example, if the root is set to "myPolicy", the Check call looks for a policy module named `myPolicy.check`.
`policyRoot` sets the root of the policy module. For example, if the root is set to "myPolicy", the Check call looks for a policy module named `myPolicy.check`.
87 changes: 35 additions & 52 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "flask-aserto"
version = "0.30.5-dirty"
version = "0.30.5"
description = "Aserto integration for Flask"
readme = "README.md"
authors = ["Aserto, Inc. <[email protected]>"]
Expand Down Expand Up @@ -29,7 +29,6 @@ packages = [

[tool.poetry.dependencies]
python = "^3.8"
version = "0.30.5-dirty"
Flask-Cors = ">=3.0.0,<5.0.0"
grpcio = "^1.49.0"
protobuf = "^4.21.0"
Expand Down
Loading

0 comments on commit d37ed88

Please sign in to comment.