Skip to content
This repository has been archived by the owner on Nov 19, 2023. It is now read-only.
/ fastapimsal Public archive

Authorization for FastAPI using Microsoft Azure Active Directory

License

Notifications You must be signed in to change notification settings

OscartGiles/fastapimsal

Repository files navigation

This project has moved to a fork maintained by the Alan Turing Institute

FastAPI Auth

This is a WIP and should not be used in production

Authenticate users with FastAPI using the Microsoft MSAL Library and Azure Active Directory.

Getting started

Python dependencies

To get started install Poetry.

Then ensure all dependencies are installed:

poetry install

Pre-commit

Run to make CI-tests pass

poetry run pre-commit run --all-files

Examples

See examples/app.py for a simple example.

Create a .auth.env file:

echo "session_expire_time_minutes=1
session_secret=<Session-Cookie-Secret>
client_id=<Application-client-id>
client_secret=<Application-Client-secret>
tenant_id=<Tenant-id" > .auth.env

For the session_secret its a good idea to create a secret with openssl rand -hex 32

To run the example

poetry run uvicorn --reload --app-dir examples app:app --reload-dir examples

About

Authorization for FastAPI using Microsoft Azure Active Directory

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages