Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Integrate Casbin and FastAPI to support access control #745

@shizidushu

Description

@shizidushu

Is your feature request related to a problem? Please describe.
It is a useful addition to have access control over FastAPI. Some framework have builtin support and some can get this feature with a plugin.

Describe the solution you'd like
According to its docs, Casbin provides support for enforcing authorization based on various access control models.
Here is the function I image:

  • Check permission before handle the request. Maybe implement is using a custom class APIRoute class.
  • Sync FastAPI path operation with Casbin policy file (or policy storage adapter).
    Maybe a function to execute on application startup; it gets all path operation's path, method and some other optional information like tags, user_id and user_role, then write it to Casbin policy file.
    It cleans redundant row in Casbin policy file and keep it update with FastAPI routes.
  • Document to describe how to use it (with example code).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions