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.3.tar.gz (3.0 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

armasec-3.0.3-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: armasec-3.0.3.tar.gz
  • Upload date:
  • Size: 3.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for armasec-3.0.3.tar.gz
Algorithm Hash digest
SHA256 a8c0e5edc38a1581ed607494a17fb8bfb4573f716efe5b53a9546f9e61c037bd
MD5 1e816e54424dfad4a01a67a2a28e9d50
BLAKE2b-256 4179cdc45753b386878547872b8b787ded012fe5a701558294c5aa8d60bc27cb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: armasec-3.0.3-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for armasec-3.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 76f5e09e43b04b83cd4fcbcfaa9ca81427b25134101edc3dde07796f7d5d2627
MD5 5bf81e17927e41e236e79ec5681de878
BLAKE2b-256 92506818db4ddb1e77164d0b696b6f24021e851fe9dea95e39564ce7b7202a85

See more details on using hashes here.

Supported by

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