Skip to main content

Injectable FastAPI auth via OIDC

Project description

Build Status Build Documentation

Python Versions PyPI Versions License

An Omnivector 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 attempts 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(
    domain=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-3.0.0.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

armasec-3.0.0-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: armasec-3.0.0.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.9.13 Linux/6.11.0-1013-azure

File hashes

Hashes for armasec-3.0.0.tar.gz
Algorithm Hash digest
SHA256 6d51445fbcf7815c9ba0569586f6b4a84cca6876edc5a19cf91cfe843132589a
MD5 70124cab459cdbfd48d506e9f8423a2d
BLAKE2b-256 a96cf39b28e9ea2c9a7eeb5211c2f1468950f3d68742e2577833a73dee36cd6a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: armasec-3.0.0-py3-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.3 CPython/3.9.13 Linux/6.11.0-1013-azure

File hashes

Hashes for armasec-3.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ae9070f4e4ebf69b88b5e5748f30634f461db3d68cb6fdc3fab0a9add0146506
MD5 93146261904cc033568b3957484d6c60
BLAKE2b-256 39aa2d0c18c9757c821576f9ac14e33c8ea5e2a3c40d9519789975ff989f981d

See more details on using hashes here.

Supported by

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