Injectable FastAPI auth via OIDC
Project description
Armasec
Adding a security layer on top of your API can be difficult, especially when working with an OIDC platform. It’s hard enough to get your OIDC provider configured correctly. Armasec aims to take the pain out of securing your APIs routes.
Armasec is an opinionated library that attemtps to use the most obvious and commonly used workflows when working with OIDC and making configuration as simple as possible.
When using the Armasec helper class, you only need two configuration settings to get going:
Domain: the domain of your OIDC provider
Audience: An optional setting that restricts tokens to those intended for your API.
That’s it! Once you have those settings dialed in, you can just worry about checking the permissions scopes of your endpoints
Documentation
Documentation is hosted hosted on github.io at the Armasec homepage
Quickstart
Install armasec and uvicorn:
$ pip install armasec
Minimal Example (example.py)
import os
from armasec import Armasec
from fastapi import FastAPI, Depends
app = FastAPI()
armasec = Armasec(
os.environ.get("ARMASEC_DOMAIN"),
audience=os.environ.get("ARMASEC_AUDIENCE"),
)
@app.get("/stuff", dependencies=[Depends(armasec.lockdown("read:stuff"))])
async def check_access():
return dict(message="Successfully authenticated!")
Run the app
$ uvicorn –host 0.0.0.0 example:app
License
Distributed under the MIT License. See LICENSE for more information.
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
File details
Details for the file armasec-0.7.1.tar.gz
.
File metadata
- Download URL: armasec-0.7.1.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.8.10 Linux/5.8.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69f1129ded0d63e7c2a8ab9d14445255abd4d2e7d533ac4959add801083314f8 |
|
MD5 | 038e2261b295cebaca53dcf445d8e7b5 |
|
BLAKE2b-256 | 0b1dc70657f8b25a96b0d49aac0279123604d64367d3fe4d67f38e37401b7dd6 |
File details
Details for the file armasec-0.7.1-py3-none-any.whl
.
File metadata
- Download URL: armasec-0.7.1-py3-none-any.whl
- Upload date:
- Size: 16.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.11 CPython/3.8.10 Linux/5.8.0-1042-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48e70b1072dbb934a623a113b7f12c500d8c44e9bee09e7c1cccdd81b0a3766d |
|
MD5 | de81c84345f70cea8e1ecbf22e91fba4 |
|
BLAKE2b-256 | e68939bcc83ae09e8abb96cbb6a941d75243c9d0ecbca0d82277231a99130fa9 |