Metadata-Version: 2.1
Name: flask-aserto
Version: 0.5.0rc2
Summary: Aserto integration for Flask
Home-page: https://github.com/aserto-dev/aserto-python/tree/HEAD/packages/flask-aserto
License: Apache-2.0
Author: Aserto, Inc.
Author-email: pypi@aserto.com
Maintainer: authereal
Maintainer-email: authereal@aserto.com
Requires-Python: >=3.7,<4.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Topic :: Software Development :: Libraries
Classifier: Typing :: Typed
Requires-Dist: Flask-Cors (>=3.0.10,<4.0.0)
Requires-Dist: Flask[async] (>=2.0.1,<3.0.0)
Requires-Dist: aserto (==0.3.0.rc3)
Requires-Dist: grpcio (>=1.49.1,<2.0.0)
Requires-Dist: protobuf (>=4.21.7,<5.0.0)
Requires-Dist: typing-extensions (>=3.10.0,<4.0.0)
Project-URL: Documentation, https://github.com/aserto-dev/aserto-python/tree/HEAD/packages/flask-aserto
Project-URL: Repository, https://github.com/aserto-dev/aserto-python/tree/HEAD/packages/flask-aserto
Description-Content-Type: text/markdown

# Aserto Flask middleware
This is the official library for integrating [Aserto](https://www.aserto.com/) authorization into your [Flask](https://github.com/pallets/flask) applications.

For a example of what this looks like in a running Flask app and guidance on connecting an identity provider, see the [PeopleFinder app example](https://github.com/aserto-dev/aserto-python/tree/main/packages/flask-aserto/peoplefinder_example).

## Features
### Add authorization checks to your routes
```py
from flask_aserto import AsertoMiddleware, AuthorizationError


app = Flask(__name__)
aserto = AsertoMiddleware(**aserto_options)


@app.route("/api/users/<id>", methods=["GET"])
@aserto.authorize
def api_user(id: str) -> Response:
    # Raises an AuthorizationError if the `GET.api.users.__id`
    # policy returns a decision of "allowed = false" 
    ...
```
### Automatically create a route to serve a [Display State Map](https://docs.aserto.com/docs/authorizer-guide/display-state-map)
```py
# Defaults to creating a route at the path "/__displaystatemap" 
aserto.register_display_state_map(app)
```
### Perform more finely controlled authorization checks
```py
@app.route("/api/users/<id>", methods=["GET"])
async def api_user(id: str) -> Response:
    # This also automatically knows to check the `GET.api.users.__id` policy
    if not await aserto.check("allowed"):
        raise AuthorizationError()

    ...
```

