A simple Elixir library for defining readable, declarative permission rules using pattern matching.
Canada is an Elixir library that provides a friendly interface for leveraging Elixir's pattern matching to create clean, declarative permission rules in applications. It offers a lightweight alternative to more complex authorization libraries, focusing on simplicity and readability without external dependencies.
Elixir developers building applications that require straightforward, maintainable authorization logic, particularly those who prefer using Elixir's native pattern matching and protocols over heavier, dependency-laden solutions.
Developers choose Canada for its minimalistic, dependency-free design that uses Elixir's built-in pattern matching and protocols to define permissions in a readable, declarative syntax, avoiding the complexity and bloat of larger authorization libraries.
Easy permission definitions in Elixir apps!
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 Elixir's native pattern matching to define permissions in a clear, match-based syntax, as demonstrated in the protocol implementation for User and Post structs in the README.
Has no external dependencies, keeping the library lightweight and stable over time, as highlighted in the key features and author's note about minimal activity.
Rules are written in a declarative style, making permissions easy to understand and maintain, evidenced by the sample code showing can? macro usage with intuitive matches.
Implements the Canada.Can protocol for custom structs, enabling flexible rule definitions per resource type, as shown with the User struct example allowing custom actions like :update or :read.
The README explicitly recommends Canary for Ecto/Plug integration, indicating Canada lacks built-in database query scoping or middleware features for web applications.
Requires defining the Canada.Can protocol for each subject struct, which can be verbose and repetitive for applications with many resource types, adding setup complexity.
Focuses on simple permission checks without advanced features such as role inheritance, permission caching, or dynamic rule evaluation, as admitted in the philosophy favoring simplicity over bloat.