MDA/MDD/TDD/DDD/DDDDDDD
          posts - 536, comments - 111, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          rails應用的認證和授權

          Posted on 2010-02-14 21:00 leekiang 閱讀(582) 評論(0)  編輯  收藏 所屬分類: ruby
          ?一個帶完整的RBAC授權系統的rails應用
          http://www.javaeye.com/topic/215074

          RESTful_ACL


          declarative_authorization
          aegis
          cancan?????????? http://github.com/ryanb/cancan
          Authologic
          acl9???????????? http://github.com/be9/acl9
          role_requirement http://github.com/timcharper/role_requirement
          ActiveRbac


          restful_authentication
          1,ruby script/plugin install http://svn.techno-weenie.net/projects/plugins/restful_authentication/
          項目右鍵->rails 插件->資源庫里添加url:http://svn.techno-weenie.net/projects/plugins
          ->新插件里找到restful_authentication然后安裝
          2, ruby script/generate authenticated user sessions
          Right-click on your application in the projects pane and choose ?
          "Generate". In the dialog box that comes up, choose "authenticated" ?
          from the drop-down "Generator" menu near the top, and in the arguments ?
          field enter "user sessions" (without the quotes). Hit OK.
          ----------------------------------------------------------------------
          Don't forget to:

          Try these for some familiar login URLs if you like:

          map.activate '/activate/:activation_code', :controller => 'users', :action => 'activate', :activation_code => nil
          map.signup '/signup', :controller => 'users', :action => 'new'
          map.login '/login', :controller => 'sessions', :action => 'new'
          map.logout '/logout', :controller => 'sessions', :action => 'destroy'

          ----------------------------------------------------------------------
          ????? create? app/views/sessions
          ????? create? app/views/users
          ????? create? app/models/user.rb
          ????? create? app/controllers/sessions_controller.rb
          ????? create? app/controllers/users_controller.rb
          ????? create? lib/authenticated_system.rb
          ????? create? lib/authenticated_test_helper.rb
          ????? create? test/functional/sessions_controller_test.rb
          ????? create? test/functional/users_controller_test.rb
          ????? create? test/unit/user_test.rb
          ????? create? test/fixtures/users.yml
          ????? create? app/helpers/sessions_helper.rb
          ????? create? app/helpers/users_helper.rb
          ????? create? app/views/sessions/new.html.erb
          ????? create? app/views/users/new.html.erb
          ????? create? db/migrate/20100218184435_create_users.rb
          ????? route? map.resource :session
          ????? route? map.resources :users

          運行測試時要把SessionsControllerTest和UsersControllerTest都改為繼承ActionController::TestCase,同時把fixtures :users注釋掉。

          要使用current_user和logged_in? helper方法的話要在ApplicationController里include?AuthenticatedSystem?

          resource與resources的區別見http://api.rubyonrails.org/classes/ActionController/Resources.html

          http://www.javaeye.com/topic/353831
          http://www.javaeye.com/topic/177508
          http://hideto.javaeye.com/blog/115157
          https://github.com/nakajima/roleful
          主站蜘蛛池模板: 瓦房店市| 襄垣县| 葫芦岛市| 常州市| 梧州市| 岢岚县| 钦州市| 襄樊市| 丘北县| 西青区| 南昌县| 祥云县| 报价| 肃北| 遵化市| 木里| 元江| 罗平县| 连州市| 通海县| 永州市| 武宁县| 固阳县| 基隆市| 贵德县| 利辛县| 景东| 纳雍县| 孝义市| 县级市| 江陵县| 洛浦县| 浠水县| 盈江县| 准格尔旗| 丽水市| 谷城县| 华阴市| 天水市| 洮南市| 广昌县|