Skip to main content

aicp-auth-python

Biblioteca de autenticação e autorização para Keycloak - Python

Instalação

Instalação Básica

pip install aicp-auth-python

Isso instala apenas as dependências básicas. Para usar com Flask ou FastAPI, instale as dependências extras:

Com Flask

pip install aicp-auth-python[flask]

Com FastAPI

pip install aicp-auth-python[fastapi]

Uso

Importação Básica

# Funciona sempre, mesmo sem Flask/FastAPI
from aicp_auth import KeycloakClient, AuthConfig, User

Flask

# Certifique-se de ter instalado: pip install aicp-auth-python[flask]
from aicp_auth import flask_auth_middleware, AuthConfig

config = AuthConfig(
    url="https://keycloak.example.com",
    realm="my-realm",
    client_id="my-client"
)

@app.route('/api/protected')
@flask_auth_middleware(config)
def protected_route():
    return {'user': g.user.__dict__}

FastAPI

# Certifique-se de ter instalado: pip install aicp-auth-python[fastapi]
from aicp_auth import fastapi_auth_middleware, AuthConfig, User

config = AuthConfig(
    url="https://keycloak.example.com",
    realm="my-realm",
    client_id="my-client"
)

get_current_user = fastapi_auth_middleware(config)

@app.get('/api/protected')
def protected_route(user: User = Depends(get_current_user)):
    return {'user': user.__dict__}

Documentação Completa

Veja a documentação principal para mais detalhes.

Metadata

Release files for aicp-auth-python 1.0.1

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

Source distribution (sdist)

Source distribution for aicp-auth-python 1.0.1
File Size Uploaded Provenance
aicp_auth_python-1.0.1.tar.gz 11.3 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for aicp-auth-python 1.0.1
File Interpreter ABI Platform
aicp_auth_python-1.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 22.0 kB

Release files / aicp_auth_python-1.0.1.tar.gz

Download URL aicp_auth_python-1.0.1.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a7bab1266694885b107888e768464446aa1e12b330939319f24eb887bcca1fdf
BLAKE2b-256 checksum
How to use checksums
815feec92585c422873ee8255863a45771e9f4146ccfe64921e732d1d7388353
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Release files / aicp_auth_python-1.0.1-py3-none-any.whl

Download URL aicp_auth_python-1.0.1-py3-none-any.whl
Size 10.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19bd9a0ebc0a401e9233a2a8bf54bfd026d21d30283ea6709c655227ddc7578e
BLAKE2b-256 checksum
How to use checksums
dadd06daffe3b9bd077fa8cb64cce96d3f037f35b73062d142f6d0c4914e1ca7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.2

Security for aicp-auth-python 1.0.1

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.

Release history Release notifications | RSS feed

This release

1.0.1 This release

2 release files No provenance

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