# rolify

> Role management library with resource scoping

Source: https://talira.ai/catalog/rolify-sa4yfj7c
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [security / auth / role management](https://talira.ai/categories/security/auth/role-management), [languages / ruby / rails](https://talira.ai/categories/languages/ruby/rails)
- Licence: MIT[^3]
- Pricing: Free and open source[^3]
- Free tier: yes[^3]
- Self-hostable: yes[^1]
- API: yes[^1]
- Creator: Florent Monbillard

rolify stores users' roles in a Rails app, either global (`user.add_role :admin`) or scoped to a resource class or a single record (`user.add_role :moderator, Forum.first`), and answers `has_role?`, `with_role` and similar queries from both sides. A generator creates the Role model and its join table for Active Record, and it works with Mongoid too. It enforces nothing itself: you check roles from an authorization library such as [Pundit](https://talira.ai/catalog/pundit-sdyy04t7.md) or [CanCanCan](https://talira.ai/catalog/cancancan-fdzdzsq8.md), with any authentication such as [Devise](https://talira.ai/catalog/devise-n63ctza6.md). Strict mode, callbacks when roles are added or removed, and `has_cached_role?` for preloaded roles are options.

## Links

- Website: https://rolifycommunity.github.io/rolify/
- GitHub: https://github.com/RolifyCommunity/rolify
- Docs: https://github.com/RolifyCommunity/rolify/wiki

## Problems it solves

- give users roles like admin and moderator in my Rails app
- make someone a moderator of one forum but not the others
- list every user who is an admin of a given organization
- find all the projects a user has a manager role on
- store user roles in the database instead of a hardcoded string column
- give every new user a default role when they sign up
- check roles from my authorization policies without writing the join tables myself
- a role that applies to a whole class of records as well as to single records
- avoid an N+1 query when checking roles for a list of users
- assign and query roles on Mongoid models in a Rails app

## Features

- global, class-scoped and instance-scoped roles
- has_role?, has_strict_role? and has_cached_role? checks
- with_role, without_role, with_any_role and with_all_roles queries
- resourcify for models roles apply to
- generator for the Role model and migration
- before_add, after_add, before_remove and after_remove callbacks
- strict mode
- Active Record and Mongoid

## Limitations

- Doesn't enforce authorization: it stores and queries roles, and an authorization library does the checks[^1][^2]

## Capabilities

- Has an API: plan not known

## Trust

Overall: 0.28 out of 1.
Signals: backing 0.20, extensibility 0.20.

- created by Florent Monbillard

Warnings:

- GitHub activity not fetched yet

## Sources

[^1]: https://github.com/RolifyCommunity/rolify (checked 20 Nov 2026)
[^2]: https://rolifycommunity.github.io/rolify/ (checked 20 Nov 2026)
[^3]: https://github.com/RolifyCommunity/rolify/blob/master/LICENSE (checked 20 Nov 2026)
