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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
766f199e0656854cb0c4d14df4fa328afaa06e7d13afd25b96723954f29fb9e2
|
|
| MD5 |
315036e51fd76efd5b3c41a56d4cf9aa
|
|
| BLAKE2b-256 |
1819b96e44343cf8e785e9acb87c00ca5a890c39cc95a97d48c25ec9fb64171c
|
File details
Details for the file fastapi_simple_bearer-0.1.2-py3-none-any.whl.
File metadata
- Download URL: fastapi_simple_bearer-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e4a28ea1bf8435fd306003e6c43d3100d60a39ea3abc4eabb8a617e34246337a
|
|
| MD5 |
91654a42475f28e9cc842eb369f8540a
|
|
| BLAKE2b-256 |
39e2d0b8ee2c89b06b445579717fcb97993c375c68b53c9a78256abb30fb6cfe
|