# Pundit

> Minimal authorization through OO design and pure Ruby classes

Source: https://talira.ai/catalog/pundit-sdyy04t7
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [security / auth / authorization](https://talira.ai/categories/security/auth/authorization), [languages / ruby / rails](https://talira.ai/categories/languages/ruby/rails)
- Platforms: linux, macos, windows
- Licence: MIT
- Pricing: Free and open source
- Free tier: yes
- Self-hostable: yes
- Backed by: [Varvet](https://talira.ai/orgs/varvet.md)
- Creator: Jonas Nicklas, who first released it in 2012

Pundit handles authorization in Rails with plain Ruby classes: each model gets a policy class whose methods (`update?`, `destroy?`) say whether a user may do something, and a scope class that limits which records a user can see. Controllers call `authorize` and `policy_scope`, and a check can fail any action that forgot to authorize. Varvet, a product studio in Sweden, maintains it; Jonas Nicklas first released it in 2012, and the README cites over 100 million downloads.

## Links

- GitHub: https://github.com/varvet/pundit
- Docs: https://www.rubydoc.info/gems/pundit

## Problems it solves

- decide who can edit or delete each record in my Rails app
- only show users the records that belong to their team
- our permission checks are scattered across controllers and views
- make sure no controller action forgets to check permissions
- test authorization rules without hitting controllers
- hide the delete button from users who aren't allowed to delete
- simple role-based permissions without a big framework
- authorization logic in plain Ruby objects instead of a DSL

## Features

- policy classes per model
- policy scopes
- authorize and policy_scope helpers
- verify_authorized and verify_policy_scoped checks
- generators

## Trust

Overall: 0.56 out of 1.
Signals: maintenance 0.54, adoption 0.79, momentum 0.52, community 0.87, backing 0.50, extensibility 0.00.

- last commit 38 days ago
- 14 commits in the last 90 days
- 8.5k GitHub stars
- 150 contributors
- backed by Varvet
- created by Jonas Nicklas, who first released it in 2012

## Alternatives

- [CanCanCan](https://talira.ai/catalog/cancancan-fdzdzsq8.md): The authorization Gem for Ruby on Rails
- [Ory](https://talira.ai/catalog/ory-9g8j29sf.md): Headless, cloud-native identity: authentication, OAuth2/OIDC and permissions
- [Apache Casbin](https://talira.ai/catalog/apache-casbin-q0j8c46t.md): An authorization library that supports access control models like ACL, RBAC, ABAC
