百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

acl9

> 编程语言
开源

又一个基于角色的授权系统,适用于 Rails

849 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

又一个基于角色的授权系统,适用于 Rails

acl9

Acl9 是一个基于角色的授权系统,提供了一个简洁的 DSL, 保护您的 Rails 应用程序。 如果你不确定自己是否正确执行了访问控制,那么它就毫无意义。 ACL9 的基本目标是确保您的规则易于理解和使用。 易于测试 - 换句话说, ACL9 使您能够轻松确保您已正确配置了 权限正确。

安装

Acl9 是 语义版本化 的,所以只需将其添加到您的 Gemfile (请注意,您需要 3.2 才能支持 Rails 6+):

ruby
gem 'acl9', '~> 3.2'

我们只测试了 Ruby >= 3.1,对于低于这个版本的情况,情况可能会有所不同

Rails 4 - 继续使用 2.x

ruby
gem 'acl9', '~> 2.0'

Rails 0.12'


## Getting Started

The simplest way to demonstrate this is with some examples.

### Access Control

You declare the access control directly in your controller, so it's visible and
obvious for any developer looking at the controller:

ruby class Admin::SchoolsController 学校 allow :admins, :managers, :teachers, :of => :school deny :teachers, :only => :destroy action: index do 允许匿名、已登录 结束 允许 logged_in, :only => :show deny :students 结束 def index

…

结束

…

结束


You can see more about all this stuff in the wiki under [Access Control
Subsystem](//github.com/be9/acl9/wiki/Access-Control-Subsystem)

### Roles

The other side of acl9 is where you give and remove roles to and from a user. As
you're looking through these examples refer back to the [Access
Control](#access-control) example and you should be able to see which access
control rule each role corresponds to.

Let's say we want to create an admin of a given school, not a global admin, just
the admin for a particular school:

ruby user.has_role! :admin, school user.has_role! :admin, of: school


Then let's say we have some support people in our organization who are dedicated
to supporting all the schools. We could do two things, either we could come up
with a new role name like `:school_support` or we can use the fact that we can
assign roles to any object, including a class, and do this:

ruby user.has_role! :support, 学校 us

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Ruby

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言