Skip to main content

A decorator for FastAPI to verify authentication and authorization via an external service.

Project description

python-ws-microservico-modulo-verificar-autenticacao-service

This project provides a decorator for FastAPI to verify authentication and authorization via an external service.

Features

  • A FastAPI-compatible decorator for authentication and authorization.
  • Easy integration with external authentication services.
  • Customizable to fit different authentication flows.

Installation

You can install the module using pip:

pip install verifyauth

Usage

This package allows you to add an authentication layer to FastAPI endpoints via a decorator. Example usage:

from verifyauth import AuthDecorator
from fastapi import FastAPI

app = FastAPI()

auth = AuthDecorator(service_url="https://auth.example.com")

@app.get("/protected")
def verifyauth(servico, capacidade, response_tag = 'obterVipCadastroResponse2', result_tag = 'obterVipCadastroResult2'):
@verifyauth(servico='example', capacidade='test', response_tag='capacidadeServicoResponse', result_tag='capacidadeServicoResult')    
def protected_endpoint():
    return {"message": "This is a protected route"}

Build and Deployment

Build the Package

Before deploying the package to TestPyPI or PyPI, you need to build the distribution files. The build process will create both a source distribution (.tar.gz) and a wheel distribution (.whl).

To build the package, first ensure the build module is installed:

pip install build

Then, run the following command to create the distribution files:

python -m build

This will generate the distribution files in the dist/ directory.

Upload to TestPyPI

To upload the package, first ensure the twine module is installed:

pip install twine

To upload the package to TestPyPI for testing purposes:

twine upload --repository-url https://test.pypi.org/legacy/ dist/*

After uploading, you can install it from TestPyPI using:

pip install --index-url https://test.pypi.org/simple/ verifyauth

Upload to PyPI

Once you've tested the package on TestPyPI and are ready to publish it, upload it to PyPI:

twine upload dist/*

You can then install it via PyPI using:

pip install verifyauth

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

verifyauth-0.1.31.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

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

verifyauth-0.1.31-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file verifyauth-0.1.31.tar.gz.

File metadata

  • Download URL: verifyauth-0.1.31.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for verifyauth-0.1.31.tar.gz
Algorithm Hash digest
SHA256 1c24c22b51a69a65cbc2f2997fb8fa49a14a0226f241920b350b8e74bba7b978
MD5 b4662acbcd7fac3a6c45053452342cdf
BLAKE2b-256 6099a0ff44e2f2b9ebc5a2bc1a268db61fc8ee4289c291a28f5323ab6202e253

See more details on using hashes here.

File details

Details for the file verifyauth-0.1.31-py3-none-any.whl.

File metadata

  • Download URL: verifyauth-0.1.31-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.11

File hashes

Hashes for verifyauth-0.1.31-py3-none-any.whl
Algorithm Hash digest
SHA256 af24b86335117fe4bcc585141a7a164814763e8dea7aae90e907c7893f30e8cd
MD5 6fa796d911b62364213f55b474e21ef8
BLAKE2b-256 0d75b268fe80cdb068d333c763d611f436f14542106c00530c2470ba55110791

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