🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

fastapi-simple-bearer

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastapi-simple-bearer

The simpliest way to secure your API with preset token

0.1.2
Source
PyPI
Maintainers
1

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

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts