Deb Lewis
2007-Feb-13 18:51 UTC
[Masterview-devel] Revised version of customized admin access check
Jeff - I reworked your initial version of allowing app developers to customize the MasterView admin auth checking, per our discussions of factoring and use of mixins. Before I commit, see below for summary of the new version. ~ Deb -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- By default, the MV admin controller restricts access to local requests (essentially, developer testing configuration). To provide customized access checking for your application, you can override the default auth checking by providing a mixin module for the MV admin controller which implements a predicate method named allow_access?. The mixin is installed in an ApplicationController subclass, so your allow_access? method has access to all standard Rails controller services as well as any services defined in your ApplicationController (notably your own authentication and authorization methods). By default, if you implement your mixin as module MasterViewAdminAuthMixin and place it in file admin_auth_mixin.rb in your rails app/masterview directory (alongside any custom directives in app/masterview/directives), MasterView will automatically install your allow_access? method in the admin controller''s auth check. If you want to use a different module name or load the mixin module from a different location, specify this information in the MasterView admin_auth_mixin config setting in your config/masterview/settings.rb or env-specific settings. # To load a different file from app/masterview or use a different module name: # # config.admin_auth_mixin = { # :file => ''alt_admin_auth_mixin'', # module file in #{RAILS_ROOT}/app/masterview dir # :module => :AltMasterViewAdminAuthMixin, # default is :MasterViewAdminAuthMixin # } # # To load a mixin from the rails app''s lib directory: # # config.admin_auth_mixin = { # :file => ''lib/custom/mv_admin_auth_mixin'', # module file in rails lib dir # :file_loc => :RAILS_ROOT, # default location for rel refs is #{RAILS_ROOT}/app/masterview # :module => :CustomMasterViewAdminAuthMixin, # default is :MasterViewAdminAuthMixin # } -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Jeff Barczewski
2007-Feb-13 19:11 UTC
[Masterview-devel] Revised version of customized admin access check
Deb, This looks great! I like how it came out. I''m glad we have the flexibility to load from anywhere in RAILS_ROOT too since they might be running from a gem, in which case they will want to load from elsewhere. What you have here gives us that flexibility. So commit when you are ready. Jeff On 2/13/07, Deb Lewis <djlewis at acm.org> wrote:> > Jeff - I reworked your initial version of allowing app developers to > customize the MasterView admin auth checking, per our discussions of > factoring and use of mixins. > > Before I commit, see below for summary of the new version. > > ~ Deb > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > > By default, the MV admin controller restricts access to local requests > (essentially, developer testing configuration). > > To provide customized access checking for your application, you can > override > the default auth checking by providing a mixin module for the MV admin > controller which implements a predicate method named allow_access?. The > mixin is installed in an ApplicationController subclass, so your > allow_access? method has access to all standard Rails controller services > as > well as any services defined in your ApplicationController (notably your > own > authentication and authorization methods). > > By default, if you implement your mixin as module MasterViewAdminAuthMixin > and place it in file admin_auth_mixin.rb in your rails app/masterview > directory (alongside any custom directives in app/masterview/directives), > MasterView will automatically install your allow_access? method in the > admin > controller''s auth check. > > If you want to use a different module name or load the mixin module from a > different location, specify this information in the MasterView > admin_auth_mixin config setting in your config/masterview/settings.rb or > env-specific settings. > > # To load a different file from app/masterview or use a different > module > name: > # > # config.admin_auth_mixin = { > # :file => ''alt_admin_auth_mixin'', # module file in > #{RAILS_ROOT}/app/masterview dir > # :module => :AltMasterViewAdminAuthMixin, # default is > :MasterViewAdminAuthMixin > # } > # > # To load a mixin from the rails app''s lib directory: > # > # config.admin_auth_mixin = { > # :file => ''lib/custom/mv_admin_auth_mixin'', # module file in rails > lib dir > # :file_loc => :RAILS_ROOT, # default location for rel refs is > #{RAILS_ROOT}/app/masterview > # :module => :CustomMasterViewAdminAuthMixin, # default is > :MasterViewAdminAuthMixin > # } > > -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- > > > _______________________________________________ > Masterview-devel mailing list > Masterview-devel at rubyforge.org > http://rubyforge.org/mailman/listinfo/masterview-devel >-- Jeff Barczewski, MasterView core team Inspired Horizons Ruby on Rails Training and Consultancy Next Ruby on Rails plus JRuby workshop Feb 22-24 St. Louis, MO http://inspiredhorizons.com/training/rails/index.html -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-devel/attachments/20070213/a6f3a318/attachment-0001.html
Deb Lewis
2007-Feb-14 00:27 UTC
[Masterview-devel] Revised version of customized admin access check
Jeff - commited. I changed the example so it follows the default module naming convention. Suggest we also rename the file from examples/rails_app_admin_auth/auth_local_request_mixin.rb to the default name admin_auth_mixin.rb so that someone can copy that directly to their app/masterview dir and simple customize, w/out having to add mv config settings to pick up alt file name or mixin module name. ~ Deb
Jeff Barczewski
2007-Feb-14 03:57 UTC
[Masterview-devel] Revised version of customized admin access check
On 2/13/07, Deb Lewis <djlewis at acm.org> wrote:> > Jeff - commited. > > I changed the example so it follows the default module naming convention. > Suggest we also rename the file from > examples/rails_app_admin_auth/auth_local_request_mixin.rb to the default > name admin_auth_mixin.rb so that someone can copy that directly to their > app/masterview dir and simple customize, w/out having to add mv config > settings to pick up alt file name or mixin module name. >Yes, I agree, with the way you have things it makes sense to have the name ready to go so they can copy it in there and run. Jeff -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/masterview-devel/attachments/20070213/9996dbec/attachment.html