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.30.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.30-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: verifyauth-0.1.30.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.30.tar.gz
Algorithm Hash digest
SHA256 5d492d6f8fb6eb671193446ee6bf394843c9699efaaded1f5d621c4e204d0d92
MD5 042adf6fae0dddff5d6630aa24ad72bf
BLAKE2b-256 aacf79020c2a5a1edf4106f356cb836ae7438f66e1ba5304b15e64515ee699fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: verifyauth-0.1.30-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.30-py3-none-any.whl
Algorithm Hash digest
SHA256 d8fec298829b0cc1263b62ab47da1a3f8e09e7ff6bd438d22e34177c6cb0ec37
MD5 aa85d2941a4467df24f2662bb7ccb9c4
BLAKE2b-256 b17d837f3f961dfaf8b17a7b46641ef176bf76052bf986950d326be5cb3501e1

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