Skip to main content

Python SDK for Veza Open Authorization API

The oaaclient package provides data models, methods and a command-line interface for using the Open Authorization API. You can use it to format and publish user, resource, and authorization metadata for processing by a Veza instance.

For example usage, please see the samples directory. For more information on Veza visit https://www.veza.com.

What is OAA?

The Open Authorization API is used to submit authorization metadata for custom applications to a Veza instance for parsing and inclusion in the Entity Catalog.

  • A typical OAA-based integration will use APIs to query the source application for information about users, resources, and permissions, along with other authorization entities such as groups and roles.
  • This data payload is published to Veza as a JSON object. The oaaclient modules simplify building the required JSON model and pushing the payload to Veza via the REST API.
  • Any application or identity provider added using OAA becomes fully available for search, rules and alerts, and access reviews, similar to any officially-supported integration.

Using the SDK

The oaaclient SDK includes the following components:

  • oaaclient.client: Veza API communication (data provider management, payload push, etc.). Requires an API key for authentication.
  • oaaclient.templates: Classes for modeling and generating an OAA payload.
  • oaaclient.utils: Additional utility functions (icon encoding, etc.).

Sample Workflow

Create the Veza API connection and a new custom application:

from oaaclient.client import OAAClient
from oaaclient.templates.application import CustomApplication, OAAPermission

# creates a connection class to communicate with Veza
veza_con = OAAClient(url=veza_url, token=veza_api_key)

# creates a new Custom Application model
custom_app = CustomApplication(name="Sample App", application_type="sample")

Once the CustomApplication class is instantiated, you can use the public methods to populate the new app with local users, groups, resources, and permissions metadata:

custom_app.add_custom_permission("owner", [OAAPermission.DataRead, OAAPermission.DataWrite])
jane = custom_app.add_local_user("jane", identities="jane@example.com")
resource1 = custom_app.add_resource(name="Resource 1", resource_type="thing")
jane.add_permission(permission="owner", resources=[resource1])

AI Entities (Agents and Models)

The SDK supports AI entity types for modeling non-human AI identities:

# Create an AI model
model = custom_app.add_model(name="GPT-4", unique_id="gpt4", ai_platform="OpenAI", ai_model_publisher="OpenAI")

# Create an AI agent that references the model
agent = custom_app.add_agent(name="Support Bot", unique_id="bot-001", ai_platform="OpenAI")
agent.is_active = True
agent.add_model("gpt4")
agent.add_group("service_agents")
agent.add_permission("read", resources=[resource1])

Once all identities, permissions and resources are modeled, the client connection handles the final push to Veza:

veza_con.push_application(provider, data_source_name, application_object=custom_app)

For more examples see the samples directory.

OAuth2 Authentication

As an alternative to an API key, OAAClient can authenticate with a Veza OAuth2 client. Tokens are requested and refreshed automatically.

from oaaclient.auth import ClientCredentialsConfig, JWTBearerConfig
from oaaclient.client import OAAClient

# client ID and secret
veza_con = OAAClient(url, oauth_config=ClientCredentialsConfig(client_id="...", client_secret="..."))

# signed JWT assertion (requires `pip install oaaclient[jwt]`)
veza_con = OAAClient(url, oauth_config=JWTBearerConfig(client_id="...", private_key_path="key.pem"))

# or the PEM key as a base64 string, e.g. from a secret store
veza_con = OAAClient(url, oauth_config=JWTBearerConfig(client_id="...", private_key_base64=encoded_key))

