declarative_authorization 和 /authorization_rules 访问问题
我已配置为使用 authlogic 和 declarative_authorization 并配置了authorization_rules.rb。一切都很好,但在尝试访问 localhost/authorization_rules 时,我看到“您不允许访问此操作。”。我已经添加了,
has_permission_on :authorization_rules, :to => [:index, :show]
但没有任何改变:(在日志中我看到
Processing AuthorizationRulesController#index (for 127.0.0.1 at 2010-05-08 14:00:01) [GET]
Parameters: {"action"=>"index", "controller"=>"authorization_rules"}
User Load (1.0ms) SELECT * FROM "users" WHERE ("users"."id" = 1) LIMIT 1
SQL (1.8ms) BEGIN
User Update (0.6ms) UPDATE "users" SET "updated_at" = '2010-05-08 10:00:01.443532', "perishable_token" = E'Narj4gmDdGiCuna9p_ht', "last_request_at" = '2010-05-08 10:00:01.440280' WHERE "id" = 1
SQL (1.4ms) COMMIT
Role Load (1.3ms) SELECT "roles".* FROM "roles" INNER JOIN "assignments" ON "roles".id = "assignments".role_id WHERE (("assignments".user_id = 1))
Permission denied: No matching rules found for read for #<User id: 1, login: "alec", email: "[email protected]", crypted_password: "cb0af876f2ae63f40b82eb7b8eb24e1f739a3d80e6afd4e9e36...", password_salt: "SBdGRsh5roMoaYOANkHN", persistence_token: "e356eb5d39c032ca3088f2fe9868941f70c396a7ed7eb082028...", single_access_token: "nABARs1vURbXmp1Yuc6e", perishable_token: "Narj4gmDdGiCuna9p_ht", confirmed: true, active: true, activation_code: nil, activated_at: "2010-03-07 20:51:46", login_count: 9, failed_login_count: 0, last_request_at: "2010-05-08 10:00:01", current_login_at: "2010-04-09 18:38:24", last_login_at: "2010-04-06 20:03:25", current_login_ip: "127.0.0.1", last_login_ip: "127.0.0.1", friends_count: 0, created_at: "2010-03-07 20:51:20", updated_at: "2010-05-08 10:00:01"> (roles [:admin, :super_moderator, :news_moderator, :news_maker], privileges [:read], context :authorization_rules).
Filter chain halted as [:filter_access_filter] rendered_or_redirected.
任何想法?
i have configured to use authlogic and declarative_authorization and configured authorization_rules.rb. All is fine but on attemp to access localhost/authorization_rules i see "You are not allowed to access this action.". I've added
has_permission_on :authorization_rules, :to => [:index, :show]
but nothing changed :( In logs i see
Processing AuthorizationRulesController#index (for 127.0.0.1 at 2010-05-08 14:00:01) [GET]
Parameters: {"action"=>"index", "controller"=>"authorization_rules"}
User Load (1.0ms) SELECT * FROM "users" WHERE ("users"."id" = 1) LIMIT 1
SQL (1.8ms) BEGIN
User Update (0.6ms) UPDATE "users" SET "updated_at" = '2010-05-08 10:00:01.443532', "perishable_token" = E'Narj4gmDdGiCuna9p_ht', "last_request_at" = '2010-05-08 10:00:01.440280' WHERE "id" = 1
SQL (1.4ms) COMMIT
Role Load (1.3ms) SELECT "roles".* FROM "roles" INNER JOIN "assignments" ON "roles".id = "assignments".role_id WHERE (("assignments".user_id = 1))
Permission denied: No matching rules found for read for #<User id: 1, login: "alec", email: "[email protected]", crypted_password: "cb0af876f2ae63f40b82eb7b8eb24e1f739a3d80e6afd4e9e36...", password_salt: "SBdGRsh5roMoaYOANkHN", persistence_token: "e356eb5d39c032ca3088f2fe9868941f70c396a7ed7eb082028...", single_access_token: "nABARs1vURbXmp1Yuc6e", perishable_token: "Narj4gmDdGiCuna9p_ht", confirmed: true, active: true, activation_code: nil, activated_at: "2010-03-07 20:51:46", login_count: 9, failed_login_count: 0, last_request_at: "2010-05-08 10:00:01", current_login_at: "2010-04-09 18:38:24", last_login_at: "2010-04-06 20:03:25", current_login_ip: "127.0.0.1", last_login_ip: "127.0.0.1", friends_count: 0, created_at: "2010-03-07 20:51:20", updated_at: "2010-05-08 10:00:01"> (roles [:admin, :super_moderator, :news_moderator, :news_maker], privileges [:read], context :authorization_rules).
Filter chain halted as [:filter_access_filter] rendered_or_redirected.
any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我在我的应用程序中使用 authlogic 和 declarative_authorization,它对我来说效果很好。
在 config/authorization_rules.rb 中,我有:
当然,我的帐户具有 :user 和 :admin 角色。我的模型是:
上面的示例完全相同):
如果您正确配置了 declarative_authorization,则应该在您的 User 模型(或与 authlogic 一起使用的任何模型)中使用 role_symbols 方法(顺便说一句,不一定与 最后我的路线是:
你应该安装 ruby_parser gem。
也许它对你有帮助。
ps: Весело писать по-английски, сидя в Москве, человеку, который тоже находится в Москве :)
I use both authlogic and declarative_authorization in my application and it works fine for me.
In config/authorization_rules.rb I have:
Of cause my account has :user and :admin roles. My models are:
If you properly configured declarative_authorization, you should have in your User model (or whatever model you use with authlogic) role_symbols method (btw not necessary exactly the same as in the example above):
At last my routes are:
And you should have ruby_parser gem installed.
Maybe it help you.
p.s: Весело писать по-английски, сидя в Москве, человеку, который тоже находится в Москве :)