Use config_cascade for ACLs and plain auth users FS#1677
This commit is contained in:
parent
c5ef5f5975
commit
c8f80b4e70
|
@ -35,6 +35,7 @@ function auth_setup(){
|
|||
global $auth;
|
||||
global $AUTH_ACL;
|
||||
global $lang;
|
||||
global $config_cascade;
|
||||
$AUTH_ACL = array();
|
||||
|
||||
if(!$conf['useacl']) return false;
|
||||
|
@ -102,8 +103,8 @@ function auth_setup(){
|
|||
}
|
||||
|
||||
//load ACL into a global array XXX
|
||||
if(is_readable(DOKU_CONF.'acl.auth.php')){
|
||||
$AUTH_ACL = file(DOKU_CONF.'acl.auth.php');
|
||||
if(is_readable($config_cascade['acl']['default'])){
|
||||
$AUTH_ACL = file($config_cascade['acl']['default']);
|
||||
//support user wildcard
|
||||
if(isset($_SERVER['REMOTE_USER'])){
|
||||
$AUTH_ACL = str_replace('%USER%',$_SERVER['REMOTE_USER'],$AUTH_ACL);
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
* @author Chris Smith <chris@jalakai.co.uk>
|
||||
*/
|
||||
|
||||
define('AUTH_USERFILE',DOKU_CONF.'users.auth.php');
|
||||
|
||||
class auth_plain extends auth_basic {
|
||||
|
||||
var $users = null;
|
||||
|
@ -23,10 +21,12 @@ class auth_plain extends auth_basic {
|
|||
* @author Christopher Smith <chris@jalakai.co.uk>
|
||||
*/
|
||||
function auth_plain() {
|
||||
if (!@is_readable(AUTH_USERFILE)){
|
||||
global $config_cascade;
|
||||
|
||||
if (!@is_readable($config_cascade['plainauth.users']['default'])){
|
||||
$this->success = false;
|
||||
}else{
|
||||
if(@is_writable(AUTH_USERFILE)){
|
||||
if(@is_writable($config_cascade['plainauth.users']['default'])){
|
||||
$this->cando['addUser'] = true;
|
||||
$this->cando['delUser'] = true;
|
||||
$this->cando['modLogin'] = true;
|
||||
|
@ -89,6 +89,7 @@ class auth_plain extends auth_basic {
|
|||
*/
|
||||
function createUser($user,$pwd,$name,$mail,$grps=null){
|
||||
global $conf;
|
||||
global $config_cascade;
|
||||
|
||||
// user mustn't already exist
|
||||
if ($this->getUserData($user) !== false) return false;
|
||||
|
@ -102,12 +103,13 @@ class auth_plain extends auth_basic {
|
|||
$groups = join(',',$grps);
|
||||
$userline = join(':',array($user,$pass,$name,$mail,$groups))."\n";
|
||||
|
||||
if (io_saveFile(AUTH_USERFILE,$userline,true)) {
|
||||
if (io_saveFile($config_cascade['plainauth.users']['default'],$userline,true)) {
|
||||
$this->users[$user] = compact('pass','name','mail','grps');
|
||||
return $pwd;
|
||||
}
|
||||
|
||||
msg('The '.AUTH_USERFILE.' file is not writable. Please inform the Wiki-Admin',-1);
|
||||
msg('The '.$config_cascade['plainauth.users']['default'].
|
||||
' file is not writable. Please inform the Wiki-Admin',-1);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -123,6 +125,7 @@ class auth_plain extends auth_basic {
|
|||
global $conf;
|
||||
global $ACT;
|
||||
global $INFO;
|
||||
global $config_cascade;
|
||||
|
||||
// sanity checks, user must already exist and there must be something to change
|
||||
if (($userinfo = $this->getUserData($user)) === false) return false;
|
||||
|
@ -147,7 +150,7 @@ class auth_plain extends auth_basic {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!io_saveFile(AUTH_USERFILE,$userline,true)) {
|
||||
if (!io_saveFile($config_cascade['plainauth.users']['default'],$userline,true)) {
|
||||
msg('There was an error modifying your user data. You should register again.',-1);
|
||||
// FIXME, user has been deleted but not recreated, should force a logout and redirect to login page
|
||||
$ACT == 'register';
|
||||
|
@ -166,6 +169,7 @@ class auth_plain extends auth_basic {
|
|||
* @return int the number of users deleted
|
||||
*/
|
||||
function deleteUsers($users) {
|
||||
global $config_cascade;
|
||||
|
||||
if (!is_array($users) || empty($users)) return 0;
|
||||
|
||||
|
@ -180,7 +184,7 @@ class auth_plain extends auth_basic {
|
|||
|
||||
$pattern = '/^('.join('|',$deleted).'):/';
|
||||
|
||||
if (io_deleteFromFile(AUTH_USERFILE,$pattern,true)) {
|
||||
if (io_deleteFromFile($config_cascade['plainauth.users']['default'],$pattern,true)) {
|
||||
foreach ($deleted as $user) unset($this->users[$user]);
|
||||
return count($deleted);
|
||||
}
|
||||
|
@ -271,11 +275,13 @@ class auth_plain extends auth_basic {
|
|||
* @author Andreas Gohr <andi@splitbrain.org>
|
||||
*/
|
||||
function _loadUserData(){
|
||||
global $config_cascade;
|
||||
|
||||
$this->users = array();
|
||||
|
||||
if(!@file_exists(AUTH_USERFILE)) return;
|
||||
if(!@file_exists($config_cascade['plainauth.users']['default'])) return;
|
||||
|
||||
$lines = file(AUTH_USERFILE);
|
||||
$lines = file($config_cascade['plainauth.users']['default']);
|
||||
foreach($lines as $line){
|
||||
$line = preg_replace('/#.*$/','',$line); //ignore comments
|
||||
$line = trim($line);
|
||||
|
|
38
inc/init.php
38
inc/init.php
|
@ -77,26 +77,32 @@ if (empty($config_cascade)) {
|
|||
'local' => array(DOKU_CONF.'license.local.php'),
|
||||
),
|
||||
'mediameta' => array(
|
||||
'default' => array(DOKU_CONF.'mediameta.php'),
|
||||
'local' => array(DOKU_CONF.'mediameta.local.php'),
|
||||
),
|
||||
'default' => array(DOKU_CONF.'mediameta.php'),
|
||||
'local' => array(DOKU_CONF.'mediameta.local.php'),
|
||||
),
|
||||
'mime' => array(
|
||||
'default' => array(DOKU_CONF.'mime.conf'),
|
||||
'local' => array(DOKU_CONF.'mime.local.conf'),
|
||||
),
|
||||
'default' => array(DOKU_CONF.'mime.conf'),
|
||||
'local' => array(DOKU_CONF.'mime.local.conf'),
|
||||
),
|
||||
'scheme' => array(
|
||||
'default' => array(DOKU_CONF.'scheme.conf'),
|
||||
'local' => array(DOKU_CONF.'scheme.local.conf'),
|
||||
),
|
||||
'default' => array(DOKU_CONF.'scheme.conf'),
|
||||
'local' => array(DOKU_CONF.'scheme.local.conf'),
|
||||
),
|
||||
'smileys' => array(
|
||||
'default' => array(DOKU_CONF.'smileys.conf'),
|
||||
'local' => array(DOKU_CONF.'smileys.local.conf'),
|
||||
),
|
||||
'default' => array(DOKU_CONF.'smileys.conf'),
|
||||
'local' => array(DOKU_CONF.'smileys.local.conf'),
|
||||
),
|
||||
'wordblock' => array(
|
||||
'default' => array(DOKU_CONF.'wordblock.conf'),
|
||||
'local' => array(DOKU_CONF.'wordblock.local.conf'),
|
||||
),
|
||||
);
|
||||
'default' => array(DOKU_CONF.'wordblock.conf'),
|
||||
'local' => array(DOKU_CONF.'wordblock.local.conf'),
|
||||
),
|
||||
'acl' => array(
|
||||
'default' => DOKU_CONF.'acl.auth.php',
|
||||
),
|
||||
'plainauth.users' => array(
|
||||
'default' => DOKU_CONF.'users.auth.php',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//prepare config array()
|
||||
|
|
|
@ -69,6 +69,7 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
|
|||
global $AUTH_ACL;
|
||||
global $ID;
|
||||
global $auth;
|
||||
global $config_cascade;
|
||||
|
||||
// fresh 1:1 copy without replacements
|
||||
$AUTH_ACL = file(DOKU_CONF.'acl.auth.php');
|
||||
|
@ -161,11 +162,11 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
|
|||
}
|
||||
}
|
||||
// save it
|
||||
io_saveFile(DOKU_CONF.'acl.auth.php', join('',$lines));
|
||||
io_saveFile($config_cascade['acl']['default'], join('',$lines));
|
||||
}
|
||||
|
||||
// reload ACL config
|
||||
$AUTH_ACL = file(DOKU_CONF.'acl.auth.php');
|
||||
$AUTH_ACL = file($config_cascade['acl']['default']);
|
||||
}
|
||||
|
||||
// initialize ACL array
|
||||
|
@ -696,7 +697,8 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
|
|||
* @author Frank Schubert <frank@schokilade.de>
|
||||
*/
|
||||
function _acl_add($acl_scope, $acl_user, $acl_level){
|
||||
$acl_config = file_get_contents(DOKU_CONF.'acl.auth.php');
|
||||
global $config_cascade;
|
||||
$acl_config = file_get_contents($config_cascade['acl']['default']);
|
||||
$acl_user = auth_nameencode($acl_user,true);
|
||||
|
||||
// max level for pagenames is edit
|
||||
|
@ -718,7 +720,8 @@ class admin_plugin_acl extends DokuWiki_Admin_Plugin {
|
|||
* @author Frank Schubert <frank@schokilade.de>
|
||||
*/
|
||||
function _acl_del($acl_scope, $acl_user){
|
||||
$acl_config = file(DOKU_CONF.'acl.auth.php');
|
||||
global $config_cascade;
|
||||
$acl_config = file($config_cascade['acl']['default']);
|
||||
$acl_user = auth_nameencode($acl_user,true);
|
||||
|
||||
$acl_pattern = '^'.preg_quote($acl_scope,'/').'\s+'.$acl_user.'\s+[0-8].*$';
|
||||
|
|
Loading…
Reference in New Issue