With no arguments, the client reads VEZA_OAUTH_CLIENT_ID plus either VEZA_OAUTH_CLIENT_SECRET, VEZA_OAUTH_PRIVATE_KEY_PATH or VEZA_OAUTH_PRIVATE_KEY_BASE64 (the base64 encoded PEM key, e.g. base64 < key.pem | tr -d '\n') (optional: VEZA_OAUTH_KEY_ID, VEZA_OAUTH_PRIVATE_KEY_PASSWORD for an encrypted key, VEZA_OAUTH_SCOPE, VEZA_OAUTH_TOKEN_URL which must be https). An API key, when provided, always takes precedence (a warning is logged if both are set in the environment). JWT keys are loaded and validated when the config is created, a bad key raises ValueError. For the command line tool, the auth.json file can contain an oauth object instead of token, e.g. {"host": "...", "oauth": {"client_id": "...", "client_secret": "..."}}.

Command Line Use

The oaaclient can also be used as a command line tool for pushing completed OAA payloads to Veza for testing and debugging, without needing to make the API requests "by hand."

You will need the following JSON files:

  1. provider.json - must contain the provider name and template to use (application or idp).

    {
      "name": "ProviderName",
      "custom_template": "application"
    }
    
  2. auth.json - defines the Veza host and API key to use

    {
      "host": "https://demo.vezacloud.com",
      "token": "ZXlKaGJHY2lPaUpJ....."
    }
    
  3. payload.json - The complete OAA JSON body to submit. For full reference see the Veza documentation. This format must match the schema (template) selected in provider.json.

Once the above files are created, the payload can be pushed with the following command:

oaaclient  --provider provider.json --auth auth.json payload.json

The client will read the files and push the payload to Veza. The client will automatically create any required custom provider and data sources.

Handling Errors

The OAAClient class handles API connections to Veza. If there are errors connecting or the API returns errors OAAClient will raise an OAAClientError exception. If the payload does not conform to the template requirements the OAAClientError.details will contain a list of any issues encountered.

    try:
        response = veza_con.push_application(provider_name=provider_name,
                                             data_source_name=data_source_name,
                                             application_object=custom_app,
                                            )
        if response.get("warnings"):
            print("Push succeeded with warnings:")
            for w in response["warnings"]:
                print(w)
    except OAAClientError as e:
        print(f"Error: {e.error}: {e.message} ({e.status_code})", file=sys.stderr)
        if hasattr(e, "details"):
            for d in e.details:
                print(d, file=sys.stderr)

Additional documentation

Since any given source application or service will have different methods for retrieving entities, authorization, and other required metadata, each OAA connector will be slightly different. You should consult the API documentation for your application when considering how you will source the information, and refer to existing Veza-supported OAA connectors for real-world examples.

Connector source code and oaaclient modules are thoroughly annotated, for reference when building your own integrations.

For additional information on developing a custom OAA integration, please contact your Veza support team for access to the User Guide.

Metadata

Release files for oaaclient 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oaaclient 1.2.3
File Size Uploaded Provenance Actions
oaaclient-1.2.3.tar.gz 117.6 kB Without provenance Details for oaaclient-1.2.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for oaaclient 1.2.3
File Interpreter ABI Platform Actions
oaaclient-1.2.3-py3-none-any.whl Python 3 none any Details for oaaclient-1.2.3-py3-none-any.whl

Total release size: 198.0 kB

Release files / oaaclient-1.2.3.tar.gz

Download URL oaaclient-1.2.3.tar.gz
Size 117.6 kB
Tags Source
SHA-256 checksum
How to use checksums
e2e682f69a7f9db46dd204c919e7d5ba36f005e28bae230321a92cbdc8cac84b
BLAKE2b-256 checksum
How to use checksums
77bbe6d52b66689ddc60ea0cedc3c84c40b5ff35f80b463ae900d8c1cf6cc563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Release files / oaaclient-1.2.3-py3-none-any.whl

Download URL oaaclient-1.2.3-py3-none-any.whl
Size 80.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
285d4538cbe249fd4377b952c3aa6870daab697b0009b3569f37491f62697038
BLAKE2b-256 checksum
How to use checksums
13f30a4f1acd919979d14df4c8f5b7d7a523f008980dffab0e50153cdbf68184
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.15.2

Security for oaaclient 1.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page