2007-01-19
orion
As noted in [[http://www.freelists.org/archives/dokuwiki/08-2006/msg00106.html]], a trivial change to auth.php can give great flexibility when we want to assign users "home namespaces". In my wiki, for instance, this patch takes the place of 70 separate permission lines of the form "people:john:* john 16" by replacing them all with the single line "people:@USER@:* @USER@ 16". I've modified the patch from the link above to take care of the case when $_SERVER['REMOTE_USER'] is empty by deleting lines containing @USER@. This patch is against the current auth.php, though I've only tested it with the 2006-11-06 release.
<code>
--- inc/auth.php 2007-01-19 14:08:30.000000000 -0700
+++ inc/auth.php 2007-01-19 14:11:17.000000000 -0700
@@ -76,6 +76,11 @@
global $AUTH_ACL;
if(is_readable(DOKU_CONF.'acl.auth.php')){
$AUTH_ACL = file(DOKU_CONF.'acl.auth.php');
+ if($_SERVER['REMOTE_USER']=='') { // delete the lines with @USER@
+ $AUTH_ACL = array_filter($AUTH_ACL, create_function('$v','return (strpos($v,"@USER@") === false);'));
+ } else {
+ $AUTH_ACL = str_replace('@USER@',$_SERVER['REMOTE_USER'],$AUTH_ACL);
+ }
}else{
$AUTH_ACL = array();
}
</code>
Note, if it's important to have consecutively indexed entries in $AUTH_ACL, then I believe we can replace:
$AUTH_ACL = array_filter($AUTH_ACL, create_function('$v','return (strpos($v,"@USER@") === false);'));
with
$AUTH_ACL = array_values(array_filter($AUTH_ACL, create_function('$v','return (strpos($v,"@USER@") === false);')));