Skip to content

A fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin

License

Notifications You must be signed in to change notification settings

Dayforce/fastapi-admin

 
 

Repository files navigation

FastAPI Admin

image image image image

中文文档 한국어 문서 日本語ドキュメント

Introduction

fastapi-admin is a fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin.

This fork adds a code-based role management system that allows developers to define and control access permissions directly in code rather than through database models.

Features

  • Standard FastAPI-Admin features
  • Extended role-based access control:
    • Define roles and permissions directly in code
    • Control access at model, action, and field levels
    • No database configuration for permissions needed
    • Better security and version control for roles
    • Multiple predefined role types and creation helpers

Installation

> pip install fastapi-admin

Requirements

Online Demo

You can check a online demo here.

  • username: admin
  • password: 123456

Or pro version online demo here.

  • username: admin
  • password: 123456

Role-Based Access Control

This fork implements a code-based permission system that allows defining roles and permissions in code:

# Define a role with specific permissions
EDITOR_ROLE = Role(
    name="editor",
    permissions=[
        Permission(model_name="category", action=PermissionAction.READ),
        Permission(model_name="category", action=PermissionAction.CREATE),
        Permission(model_name="category", action=PermissionAction.UPDATE),
        Permission(model_name="product", action=PermissionAction.READ),
    ]
)

# Register the role
register_role(EDITOR_ROLE)

# Use helper functions to create common roles
CATALOG_VIEWER = create_viewer_role(["category", "product"])

To use the role-based system:

  1. Define roles in your application
  2. Register the CodePermissionProvider in your app
  3. Assign roles to administrators through the role_names field

See examples/code_based_auth.py for a complete example.

Screenshots

Run examples in local

  1. Clone repo.

  2. Create .env file.

    DATABASE_URL=mysql://root:123456@127.0.0.1:3306/fastapi-admin
    REDIS_URL=redis://localhost:6379/0
  3. Run docker-compose up -d --build.

  4. Visit http://localhost:8000/admin/init to create first admin.

Documentation

See documentation at https://fastapi-admin-docs.long2ice.io.

License

This project is licensed under the Apache-2.0 License.

Credits

image

NodeSupport supports this project.

About

A fast admin dashboard based on FastAPI and TortoiseORM with tabler ui, inspired by Django admin

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • HTML 70.5%
  • Python 29.1%
  • Other 0.4%