Skip to main content

Injectable FastAPI auth via OIDC

Project description

main build github issues pull requests github contributors python versions pypi version license
Logo

An Omnivector Solutions initiative

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

  2. 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!")
  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-0.9.0.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

armasec-0.9.0-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: armasec-0.9.0.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.12 Linux/5.10.60.1-microsoft-standard-WSL2

File hashes

Hashes for armasec-0.9.0.tar.gz
Algorithm Hash digest
SHA256 57ca4b3d78d8f759af9b86170fb3764b48890cc943adc1badf99e76820cb8d6d
MD5 d89cde610e573ed40475ea1ac23bce23
BLAKE2b-256 90347f94444befea57f206e510a4881cb9d7b39e5e8b93068df75c20ed311a34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: armasec-0.9.0-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.11 CPython/3.8.12 Linux/5.10.60.1-microsoft-standard-WSL2

File hashes

Hashes for armasec-0.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e679f66236a0c4535e6516715bbec01da6cc4587416645b90bcd70cd8eff00b1
MD5 7e6f8b9b285de4bef52171ce77314a05
BLAKE2b-256 6ec861486a8a42372d8d8fce17dcbad08b2af362d9c7a599515fca2f4cc693e0

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