Skip to main content

PAIG Authorizer Core

Project description

paig-authorizer-core

Overview

paig-authorizer-core is a Python library designed to provide a framework of interfaces and abstract classes for building custom authorization implementations. This library allows developers to define their own authorization logic while ensuring consistency and structure.

Features

  • Provides a set of interfaces and abstract classes.
  • Customizable implementations for various authorization scenarios.
  • Easy to extend and integrate into existing applications.

Installation

You can install the library using pip:

pip install paig-authorizer-core

Usage

To use the paig-authorizer-core library, follow these steps:

  1. Import the required classes:

    from paig_authorizer_core import BasePAIGAuthorizer
    from paig_authorizer_core.models.request_models import AuthzRequest, VectorDBAuthzRequest
    
  2. Create a custom authorizer class: Implement your own authorizer by extending the BasePAIGAuthorizer class:

    class MyCustomAuthorizer(BasePAIGAuthorizer):
        def get_user_id_by_email(self, email: str) -> Optional[str]:
            # Implementation to retrieve user ID by email
            pass
        
        def get_user_groups(self, user: str) -> List[str]:
            # Implementation to retrieve user groups
            pass
    
        # Implement other abstract methods...
    
  3. Instantiate your custom authorizer:

    authorizer = MyCustomAuthorizer()
    
  4. Create an authorization request:

    authz_request = AuthzRequest(
        user_id="user@example.com",
        application_key="MyApp",
        traits=["trait1"],
        request_type="access"
    )
    
  5. Authorize the request: Call the authorize method to check if the request is authorized:

    response = authorizer.authorize(authz_request)
    print(f"Authorization response: {response}")
    
  6. Create a VectorDB authorization request:

    vector_db_request = VectorDBAuthzRequest(
        user_id="admin@example.com",
        application_key="MyApp"
    )
    
  7. Authorize the VectorDB request: Call the authorize_vector_db method to check VectorDB access:

    vector_db_response = authorizer.authorize_vector_db(vector_db_request)
    print(f"VectorDB authorization response: {vector_db_response}")
    

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

paig_authorizer_core-0.0.2-py3-none-any.whl (25.0 kB view details)

Uploaded Python 3

File details

Details for the file paig_authorizer_core-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for paig_authorizer_core-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ad7c4ec562e19c4780feaeecad9663c86a6fbf3519089962f14dce2abb10b584
MD5 a329f490086fa08d186913b2c8240e09
BLAKE2b-256 ed52209cf691444284b65bf34df89c3dd041a29b0e9626310e773f1cad131998

See more details on using hashes here.

Supported by

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