mirror of
https://github.com/YunoHost-Apps/dotclear2_ynh.git
synced 2024-09-03 18:26:29 +02:00
fix ldap auth
This commit is contained in:
parent
de642dcf69
commit
5b77cd2f4d
3 changed files with 18 additions and 12 deletions
|
@ -1,13 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
use Dotclear\App;
|
||||||
|
use Dotclear\Core\Auth;
|
||||||
class ldapDcAuth extends Auth
|
class ldapDcAuth extends Auth
|
||||||
{
|
{
|
||||||
# The user can't change his password
|
# The user can't change his password
|
||||||
protected $allow_pass_change = false;
|
protected bool $allow_pass_change = false;
|
||||||
|
|
||||||
# LDAP parameter
|
# LDAP parameter
|
||||||
private $server = "localhost";
|
private string $server = "localhost";
|
||||||
private $port = "389";
|
private string $port = "389";
|
||||||
private $base = "dc=yunohost,dc=org";
|
private string $base = "dc=yunohost,dc=org";
|
||||||
|
|
||||||
public function checkUser(string $user_id, ?string $pwd = NULL, ?string $user_key = NULL, bool $check_blog = true): bool
|
public function checkUser(string $user_id, ?string $pwd = NULL, ?string $user_key = NULL, bool $check_blog = true): bool
|
||||||
{
|
{
|
||||||
|
@ -56,9 +58,9 @@ class ldapDcAuth extends Auth
|
||||||
}
|
}
|
||||||
|
|
||||||
# If the user exist, then we just update his password.
|
# If the user exist, then we just update his password.
|
||||||
if (dcCore::app()->userExists($user_id))
|
if (App::users()->userExists($user_id))
|
||||||
{
|
{
|
||||||
$this->sudo(array(dcCore::app(), 'updUser'), $user_id, $cur);
|
$this->sudo(array(App::users(), 'updUser'), $user_id, $cur);
|
||||||
}
|
}
|
||||||
# If not, we create him.
|
# If not, we create him.
|
||||||
# In order for him to connect,
|
# In order for him to connect,
|
||||||
|
@ -69,7 +71,7 @@ class ldapDcAuth extends Auth
|
||||||
$cur->user_lang = 'fr'; # Can change this, PR are welcome
|
$cur->user_lang = 'fr'; # Can change this, PR are welcome
|
||||||
$cur->user_tz = 'Europe/Paris'; # Can change this, PR are welcome
|
$cur->user_tz = 'Europe/Paris'; # Can change this, PR are welcome
|
||||||
$cur->user_default_blog = 'default'; # Can change this, PR are welcome
|
$cur->user_default_blog = 'default'; # Can change this, PR are welcome
|
||||||
$this->sudo(array(dcCore::app(),'addUser'), $cur);
|
$this->sudo(array(App::users(),'addUser'), $cur);
|
||||||
# Possible roles:
|
# Possible roles:
|
||||||
# admin "administrator"
|
# admin "administrator"
|
||||||
# contentadmin "manage all entries and comments"
|
# contentadmin "manage all entries and comments"
|
||||||
|
@ -100,7 +102,7 @@ class ldapDcAuth extends Auth
|
||||||
$set_perms[$perm_id] = true;
|
$set_perms[$perm_id] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->sudo(array(dcCore::app(), 'setUserBlogPermissions'), $user_id, 'default', $set_perms, true);
|
$this->sudo(array(App::users(), 'setUserBlogPermissions'), $user_id, 'default', $set_perms, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->con->commit();
|
$this->con->commit();
|
||||||
|
|
|
@ -95,8 +95,10 @@ ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$install_
|
||||||
|
|
||||||
cat << EOF >> $php_config
|
cat << EOF >> $php_config
|
||||||
|
|
||||||
require dirname(__FILE__).'/class.auth.ldap.php';
|
require_once dirname(__FILE__).'/class.auth.ldap.php';
|
||||||
define('DC_AUTH_CLASS','ldapDcAuth');
|
define('DC_AUTH_LDAP','ldapDcAuth');
|
||||||
|
use Dotclear\Helper\Container\Factories;
|
||||||
|
Factories::addService("core", AuthInterface::class, DC_AUTH_LDAP);
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
ynh_store_file_checksum --file=$php_config
|
ynh_store_file_checksum --file=$php_config
|
||||||
|
|
|
@ -116,8 +116,10 @@ ynh_add_config --template="../conf/class.auth.ldap.php" --destination="$install_
|
||||||
|
|
||||||
cat << EOF >> $php_config
|
cat << EOF >> $php_config
|
||||||
|
|
||||||
require dirname(__FILE__).'/class.auth.ldap.php';
|
require_once dirname(__FILE__).'/class.auth.ldap.php';
|
||||||
define('DC_AUTH_CLASS','ldapDcAuth');
|
define('DC_AUTH_LDAP','ldapDcAuth');
|
||||||
|
use Dotclear\Helper\Container\Factories;
|
||||||
|
Factories::addService("core", AuthInterface::class, DC_AUTH_LDAP);
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
|
|
Loading…
Reference in a new issue