A lightweight, generic role-based access control (RBAC) library for Go applications with inheritance and custom assertions.
goRBAC is a Go library that implements a lightweight Role-Based Access Control (RBAC) system. It allows developers to define roles, assign permissions to those roles, and check if a role (or inherited roles) grants access to a specific permission. It solves the problem of managing complex authorization logic in Go applications with a clean, generic API.
Go developers building applications that require structured permission management, such as web services, APIs, or internal tools where users have different access levels based on roles.
Developers choose goRBAC for its simplicity, type safety through Go generics, support for role inheritance, and flexibility with custom assertion functions. It's a focused library that does one thing well without pulling in unnecessary dependencies.
goRBAC provides a lightweight role-based access control (RBAC) implementation in Golang.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses Go 1.18+ generics to support custom ID types like strings, integers, or structs, ensuring compile-time safety and flexibility for diverse projects.
Allows roles to inherit permissions from parent roles, simplifying management of complex authorization hierarchies as shown in the SetParent examples.
Enables custom logic for fine-grained permission checks beyond role assignments, demonstrated in the advanced checking section with assertion callbacks.
RBAC instances can be adjusted at runtime safely, making it suitable for dynamic environments where roles or permissions change frequently.
Includes built-in functions like AnyGranted and AllGranted for common permission checks, reducing boilerplate code in authorization logic.
The library lacks storage mechanisms; developers must implement persistence separately, as admitted in the README with a link to an external blog post.
Requires explicit creation and assignment of roles and permissions, which can be verbose and error-prone for large-scale systems with many entities.
While generic, it doesn't provide pre-built middleware or integrations with popular Go web frameworks, forcing custom implementation for common use cases.