I've recently (re)started work on the security branch [1], using
Christian's recent Context additions. Given that the Context contains all
of the information necessary to enforce a policy decision, I think this
is a good approach.
In the security sandbox I've made a couple of minor changes and would
like to make a few more.
What I've done so far, and why:
- Added a trac.resource module
- Moved trac.wiki.api.Context to trac.resource. I did this because
I think the Context is more generalised, and some auxiliary
interfaces/components are required which don't make sense being in
trac.wiki.
- Created a trac.resource.IResourceMapper interface for mapping
between resources and contexts.
- Added the trac.resource.ResourceSystem component for inspecting and
converting resources.
- Added a trac.perm.IPermissionPolicy interface for making security policy
decisions, and converted PermissionSystem and PermissionCache to use this.
- Added convenience classmethod Context.from_resource(env, req,
resource) for creating a Context from a resource, such as a WikiPage
object (actually anything that can be identified via IResourceMapper).
page = WikiPage(env, 'WikiStart')
context = Context.from_resource(env, req, page)
- Added Context.object, which lazily fetches the actual object
referred to by the Context (I'd like to rename this from "object"
to "resource" - more info further down).
- Added Context.perm which is a PermissionCache object (same as
req.perm) but specific to the current context. eg.
if 'WIKI_MODIFY' in context.perm:
...
The context object is passed to template pages, where appropriate,
and can be used to control access:
<py:if test="'WIKI_ADMIN' in context.perm">
...
<py:/if>
So far I've only converted the Wiki module, but it is working perfectly
so far.
Changes I would like to make:
- Rename the "resource" member of Contact to "realm" [2]. "resource"
currently refers to "wiki", "ticket", etc. I think it should refer
to the actual object identified (eg. WikiPage(env, 'WikiStart')).
- Merge into trunk.
- Continue converting modules.
If amenable, I'd like to merge the branch into trunk as it is currently.
[1] http://trac.edgewall.org/wiki/PermissionPolicy
[2] http://trac.edgewall.org/browser/sandbox/security/trac/resource.py#L73
--
Evolution: Taking care of those too stupid to take care of themselves.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Trac Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/trac-dev?hl=en
-~----------~----~----~----~------~----~------~--~---