Skip to main content

Injectable FastAPI auth via OIDC

Project description

Build Status Build Documentation

Python Versions PyPI Versions License

An Omnivector Solutions initiative

omnivector-logo

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:

  1. Domain: the domain of your OIDC provider
  2. 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

  1. Install armasec and uvicorn:
pip install armasec uvicorn
  1. Save th Minimal Example (example.py) locally:
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!")
  1. Set the Armasec environment variables:
  • ARMASEC_DOMAIN
  • ARMASEC_AUDIENCE
  1. Run the app
uvicorn --host 0.0.0.0 example:app

License

Distributed under the MIT License. See LICENSE for more information.

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

armasec-1.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

armasec-1.1.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file armasec-1.1.0.tar.gz.

File metadata

  • Download URL: armasec-1.1.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1042-azure

File hashes

Hashes for armasec-1.1.0.tar.gz
Algorithm Hash digest
SHA256 93b39f828d54aa16abef3aac844f127ca89a52c83ce3bc5843a402b57a61393f
MD5 3ae66c19c46ecb5a39796d98d1f8114a
BLAKE2b-256 a5996819b7efb28288b189734c99ce184d692fffafec0e78d0e8be10c806a144

See more details on using hashes here.

File details

Details for the file armasec-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: armasec-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.8.17 Linux/5.15.0-1042-azure

File hashes

Hashes for armasec-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dd2c7a11482824d1305b5b0c0bf94d2df1cecda8bd8daed87340d1080d260c54
MD5 84b72df14993034baa6c525dee8ba0c0
BLAKE2b-256 b08a935961691456c27823b8bb5d22c214e9b4aca87d8a1236002477e6c9e713

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