Skip to main content

Biblioteca de autenticação e autorização para Keycloak com suporte a permissões contextuais - Python

Project description

aicp-auth-python

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

Instalação

pip install aicp-auth-python

Uso

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

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.

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

aicp_auth_python-1.0.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

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

aicp_auth_python-1.0.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file aicp_auth_python-1.0.0.tar.gz.

File metadata

  • Download URL: aicp_auth_python-1.0.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for aicp_auth_python-1.0.0.tar.gz
Algorithm Hash digest
SHA256 3309e03ad2dda09cb68acae327ca0e1fa13bace21c1955cea57a9e17d3dc8dea
MD5 e05f6af3576a376c98402c1614bf6522
BLAKE2b-256 8018a469a5070def920ec4f05a1c698fbd70363ef535f8bcdcd3e0efbfa454b6

See more details on using hashes here.

File details

Details for the file aicp_auth_python-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aicp_auth_python-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da264748a0cf36e95939c9f0e3aa57e5ce0346cff23e439b0ec19033ba8f226f
MD5 f7ffe3f21265e0d8f7f54c08b2497f3a
BLAKE2b-256 43676d3675dd4ec3d5c73782e6391d27aa0b3857d99f005eb503576d77a4d39b

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