CanCan is an authorization library for Ruby on Rails that helps manage user permissions in a clean and consistent way. It centralizes all authorization logic in a single Ability class, where you define what actions each type of user can or cannot perform on different resources. Developers then use helpers like authorize! in controllers or can? in views to enforce those rules without scattering permission logic across the application. It supports defining permissions using conditions, allowing granular access based on attributes like ownership or role. Because it abstracts authorization cleanly, applications stay easier to read, test, and maintain as business rules evolve. Though no longer actively maintained in its original form, CanCan inspired forks and successors (such as CanCanCan) that continue to be widely used in Rails projects.

Features

  • Define user permissions in a single Ability class rather than scattering logic across controllers and views
  • Helper methods in controllers and views like can?, cannot?, authorize! to test or enforce permissions
  • load_and_authorize_resource support: automatically loading resources and checking abilities for RESTful controllers
  • Ability to rescue from unauthorized access exceptions and handle accordingly (redirect, flash message, etc.)
  • Checks for authorization in all actions, with a mechanism to skip authorization where needed, or ensure it's always checked with check_authorization
  • Integration with Rails conventions (current_user, filters, controller/view helpers) so minimal boilerplate required in Rails apps using it

Project Samples

Project Activity

See All Activity >

Categories

Libraries

License

MIT License

Follow CanCan

CanCan Web Site

Other Useful Business Software
Our Free Plans just got better! | Auth0 Icon
Our Free Plans just got better! | Auth0

With up to 25k MAUs and unlimited Okta connections, our Free Plan lets you focus on what you do best—building great apps.

You asked, we delivered! Auth0 is excited to expand our Free and Paid plans to include more options so you can focus on building, deploying, and scaling applications without having to worry about your security. Auth0 now, thank yourself later.
Try free now
Rate This Project
Login To Rate This Project

User Reviews

Be the first to post a review of CanCan!

Additional Project Details

Operating Systems

Linux, Mac, Windows

Programming Language

Ruby

Related Categories

Ruby Libraries

Registered

2025-09-17