난 그냥 루비 온 레일즈로 개발을 시작하고 나는 사용자에게 역할 및 역할에 대한 권한을 연결하는 관리자를 가능하게하는 동적 인증 플러그인을 찾고 있어요.레일 동적 인증 인터페이스
나는이 주제를 대상으로 railscasts.org에서 stackoverflow 및 일부 포럼과 일부 포드 캐스트에서 일부 게시물을 발견했지만 모두 acl9, declarative_authorization, Aegis, restful acl 또는 인증이 아닌 Authlogic을 참조하지만 인증 플러그인. 다른 것들은 필요한 기능을 제공하지 않습니다. 는 사용자 역할을 다스리 다에 레일에 루비를 사용하여 웹 인터페이스를 설정 할 수 있다면
그래서 누군가가 나에게 말해 줄 수?
그래서 지금 내가 folowing 마이그레이션을 사용하여 내 데이터베이스를 마이그레이션.class AddRolesAndRightsTables < ActiveRecord::Migration
def self.up
create_table :roles_users do |t|
t.integer :role_id
t.integer :user_id
end
create_table :roles do |t|
t.string :name
end
create_table :rights_roles do |t|
t.integer :right_id
t.integer :role_id
end
create_table :rights do |t|
t.string :name
t.string :controller
t.string :action
end
end
def self.down
drop_table :roles_users
drop_table :roles
drop_table :rights_roles
drop_table :rights
end
end
그리고 일부보기 및 컨트롤러 동작 외에도 다음 작업을 ApplicationController에 추가했습니다.
def check_authorization
user = User.find(session[:user])
unless user.roles.detect do |role|
role.rights.select do |right|
right.action == action_name && right.controller == self.class.controller_path
end
end
redirect_back_or user
flash[:notice] = "You are not authorized to view the page you requested."
return false
end
Right.synchronize_with_controllers (Wolfman-Blog의 블로그 포스트를 참조)를 실행, 나는 다음과 같은 오류가 발생합니다.
syntax error, unexpected $end, expecting kEND (line 17 in application_controller)
그래서 관리자가 수 있도록 인터페이스를 프로그래밍 할 수 있습니다 새로운 역할을 만들고 권한을 할당 할 수 있습니다. 코드를 변경하지 않으셨습니까? – Phidelux
예. 캔칸 (Cancan) 및 다른 대부분의 승인 보석은 귀하가 허용 한도를 구현하는 방법에 간섭하지 않을 것입니다. 아픈 짧은 스 니펫 n 개의 링크로 내 대답을 업데이 트하십시오. –
Avedo, 대답은 당신에게 받아 들여지지 않습니까? –