Hi everyone,
I don’t to sound pedantic here, but can we be sure to distinguish
between Authentication (auth), Authorization (authz), and Access
Control? See the intro of this section of the Apache manual:
http://httpd.apache.org/docs/1.3/howto/auth.html#intro
Just to be clear, this looks to be a problem entirely of authorization
and not authentication or access control.
Take a look at Radiant’s login system in lib/login_system.rb: Auth is
provided by the before_filter #authenticate (which unfortunately also
authorizes to some extent), which calls #current_user. I’d recommend
using this method instead of calling User.find(session[:id]) manually.
This way your extension will work with other extensions that may
overload the authentication mechanism (e.g. I’m working on an
extension that uses RubyCAS-Client [1] to allow centralized
authentication over multiple applications – and I’m going to do this
by overriding #current_user).
Ok, so let’s consider an authz system: let’s say a user has roles.
Roles grant them permission. Roles can either be global
“Uber-administrator” or granular to a page “Editor of the lunch menu
web page”. Right now Radiant determines if the user is authorized
using the #user_has_role?(action). If you overrode this to call to
include a page parameter, it would probably do what you need.
E.g.
def user_has_role?(role, page)
current_user.send(“#{role}?”, page)
end
Also override #user_has_access_to_action? so that it include the page
param.
So then you just need to monkey-patch User so that messages like
“current_user.uber_admin?(page_doesnt_matter_because_im_uber)” or
“current_user.lunch_menu_editor?(lunch_menu_page)” make sense.
I flirted with added an authz system to Radiant awhile back, and while
this project [2] seems to be dormant and permissions are in funky
little strings, the data model is solid and is what I’d recommend for
the storing users and roles.
Well, I hope this helps. Auth and authz can be tricky, so I wish you
the best of luck. I think the hardest part really, is putting
together a role admin interface that makes sense. That’s why I’m
leaving that as an exercise to you… 
-Andrew
[1] For more on RubyCAS, see:
http://rubyconf2007.confreaks.com/d3t2p1_security_and_identity.html
http://code.google.com/p/rubycas-server/
http://code.google.com/p/rubycas-client/
[2] writertopia