summaryrefslogtreecommitdiff
path: root/inc/auth.php
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2013-08-03 14:04:06 +0200
committerChristopher Smith <chris@jalakai.co.uk>2013-08-03 14:04:06 +0200
commitad3d68d738ab9057164c5d13a1836bd2791ab2f7 (patch)
tree14633cb56416409180d181c2882efd7361aef5ac /inc/auth.php
parent354c39ffc9aa3bbd7d59d5e182a36d1f390c5b7e (diff)
downloadrpg-ad3d68d738ab9057164c5d13a1836bd2791ab2f7.tar.gz
rpg-ad3d68d738ab9057164c5d13a1836bd2791ab2f7.tar.bz2
Fix a couple of bugs in ACL substitution mechanism
- %GROUP% & %USER% can now both be used in the same rule, e.g. %GROUP%:%USER% 2 - rules with tokens will be skipped when the user is not logged in previously %USER% was attempted
Diffstat (limited to 'inc/auth.php')
-rw-r--r--inc/auth.php14
1 files changed, 11 insertions, 3 deletions
diff --git a/inc/auth.php b/inc/auth.php
index be6b7ebbe..1c0bf5b4f 100644
--- a/inc/auth.php
+++ b/inc/auth.php
@@ -136,22 +136,30 @@ function auth_loadACL() {
$acl = file($config_cascade['acl']['default']);
- //support user wildcard
$out = array();
foreach($acl as $line) {
$line = trim($line);
if($line{0} == '#') continue;
list($id,$rest) = preg_split('/\s+/',$line,2);
+ // substitue user wildcard first (its 1:1)
+ if(strstr($line, '%USER%')){
+ // if user is not logged in, this ACL line is meaningless - skip it
+ if (!isset($_SERVER['REMOTE_USER'])) continue;
+
+ $id = str_replace('%USER%',cleanID($_SERVER['REMOTE_USER']),$id);
+ $rest = str_replace('%USER%',auth_nameencode($_SERVER['REMOTE_USER']),$rest);
+ }
+
+ // substitute group wildcard (its 1:m)
if(strstr($line, '%GROUP%')){
+ // if user is not logged in, grps is empty, no output will be added (i.e. skipped)
foreach((array) $USERINFO['grps'] as $grp){
$nid = str_replace('%GROUP%',cleanID($grp),$id);
$nrest = str_replace('%GROUP%','@'.auth_nameencode($grp),$rest);
$out[] = "$nid\t$nrest";
}
} else {
- $id = str_replace('%USER%',cleanID($_SERVER['REMOTE_USER']),$id);
- $rest = str_replace('%USER%',auth_nameencode($_SERVER['REMOTE_USER']),$rest);
$out[] = "$id\t$rest";
}
}