When I was talking on IRC with AlexanderSchremmer about using moin as a blog, he mentioned that people may want to write things up for the future that are not immediately visible. He half-jokingly suggested ACL Plugins. After thinking this through, I think it makes sense. So here's a plan for it.

Idea

Currently, we have 4 types of ACL rights (which I'll denote in italics):

There rights will be kept, but we'll add another layer of indirection. Specifically:

There will be the 4 basic ACL plugins (which I'll denote in typewriter):

which always return True for the right they're named after, and None otherwise. This helps to ensure backward compatibility, see below.

Currently we have this syntax:

#acl UserOrGroup:right1,right2,right3

This will be expanded to

#acl UserOrGroup:plugin1(param1, param2, param3),plugin2,plugin3(...)

where of course the parentheses and parameters are optional (and the 4 basic plugins don't take any at least for now). If the parentheses are left off, the arguments are parsed as None, otherwise the string inbetween is used.

plugin API

Plugins will have to provide these methods:

example basic plugin

   1 class read:
   2   def __init__(self, request, args):
   3     if not args is None: # no arguments allowed for this basic plugin
   4       raise InvalidACLArgumentException
   5   def may(self, right):
   6     if right != self.__class__.__name__:
   7       return None
   8     return True
   9 
  10 # other basic classes can inherit stuff
  11 class write(read):
  12   pass
  13 class delete(read):
  14   pass
  15 class admin(read):
  16   pass

what changes

Well, instead of just saving the rights, plugin instances are created and saved with the ACL. Then, when the ACL is queried for a specific right, the plugins are asked in turn. If one of them says that it determines the right the query is looking for (that is, returns True or False), then the right is granted or denied, and ACL processing stops after that point. Otherwise, the next plugin is queried. This ensures full backward compatibility.

I have a patch for wikiacl.py that changes the way ACLs are parsed (yes, it still passes tests) and additionally allows quoting usernames. The only non-backward compatible part is ACLs that have usernames containing quotes. See /wikiacl.patch.

example of a more interesting plugin

   1 import time
   2 
   3 class readafter:
   4   def __init__(self, request, args):
   5     self.thetime = parse_time_argument(args) # to be filled in
   6   def may(self, right):
   7     if right != 'read':
   8       return None
   9     return (time.time() > self.thetime)

further ideas

We could fold the SecurityPolicy into pluggable ACLs. Currently, differences are that the SecurityPolicy is evaluated on save, and the ACL is already evaluated before. But the ACL obviously also has to be evaluated on saving, this could be extended by adding a save right (which the write plugin would automatically grant as well as write), but which is evaluated with the extra parameters editor, newtext, rev, **kw from saveText(). Then a custom security policy could be replaced by a acl_before statement and an ACL plugin, making custom security policies aggregable (read: you can download ACL plugins from anyone and use them in whatever way you like). This needs some more thought (read: I haven't fully thought through the implications).

discussion

I don't see how security policy is less flexible and outdated, and why extending acl is mandatory if we want to see some progress. A security policy class is the most flexible thing you can have - run you own code on any event. What is mandatory is the rule - don't touch the core unless its really needed.

Anyway, if we have a new concept of date when a page is available, and its really needed to be in the core of the wiki, the simple solution is to add a processing instruction, like #date date, that will make the page available from date. Of course in a wiki, this concept is problematic - what do you do with the page? show missing page? show "Page will be published in date"? This is typical trouble when trying to do things a wiki should not do. -- NirSoffer 2005-02-09 14:48:22

  1. unless I explicitly exclude a single user in code, or add another pragma, or ... I'm thinking along the lines of a new way to do a class of things, not just solving a single problem. (1)

MoinMoin: JohannesBerg/PluggableACLs (last edited 2007-10-29 19:10:13 by localhost)