Skip to main content

The simpliest way to secure your API with preset token

Project description

FastAPI Simple Bearer (FSB)

This library provides you with ability to secure your endpoints with preset token (or tokens) in the "Authorization: Bearer" header

[!CAUTION] There are negative potential consequences of using a hard coded token.

You may want to use JWT tokens: https://github.com/sijokun/async-fastapi-jwt-auth

Installation

The easiest way to start working with this library is to install it from pip

pip install fastapi-simple-bearer

Example of usage

Basic usage:

from fastapi import Depends, FastAPI
from fastapi_simple_bearer import FSB, FSBToken

app = FastAPI()

fsb = FSB(token="SUPER_SECRET_TOKEN")

@app.get("/secure")
async def secure(auth: FSBToken = Depends(fsb)):
    return {"token": auth.token}

Other examples are available in examples folder

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

fastapi_simple_bearer-0.1.2.tar.gz (2.4 kB view details)

Uploaded Source

Built Distribution

fastapi_simple_bearer-0.1.2-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_simple_bearer-0.1.2.tar.gz.

File metadata

  • Download URL: fastapi_simple_bearer-0.1.2.tar.gz
  • Upload date:
  • Size: 2.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for fastapi_simple_bearer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 766f199e0656854cb0c4d14df4fa328afaa06e7d13afd25b96723954f29fb9e2
MD5 315036e51fd76efd5b3c41a56d4cf9aa
BLAKE2b-256 1819b96e44343cf8e785e9acb87c00ca5a890c39cc95a97d48c25ec9fb64171c

See more details on using hashes here.

File details

Details for the file fastapi_simple_bearer-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_simple_bearer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e4a28ea1bf8435fd306003e6c43d3100d60a39ea3abc4eabb8a617e34246337a
MD5 91654a42475f28e9cc842eb369f8540a
BLAKE2b-256 39e2d0b8ee2c89b06b445579717fcb97993c375c68b53c9a78256abb30fb6cfe

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page