Skip to content

ncstate-sat/auth_checker

Repository files navigation

Auth Checker

Release Status

A library for authorizing users based on their assigned roles, parsed from their JWT payload.

  • Free software: MIT

Usage

Authorize a read operation

from auth_checker import AuthChecker
from fastapi import APIRouter, Depends

# authorize a user with "personnel_read" permissions to look up personnel
@router.get("", tags=["Personnel"], dependencies=[Depends(AuthChecker("personnel_read"))])

Authorize an update operation

from auth_checker import AuthChecker
from fastapi import APIRouter, Depends

# authorize a user with "personnel_write" permissions to disable personnel
@router.post("/disable", tags=["Personnel"], dependencies=[Depends(AuthChecker("personnel_write"))])