https://github.com/aserto-dev/python-authorizer
https://github.com/aserto-dev/python-authorizer
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/aserto-dev/python-authorizer
- Owner: aserto-dev
- License: mit
- Created: 2022-10-05T12:56:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-25T16:42:16.000Z (about 1 year ago)
- Last Synced: 2025-10-28T03:55:15.231Z (8 months ago)
- Language: Python
- Size: 170 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS.md
Awesome Lists containing this project
README
# Aserto Authorizer gRPC client
This is an automatically generated client for interacting with Aserto's [Authorizer service](https://docs.aserto.com/docs/authorizer-guide/overview) using the gRPC protocol.
The code was generated from https://buf.build/aserto-dev/authorizer.
## Installation
### Using Pip
```sh
pip install aserto-authorizer
```
### Using Poetry
```sh
poetry add aserto-authorizer
```
## Usage
```py
import grpc
from aserto.authorizer.v2.api import (
IdentityContext,
IdentityType,
PolicyContext,
PolicyInstance,
)
from aserto.authorizer.v2 import (
AuthorizerStub,
DecisionTreeRequest,
DecisionTreeOptions,
DecisionTreeResponse,
PathSeparator,
)
from grpclib.client import Channel
with grpc.secure_channel(
target="authorizer.prod.aserto.com:8443",
credentials=grpc.ssl_channel_credentials(),
) as channel:
client = AuthorizerStub(channel)
response = client.DecisionTree(
DecisionTreeRequest(
policy_context=PolicyContext(
path=ASERTO_POLICY_PATH_ROOT,
decisions=["visible", "enabled", "allowed"],
),
policy_instance=PolicyInstance(
name=ASERTO_POLICY_NAME,
instance_label=ASERTO_POLICY_INSTANCE_LABEL,
),
identity_context=IdentityContext(type=IdentityType.IDENTITY_TYPE_NONE),
options=DecisionTreeOptions(
path_separator=PathSeparator.PATH_SEPARATOR_DOT,
),
)
)
assert response == DecisionTreeResponse(
path_root=ASERTO_POLICY_PATH_ROOT,
path=Proto.Struct(
fields={
"GET.your.policy.path": Proto.Value(
struct_value=Proto.Struct(
fields={
"visible": Proto.Value(bool_value=True),
"enabled": Proto.Value(bool_value=True),
"allowed": Proto.Value(bool_value=False),
},
),
),
},
),
)
```