Skip to main content

gRPC client for Aserto Authorizer service instances

Project description

Aserto Authorizer gRPC client

This is an automatically generated client for interacting with Aserto's Authorizer service using the gRPC protocol.

Installation

Using Pip

pip install aserto-authorizer-grpc

Using Poetry

poetry add aserto-authorizer-grpc

Usage

from aserto_authorizer_grpc.aserto.api.v1 import (
    IdentityContext,
    IdentityType,
    PolicyContext,
)
from aserto_authorizer_grpc.aserto.authorizer.authorizer.v1 import (
    AuthorizerStub,
    DecisionTreeOptions,
    DecisionTreeResponse,
    PathSeparator,
    Proto,
)
from grpclib.client import Channel


async with Channel(host=host, port=port, ssl=True) as channel:
    headers = {
        "aserto-tenant-id": TENANT_ID,
        "authorization": f"basic {ASERTO_API_KEY}"
    }

    client = AuthorizerStub(channel, metadata=headers)

    response = await client.decision_tree(
        policy_context=PolicyContext(
            id=ASERTO_POLICY_ID,
            path=ASERTO_POLICY_PATH_ROOT,
            decisions=["visible", "enabled", "allowed"],
        ),
        identity_context=IdentityContext(type=IdentityType.IDENTITY_TYPE_NONE),
        resource_context=Proto.Struct().from_dict(value={})),
        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),
                        },
                    ),
                ),
            },
        ),
    )

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aserto-authorizer-grpc-0.2.1.tar.gz (53.8 kB view details)

Uploaded Source

Built Distribution

aserto_authorizer_grpc-0.2.1-py3-none-any.whl (59.1 kB view details)

Uploaded Python 3

File details

Details for the file aserto-authorizer-grpc-0.2.1.tar.gz.

File metadata

  • Download URL: aserto-authorizer-grpc-0.2.1.tar.gz
  • Upload date:
  • Size: 53.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.8 CPython/3.7.11 Darwin/20.3.0

File hashes

Hashes for aserto-authorizer-grpc-0.2.1.tar.gz
Algorithm Hash digest
SHA256 48ad82579ba08bfa4e9a747b81012e1eb6d2c66fb385f409351d2d23e706ccca
MD5 812948d8f8ab524404c5071bb0580525
BLAKE2b-256 b03c52a284f3e7dbe16293b48ec58d048684dbba3afeb346f1085fa49b6d25cb

See more details on using hashes here.

File details

Details for the file aserto_authorizer_grpc-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aserto_authorizer_grpc-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8a6332eb2b675f8038bcbfe11b2d1c445a617cee909b145e1befda09586c93d0
MD5 c10e79cc2cdbec9ec4537d20557ba43f
BLAKE2b-256 d4b6b6ca2615c81dde579a1d4df80c3bb3c076c2ae7127f9aa47f6484f1b7694

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page