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.29.tar.gz (4.7 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.29-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for verifyauth-0.1.29.tar.gz
Algorithm Hash digest
SHA256 5a3af1403caceab5bdf5de18d433cee55d9091c1fdc61b5069561a42c3009bfe
MD5 04cd37348c08539873f6468aa374d9af
BLAKE2b-256 e3b08ca4c479c1964b14d32d747fb8302f9ede1935c5fe32e84ebedc1fc64fe3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for verifyauth-0.1.29-py3-none-any.whl
Algorithm Hash digest
SHA256 6ec40a79fca95f995eebab611f8e108c7544d1edf4305301bcf16095eaebeec4
MD5 685f198fc7c0285c9277c27aedd899fd
BLAKE2b-256 b6eae2d02fe1af068b40298d4cc96c0c30fde3cfa1057bc7f587886c7c5f1b22

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