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 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.27.tar.gz (4.6 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.27-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: verifyauth-0.1.27.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for verifyauth-0.1.27.tar.gz
Algorithm Hash digest
SHA256 8a95718531a6a13a6559a49dab30d5b6c236cf5e1320e763a15513d301c22469
MD5 76c1b6e65960f9d591c65a5f68668070
BLAKE2b-256 a2905b1fc42c299efbf011c8ab2918f18066dff263d7401cf05db03d17c44d69

See more details on using hashes here.

File details

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

File metadata

  • Download URL: verifyauth-0.1.27-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.3

File hashes

Hashes for verifyauth-0.1.27-py3-none-any.whl
Algorithm Hash digest
SHA256 9959d8e9f8e937a13ceb5e41809421e83ca1f5aab6e100e556d9e3b6dc6e20ce
MD5 873f1f8911ca66ffe7182bf0f9608baf
BLAKE2b-256 ca03b760f78e2e475a658429ed2d678f6bbf08f076a5fe4b1e3e953bc7d0d2d8

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