Adds Pyramid-inspired row-level security and declarative permissions to FastAPI applications.
FastAPI Permissions is a Python library that adds a Pyramid-inspired, declarative row-level security system to FastAPI applications. It allows developers to define fine-grained permissions on resources using Access Control Lists (ACLs), enabling authorization decisions based on both the user's identity and the resource's state. It solves the problem of implementing complex, resource-aware permission logic beyond simple OAuth2 scopes.
FastAPI developers building applications that require fine-grained, resource-state-dependent authorization, such as content management systems, multi-tenant SaaS platforms, or scientific workflow tools.
Developers choose FastAPI Permissions because it provides a centralized, declarative way to handle complex permissions, reducing boilerplate code in route handlers. Its unique selling point is the Pyramid-derived ACL model, which is more expressive than scopes when permissions depend on resource state.
row level security for FastAPI framework
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables defining permissions directly on resources using an __acl__ attribute, centralizing authorization logic and reducing boilerplate in route handlers, as shown in the example with Item and User models.
Allows permissions to depend on both user principals and resource state, such as draft or published status, supporting complex workflows like scientific paper submissions mentioned in the README.
Derived from Pyramid's security system, offering a reliable and familiar pattern for developers experienced with that framework, reducing the learning curve for those migrating.
Works as a FastAPI dependency that can be easily injected into path operations via the Permission helper, maintaining the framework's declarative style without invasive changes.
Requires implementing a custom get_active_principals function to map users to identifiers, adding initial boilerplate and complexity compared to out-of-the-box solutions.
ACLs are checked in the order provided, which can lead to subtle bugs and debugging challenges if rules are not carefully sequenced, as warned in the README.
As a smaller library inspired by Pyramid, it has a limited ecosystem with fewer community resources, plugins, or updates compared to mainstream authorization tools.