summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2012-06-30 02:05:54 -0700
committerAndreas Gohr <andi@splitbrain.org>2012-06-30 02:05:54 -0700
commit0a16cff14790717c0302a1f1d34062ddc2f59d21 (patch)
tree0d4ecce722071953aab4644347f7420c380470f6
parent4d053d04448a73826574eeb5e6be7e4d53c38ae6 (diff)
parent11f03531585cccac387161ba88f54a28bad5624b (diff)
downloadrpg-0a16cff14790717c0302a1f1d34062ddc2f59d21.tar.gz
rpg-0a16cff14790717c0302a1f1d34062ddc2f59d21.tar.bz2
Merge pull request #111 from splitbrain/groupwildcard
Groupwildcard
-rw-r--r--inc/auth.php17
-rw-r--r--lib/plugins/acl/admin.php4
2 files changed, 15 insertions, 6 deletions
diff --git a/inc/auth.php b/inc/auth.php
index d0f21c825..fbdb2b439 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -123,19 +123,27 @@ function auth_setup() {
*/
function auth_loadACL() {
global $config_cascade;
+ global $USERINFO;
if(!is_readable($config_cascade['acl']['default'])) return array();
$acl = file($config_cascade['acl']['default']);
//support user wildcard
- if(isset($_SERVER['REMOTE_USER'])) {
+ if(isset($_SERVER['REMOTE_USER'])){
$len = count($acl);
for($i = 0; $i < $len; $i++) {
if($acl[$i]{0} == '#') continue;
- list($id, $rest) = preg_split('/\s+/', $acl[$i], 2);
- $id = str_replace('%USER%', cleanID($_SERVER['REMOTE_USER']), $id);
- $rest = str_replace('%USER%', auth_nameencode($_SERVER['REMOTE_USER']), $rest);
+ list($id,$rest) = preg_split('/\s+/',$acl[$i],2);
+ if(strstr($acl[$i], '%GROUP%')){
+ foreach($USERINFO['grps'] as $grp){
+ $nid = str_replace('%GROUP%',cleanID($grp),$id);
+ $nrest = str_replace('%GROUP%',auth_nameencode($grp),$rest);
+ $acl[] = "$nid\t$nrest";
+ }
+ }
+ $id = str_replace('%USER%',cleanID($_SERVER['REMOTE_USER']),$id);
+ $rest = str_replace('%USER%',auth_nameencode($_SERVER['REMOTE_USER']),$rest);
$acl[$i] = "$id\t$rest";
}
}
@@ -632,6 +640,7 @@ function auth_nameencode($name, $skip_group = false) {
// never encode wildcard FS#1955
if($name == '%USER%') return $name;
+ if($name == '%GROUP%') return $name;
if(!isset($cache[$name][$skip_group])) {
if($skip_group && $name{0} == '@') {
diff --git a/lib/plugins/acl/admin.php b/lib/plugins/acl/admin.php
index c3461b78b..1f88c6ff9 100644
--- a/lib/plugins/acl/admin.php
+++ b/lib/plugins/acl/admin.php
@@ -84,7 +84,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
$this->who = '@'.ltrim($auth->cleanGroup($who),'@');
}elseif($_REQUEST['acl_t'] == '__u__' && $who){
$this->who = ltrim($who,'@');
- if($this->who != '%USER%'){ #keep wildcard as is
+ if($this->who != '%USER%' && $this->who != '%GROUP%'){ #keep wildcard as is
$this->who = $auth->cleanUser($this->who);
}
}elseif($_REQUEST['acl_t'] &&
@@ -140,7 +140,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
if ($who!='@ALL') {
$who = '@'.ltrim($auth->cleanGroup($who),'@');
}
- } elseif ($who != '%USER%'){ #keep wildcard as is
+ } elseif ($who != '%USER%' && $who != '%GROUP%'){ #keep wildcard as is
$who = $auth->cleanUser($who);
}
$who = auth_nameencode($who,true);