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.
- 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
> pip install fastapi-adminYou can check a online demo here.
- username:
admin - password:
123456
Or pro version online demo here.
- username:
admin - password:
123456
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:
- Define roles in your application
- Register the
CodePermissionProviderin your app - Assign roles to administrators through the
role_namesfield
See examples/code_based_auth.py for a complete example.
-
Clone repo.
-
Create
.envfile.DATABASE_URL=mysql://root:123456@127.0.0.1:3306/fastapi-admin REDIS_URL=redis://localhost:6379/0
-
Run
docker-compose up -d --build. -
Visit http://localhost:8000/admin/init to create first admin.
See documentation at https://fastapi-admin-docs.long2ice.io.
This project is licensed under the Apache-2.0 License.
NodeSupport supports this project.


