1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/wordpress_ynh.git synced 2024-09-03 20:36:10 +02:00

Merge pull request #3 from maniackcrudelis/master

Merge de wordpress Yunohost officiel et multisite
This commit is contained in:
Maniack Crudelis 2016-06-03 22:31:54 +02:00
commit 70f7e48960
17 changed files with 571 additions and 580 deletions

View file

@ -5,15 +5,15 @@
#--MULTISITE--} #--MULTISITE--}
location __PATHTOCHANGE__ { location __PATHTOCHANGE__ {
alias __FINALPATH__; alias __FINALPATH__/;
index index.php; index index.php;
if (!-e $request_filename) if (!-e $request_filename)
{ {
rewrite ^(.+)$ __PATHTOCHANGE__/index.php?q=$1 last; rewrite ^(.+)$ __PATHTOCHANGE__/index.php?q=$1 last;
} }
#--PRIVATE--if ($scheme = http) { if ($scheme = http) {
#--PRIVATE-- rewrite ^ https://$server_name$request_uri? permanent; rewrite ^ https://$server_name$request_uri? permanent;
#--PRIVATE--} }
client_max_body_size 30m; client_max_body_size 30m;
location ~ [^/]\.php(/|$) { location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$; fastcgi_split_path_info ^(.+?\.php)(/.*)$;

View file

@ -1,2 +1,2 @@
INSERT INTO wp_options VALUES('','sll_settings','a:14:{s:14:"account_suffix";s:0:"";s:7:"base_dn";s:27:"ou=users,dc=yunohost,dc=org";s:18:"domain_controllers";a:1:{i:0;s:9:"localhost";}s:9:"directory";s:2:"ol";s:4:"role";s:10:"subscriber";s:13:"high_security";s:5:"false";s:8:"ol_login";s:3:"uid";s:7:"use_tls";s:5:"false";s:9:"ldap_port";s:3:"389";s:12:"ldap_version";s:1:"3";s:12:"create_users";s:4:"true";s:7:"enabled";s:4:"true";s:7:"version";s:3:"1.5";s:6:"groups";a:1:{i:0;s:0:"";}}','yes'); INSERT INTO wp_options VALUES('','http_authentication_options','a:8:{s:13:"allow_wp_auth";b:1;s:10:"auth_label";s:19:"HTTP authentication";s:9:"login_uri";s:40:"https://__DOMAIN_PATH__/wp-login.php";s:10:"logout_uri";s:28:"https://__DOMAIN_PATH__/";s:22:"additional_server_keys";s:13:"PHP_AUTH_USER";s:24:"auto_create_email_domain";s:0:"";s:10:"db_version";i:2;s:16:"auto_create_user";b:0;}','yes');
INSERT INTO wp_options (option_id,option_name,option_value,autoload) VALUES('','WPLANG','__LANGUAGE__','yes') ON DUPLICATE KEY UPDATE option_value=VALUES(option_value); INSERT INTO wp_options (option_id,option_name,option_value,autoload) VALUES('','WPLANG','__LANGUAGE__','yes') ON DUPLICATE KEY UPDATE option_value=VALUES(option_value);

View file

@ -1,3 +1,3 @@
INSERT INTO wp_options VALUES('','http_authentication_options','a:8:{s:13:"allow_wp_auth";b:1;s:10:"auth_label";s:19:"HTTP authentication";s:9:"login_uri";s:40:"https://__DOMAIN_PATH__/wp-login.php";s:10:"logout_uri";s:28:"https://__DOMAIN_PATH__/";s:22:"additional_server_keys";s:13:"PHP_AUTH_USER";s:24:"auto_create_email_domain";s:0:"";s:10:"db_version";i:2;s:16:"auto_create_user";b:0;}','yes'); INSERT INTO wp_sitemeta VALUES('',1,'sll_settings','a:14:{s:14:"account_suffix";s:0:"";s:7:"base_dn";s:27:"ou=users,dc=yunohost,dc=org";s:18:"domain_controllers";a:1:{i:0;s:9:"localhost";}s:9:"directory";s:2:"ol";s:4:"role";s:10:"subscriber";s:13:"high_security";s:5:"false";s:8:"ol_login";s:3:"uid";s:7:"use_tls";s:5:"false";s:9:"ldap_port";s:3:"389";s:12:"ldap_version";s:1:"3";s:12:"create_users";s:4:"true";s:7:"enabled";s:4:"true";s:7:"version";s:3:"1.5";s:6:"groups";a:1:{i:0;s:0:"";}}');
#--PUBLIC--UPDATE wp_sitemeta SET meta_value='a:1:{s:39:"simple-ldap-login/Simple-LDAP-Login.php";i:__DATE__;}' WHERE meta_key='active_sitewide_plugins'; #--PUBLIC--UPDATE wp_sitemeta SET meta_value='a:1:{s:39:"simple-ldap-login/Simple-LDAP-Login.php";i:__DATE__;}' WHERE meta_key='active_sitewide_plugins';
#--PRIVATE--UPDATE wp_sitemeta SET meta_value='a:2:{s:39:"simple-ldap-login/Simple-LDAP-Login.php";i:__DATE__;s:43:"http-authentication/http-authentication.php";i:__DATE__;}' WHERE meta_key='active_sitewide_plugins'; #--PRIVATE--UPDATE wp_sitemeta SET meta_value='a:2:{s:39:"simple-ldap-login/Simple-LDAP-Login.php";i:__DATE__;s:43:"http-authentication/http-authentication.php";i:__DATE__;}' WHERE meta_key='active_sitewide_plugins';

View file

@ -1,3 +1,3 @@
INSERT INTO wp_options VALUES('','http_authentication_options','a:8:{s:13:"allow_wp_auth";b:1;s:10:"auth_label";s:19:"HTTP authentication";s:9:"login_uri";s:40:"https://__DOMAIN_PATH__/wp-login.php";s:10:"logout_uri";s:28:"https://__DOMAIN_PATH__/";s:22:"additional_server_keys";s:13:"PHP_AUTH_USER";s:24:"auto_create_email_domain";s:0:"";s:10:"db_version";i:2;s:16:"auto_create_user";b:1;}','yes'); INSERT INTO wp_options VALUES('','sll_settings','a:14:{s:14:"account_suffix";s:0:"";s:7:"base_dn";s:27:"ou=users,dc=yunohost,dc=org";s:18:"domain_controllers";a:1:{i:0;s:9:"localhost";}s:9:"directory";s:2:"ol";s:4:"role";s:10:"subscriber";s:13:"high_security";s:5:"false";s:8:"ol_login";s:3:"uid";s:7:"use_tls";s:5:"false";s:9:"ldap_port";s:3:"389";s:12:"ldap_version";s:1:"3";s:12:"create_users";s:4:"true";s:7:"enabled";s:4:"true";s:7:"version";s:3:"1.5";s:6:"groups";a:1:{i:0;s:0:"";}}','yes');
#--PRIVATE--UPDATE wp_options SET option_value='a:2:{i:0;s:43:"http-authentication/http-authentication.php";i:1;s:39:"simple-ldap-login/Simple-LDAP-Login.php";}' WHERE option_name='active_plugins'; #--PRIVATE--UPDATE wp_options SET option_value='a:2:{i:0;s:43:"http-authentication/http-authentication.php";i:1;s:39:"simple-ldap-login/Simple-LDAP-Login.php";}' WHERE option_name='active_plugins';
#--PUBLIC--UPDATE wp_options SET option_value='a:1:{i:1;s:39:"simple-ldap-login/Simple-LDAP-Login.php";}' WHERE option_name='active_plugins'; #--PUBLIC--UPDATE wp_options SET option_value='a:1:{i:1;s:39:"simple-ldap-login/Simple-LDAP-Login.php";}' WHERE option_name='active_plugins';

View file

@ -42,3 +42,8 @@ require_once(ABSPATH . 'wp-settings.php');
// Force https redirect // Force https redirect
//--PUBLIC--define('FORCE_SSL_ADMIN', true); //--PUBLIC--define('FORCE_SSL_ADMIN', true);
// Auto update
define('WP_AUTO_UPDATE_CORE', 'minor');
//add_filter( 'auto_update_plugin', '__return_true' );
//add_filter( 'auto_update_theme', '__return_true' );

View file

@ -1,6 +1,6 @@
{ {
"name": "WordPress MultiSite", "name": "WordPress",
"id": "wordpressms", "id": "wordpress",
"packaging_format": 1, "packaging_format": 1,
"requirements": { "requirements": {
"yunohost": ">= 2.4" "yunohost": ">= 2.4"
@ -9,12 +9,12 @@
"en": "Create a beautiful blog or website easily", "en": "Create a beautiful blog or website easily",
"fr": "Logiciel de création de blog ou de site Web" "fr": "Logiciel de création de blog ou de site Web"
}, },
"version": "4.4", "version": "4.5.2",
"url": "https://wordpress.org/", "url": "https://wordpress.org/",
"licence": "free", "licence": "free",
"maintainer": { "maintainer": {
"name": "Maniack Crudelis", "name": "Maniack Crudelis et beudbeud",
"email": "maniackc_dev@crudelis.fr" "email": "maniackc_dev@crudelis.fr, beudbeud@beudibox.fr"
}, },
"multi_instance": "true", "multi_instance": "true",
"services": [ "services": [
@ -47,7 +47,7 @@
"en": "Choose the WordPress administrator (must be an existing YunoHost user)", "en": "Choose the WordPress administrator (must be an existing YunoHost user)",
"fr": "Administrateur du site (doit être un utilisateur YunoHost existant)" "fr": "Administrateur du site (doit être un utilisateur YunoHost existant)"
}, },
"example": "homer" "example": "john"
}, },
{ {
"name": "language", "name": "language",
@ -73,7 +73,8 @@
"en": "Is it a public WordPress site ?", "en": "Is it a public WordPress site ?",
"fr": "Est-ce un site public ?" "fr": "Est-ce un site public ?"
}, },
"choices": ["Yes", "No"] "choices": ["Yes", "No"],
"default": "Yes"
} }
] ]
} }

View file

@ -1,77 +0,0 @@
{
"name": "WordPress MultiSite",
"id": "wordpressms",
"packaging_format": 1,
"description": {
"en": "Create a beautiful blog or website easily",
"fr": "Logiciel de création de blog ou de site Web"
},
"version": "4.4",
"url": "https://wordpress.org/",
"licence": "free",
"maintainer": {
"name": "Maniack Crudelis",
"email": "maniackc_dev@crudelis.fr"
},
"multi_instance": "true",
"services": [
"nginx",
"php5-fpm",
"mysql"
],
"arguments": {
"install" : [
{
"name": "domain",
"ask": {
"en": "Choose a domain for WordPress",
"fr": "Choisissez un domaine pour WordPress"
},
"example": "domain.org"
},
{
"name": "path",
"ask": {
"en": "Choose a path for WordPress",
"fr": "Choisissez un chemin pour WordPress"
},
"example": "/blog",
"default": "/blog"
},
{
"name": "admin",
"ask": {
"en": "Choose the WordPress administrator (must be an existing YunoHost user)",
"fr": "Administrateur du site (doit être un utilisateur YunoHost existant)"
},
"example": "homer"
},
{
"name": "language",
"ask": {
"en": "Choose the language of the WordPress site",
"fr": "Choissisez la langue du WordPress"
},
"choices": ["en_EN", "fr_FR"],
"default": "en_EN"
},
{
"name": "multisite",
"ask": {
"en": "Enable multisite option ?",
"fr": "Activer l'option multisite ?"
},
"choices": ["Yes", "No"],
"default": "No"
},
{
"name": "is_public",
"ask": {
"en": "Is it a public WordPress site ?",
"fr": "Est-ce un site public ?"
},
"choices": ["Yes", "No"]
}
]
}
}

View file

@ -1,28 +1,26 @@
#!/bin/bash #!/bin/bash
# Récupère les infos de l'application. # The parameter $1 is the backup directory location dedicated to the app
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2) backup_dir=$1
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME # The parameter $2 is theid of the app instance
else app=$2
app=wordpressms
fi
final_path=$(sudo yunohost app setting $app final_path)
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
final_path=$(sudo yunohost app setting $app final_path)
# Copy the app files
sudo mkdir -p ${backup_dir}/var/www
sudo cp -a $final_path "${backup_dir}/var/www/$app"
# The parameter $1 is the backup directory location # Copy the conf files
# which will be compressed afterward sudo mkdir -p "${backup_dir}/conf"
backup_dir=$1/apps/$app sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf "${backup_dir}/conf/nginx.conf"
sudo mkdir -p "$backup_dir"
# Backup sources & data
sudo cp -a $final_path/. $backup_dir/sources
# Copy Nginx and YunoHost parameters to make the script "standalone"
sudo cp -a /etc/yunohost/apps/$app/. $backup_dir/yunohost
sudo cp -a /etc/nginx/conf.d/$domain.d/$app.conf $backup_dir/nginx.conf
# Copy dedicated php-fpm process to backup folder # Copy dedicated php-fpm process to backup folder
sudo cp -a /etc/php5/fpm/pool.d/$app.conf $backup_dir/php-fpm.conf sudo cp -a /etc/php5/fpm/pool.d/$app.conf "${backup_dir}/conf/php-fpm.conf"
sudo cp -a /etc/php5/fpm/conf.d/20-$app.ini $backup_dir/php-fpm.ini sudo cp -a /etc/php5/fpm/conf.d/20-$app.ini "${backup_dir}/conf/php-fpm.ini"
# Backup db
root_pwd=$(sudo cat /etc/yunohost/mysql)
sudo su -c "mysqldump -u root -p$root_pwd --no-create-db $app > ${backup_dir}/db.sql"

View file

@ -1,9 +1,5 @@
#!/bin/bash #!/bin/bash
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
# Retrieve arguments
if [ $ynh_version = "2.4" ]
then
domain=$YNH_APP_ARG_DOMAIN domain=$YNH_APP_ARG_DOMAIN
path=$YNH_APP_ARG_PATH path=$YNH_APP_ARG_PATH
admin_wordpress=$YNH_APP_ARG_ADMIN admin_wordpress=$YNH_APP_ARG_ADMIN
@ -15,15 +11,6 @@ then
# Source app helpers # Source app helpers
. /usr/share/yunohost/helpers . /usr/share/yunohost/helpers
else
domain=$1
path=$2
admin_wordpress=$3
language=$4
multisite=$5
is_public=$6
app=wordpressms
fi
# Delete files and db if exit with an error # Delete files and db if exit with an error
@ -32,9 +19,9 @@ EXIT_PROPERLY () {
echo -e "\e[91m \e[1m" # Shell in light red bold echo -e "\e[91m \e[1m" # Shell in light red bold
echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!" echo -e "!!\n $app install's script has encountered an error. Installation was cancelled.\n!!"
if [ $ynh_version = "2.2" ]; then # Clean hosts
/bin/bash ./remove # Appel le script remove. En 2.2, ce comportement n'est pas automatique. sudo sed -i '/#wordpress_yunohost/d' /etc/hosts
fi
exit 1 exit 1
} }
TRAP_ON () { # Activate signal capture TRAP_ON () { # Activate signal capture
@ -75,6 +62,10 @@ then
touch /force_stop touch /force_stop
fi fi
if [ "$path" == "/" ] && [ "$multisite" = "Yes" ]; then
echo "Multisite option of wordpress doesn't work at root of domain."
touch /force_stop
fi
# Enregistre les infos dans la config YunoHost # Enregistre les infos dans la config YunoHost
sudo yunohost app setting $app domain -v $domain sudo yunohost app setting $app domain -v $domain
@ -90,11 +81,7 @@ db_pwd=$(head -n20 /dev/urandom | tr -c -d 'A-Za-z0-9' | head -c20)
# Utilise '$app' comme nom d'utilisateur et de base de donnée # Utilise '$app' comme nom d'utilisateur et de base de donnée
db_user=$app db_user=$app
# Initialise la base de donnée et stocke le mot de passe mysql. # Initialise la base de donnée et stocke le mot de passe mysql.
if [ $ynh_version = "2.4" ]; then
ynh_mysql_create_db $db_user $db_user $db_pwd ynh_mysql_create_db $db_user $db_user $db_pwd
else
sudo yunohost app initdb $db_user -p $db_pwd
fi
sudo yunohost app setting $app mysqlpwd -v $db_pwd sudo yunohost app setting $app mysqlpwd -v $db_pwd
@ -156,7 +143,7 @@ done
sudo chown -R www-data: $final_path sudo chown -R www-data: $final_path
# Donne un accès public pour curl # Donne un accès public pour curl
sudo yunohost app setting wordpressms skipped_uris -v "/" sudo yunohost app setting $app unprotected_uris -v "/"
# Recharge la configuration Nginx et php5-fpm # Recharge la configuration Nginx et php5-fpm
sudo service nginx reload sudo service nginx reload
sudo service php5-fpm reload sudo service php5-fpm reload
@ -169,13 +156,13 @@ echo "127.0.0.1 $domain #wordpress_yunohost" | sudo tee -a /etc/hosts
curl -kL --data "&weblog_title=YunoBlog&user_name=$admin_wordpress&admin_password=$db_pwd&admin_password2=$db_pwd&admin_email=$admin_wordpress@$domain&language=$language&Submit=Install+WordPress" https://$domain$path/wp-admin/install.php?step=2 > /dev/null 2>&1 curl -kL --data "&weblog_title=YunoBlog&user_name=$admin_wordpress&admin_password=$db_pwd&admin_password2=$db_pwd&admin_email=$admin_wordpress@$domain&language=$language&Submit=Install+WordPress" https://$domain$path/wp-admin/install.php?step=2 > /dev/null 2>&1
sleep 5 sleep 5
mysql -u $db_user -p$db_pwd $db_user -e "select * from wp_options;" > /dev/null 2>&1 mysql --debug-check -u $db_user -p$db_pwd $db_user -e "select * from wp_options;" > /dev/null 2>&1
result=$? result=$?
loop_number=1 loop_number=1
while [ $result != 0 ] && [ $loop_number -lt 5 ]; while [ $result != 0 ] && [ $loop_number -lt 5 ];
do do
sleep 5 sleep 5
mysql -u $db_user -p$db_pwd $db_user -e "select * from wp_options;" > /dev/null 2>&1 mysql --debug-check -u $db_user -p$db_pwd $db_user -e "select * from wp_options;" > /dev/null 2>&1
let result=$? let result=$?
let loop_number++ let loop_number++
done done
@ -186,61 +173,60 @@ sudo sed -i "s/__LANGUAGE__/$language/g" ../conf/sql/*.sql
sudo sed -i "s/__DATE__/$(date +%s)/g" ../conf/sql/*.sql sudo sed -i "s/__DATE__/$(date +%s)/g" ../conf/sql/*.sql
# Charge les commandes sql communes à tous les scripts. # Charge les commandes sql communes à tous les scripts.
mysql -u $db_user -p$db_pwd $db_user < ../conf/sql/common.sql mysql --debug-check -u $db_user -p$db_pwd $db_user < ../conf/sql/common.sql
if [ "$multisite" = "Yes" ]; if [ "$multisite" = "Yes" ]
then then
# Installation de php5-cli pour wp-cli # Installation de php5-cli pour wp-cli
sudo apt-get update sudo apt-get update
sudo apt-get install php5-cli -qy sudo apt-get install php5-cli -qy
sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
# Autorise le multisite wordpress # Autorise le multisite wordpress
sudo sed -i "s@//--MULTISITE1--define@define@g" $final_path/wp-config.php sudo sed -i "s@//--MULTISITE1--define@define@g" $final_path/wp-config.php
# Active le multisite via wp-cli. # Active le multisite via wp-cli.
php $final_path/wp-cli.phar core multisite-convert --path=$final_path --base=$path/ php $final_path/wp-cli.phar core multisite-convert --path=$final_path --base=$path/ > /dev/null 2>&1
echo "The 2 warnings of php about \"Permission denied\" on wp-config.php are normal. The install script writing into this file, not wp-cli!" # echo "The 2 warnings of php about \"Permission denied\" on wp-config.php are normal. The install script writing into this file, not wp-cli!"
# Active le multisite wordpress # Active le multisite wordpress
sudo sed -i "s@//--MULTISITE2--define@define@g" $final_path/wp-config.php sudo sed -i "s@//--MULTISITE2--define@define@g" $final_path/wp-config.php
# Charge les commandes sql pour les plugins # Charge les commandes sql pour activer les plugins
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
sudo sed -i "s@#--PRIVATE--@@g" ../conf/sql/multisite.sql sudo sed -i "s@#--PRIVATE--@@g" ../conf/sql/multisite.sql
else else
sudo sed -i "s@#--PUBLIC--@@g" ../conf/sql/multisite.sql sudo sed -i "s@#--PUBLIC--@@g" ../conf/sql/multisite.sql
fi fi
mysql -u $db_user -p$db_pwd $db_user < ../conf/sql/multisite.sql mysql --debug-check -u $db_user -p$db_pwd $db_user < ../conf/sql/multisite.sql
else else
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@#--PRIVATE--@@g" ../conf/sql/single.sql sudo sed -i "s@#--PRIVATE--@@g" ../conf/sql/single.sql
else else
sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php
sudo sed -i "s@#--PRIVATE--@#@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf sudo sed -i "s@#--PRIVATE--@#@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@#--PUBLIC--@@g" ../conf/sql/single.sql sudo sed -i "s@#--PUBLIC--@@g" ../conf/sql/single.sql
fi fi
# Charge les commandes sql pour les plugins # Charge les commandes sql pour activer les plugins
mysql -u $db_user -p$db_pwd $db_user < ../conf/sql/single.sql mysql --debug-check -u $db_user -p$db_pwd $db_user < ../conf/sql/single.sql
fi fi
# Décommente les add_filter, qui auraient provoqué une erreur avec wp-cli
sudo sed -i "s@//add_filter@add_filter@g" $final_path/wp-config.php
# Configure les droits d'accès au fichiers # Configure les droits d'accès au fichiers
# -rw-r--r-- sur les fichiers # Les fichiers appartiennent à www-data, pour permettre les mises à jour.
sudo find $final_path -type f -print0 | xargs -0 sudo chmod 644 sudo chown -R www-data: $final_path
# drwxr-xr-x sur les dossiers # Sauf le fichier de config wp-config.php qui appartient à root
sudo find $final_path -type d -print0 | xargs -0 sudo chmod 755 sudo chown root: $final_path/wp-config.php
# Les fichiers appartiennent à root
sudo chown -R root: $final_path
# Sauf le dossier wp-content qui appartient à www-data
sudo chown -R www-data:root $final_path/wp-content
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
# Retire l'accès public # Retire l'accès public
sudo yunohost app setting wordpressms skipped_uris -d sudo yunohost app setting $app unprotected_uris -d
sudo yunohost app ssowatconf sudo yunohost app ssowatconf
fi fi
@ -248,5 +234,6 @@ fi
sudo sed -i '/#wordpress_yunohost/d' /etc/hosts sudo sed -i '/#wordpress_yunohost/d' /etc/hosts
sudo service nginx reload sudo service nginx reload
# wp-cli me semble un peu trop permissif... Il a terminé son travail... # wp-cli me semble un peu trop permissif... Il a terminé son travail...
sudo rm $final_path/wp-cli.phar sudo rm -f $final_path/wp-cli.phar

View file

@ -1,16 +1,10 @@
#!/bin/bash #!/bin/bash
# Récupère les infos de l'application. # Récupère les infos de l'application.
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
# Source app helpers # Source app helpers
. /usr/share/yunohost/helpers . /usr/share/yunohost/helpers
else
app=wordpressms
MYSQL_ROOT_PWD_FILE="/etc/yunohost/mysql"
fi
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
# Suppression de la base de donnée et de l'utilisateur associé. # Suppression de la base de donnée et de l'utilisateur associé.
@ -18,12 +12,8 @@ domain=$(sudo yunohost app setting $app domain)
db_user=$app db_user=$app
if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then if mysqlshow -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) | grep -q "^| $db_user"; then
echo "Delete db" echo "Delete db"
if [ $ynh_version = "2.4" ]; then
ynh_mysql_drop_db $db_user ynh_mysql_drop_db $db_user
ynh_mysql_drop_user $db_user ynh_mysql_drop_user $db_user
else
mysql -u root -p$(sudo cat $MYSQL_ROOT_PWD_FILE) -e "DROP DATABASE $db_user ; DROP USER $db_user@localhost ;"
fi
fi fi
# Suppression du dossier de l'application # Suppression du dossier de l'application

View file

@ -1,24 +1,56 @@
#!/bin/bash #!/bin/bash
# This restore script is adapted to Yunohost >=2.4
# Récupère les infos de l'application. # The parameter $1 is the backup directory location dedicated to the app
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2) backup_dir=$1
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME # The parameter $2 is the id of the app instance ex: ynhexample__2
else app=$2
app=wordpressms
fi # Get old parameter of the app
final_path=$(sudo yunohost app setting $app final_path)
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
is_public=$(sudo yunohost app setting $app is_public)
final_path=$(sudo yunohost app setting $app final_path)
# The parameter $1 is the uncompressed restore directory location # Check domain/path availability
backup_dir=$1/apps/$app sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
echo "There is already an app on this URL : $domain$path" | sudo tee /dev/stderr
exit 1
fi
# Restore sources & data if [ -d $final_path ]; then
sudo cp -a $backup_dir/sources/. $final_path echo "There is already a directory: $final_path " | sudo tee /dev/stderr
exit 1
fi
sudo cp -a "${backup_dir}/var/www/$app" $final_path
# Restore Nginx and YunoHost parameters
sudo cp -a $backup_dir/yunohost/. /etc/yunohost/apps/$app db_pwd=$(sudo yunohost app setting $app mysqlpwd)
sudo cp -a $backup_dir/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf db_user=$app
sudo yunohost app initdb $db_user -p $db_pwd
sudo su -c "mysql -u $db_user -p$db_pwd $app < ${backup_dir}/db.sql"
sudo rm -f "${backup_dir}/db.sql"
sudo sed -i -e "s/'DB_USER', *'[^']*'/'DB_USER', '$app'/g" $final_path/wp-config.php
sudo sed -i -e "s/'DB_NAME', *'[^']*'/'DB_NAME', '$app'/g" $final_path/wp-config.php
# Set permissions
# Les fichiers appartiennent à www-data, pour permettre les mises à jour.
sudo chown -R www-data: $final_path
# Sauf le fichier de config wp-config.php qui appartient à root
sudo chown root: $final_path/wp-config.php
# Restore conf files
conf=/etc/nginx/conf.d/$domain.d/$app.conf
if [ -f $conf ]; then
echo "There is already a nginx conf file at this path: $conf " | sudo tee /dev/stderr
exit 1
fi
sudo cp -a "${backup_dir}/conf/nginx.conf" $conf
# Reload Nginx
sudo service nginx reload
# Copy dedicated php-fpm process from backup folder to the right location # Copy dedicated php-fpm process from backup folder to the right location
sudo cp -a $backup_dir/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf sudo cp -a $backup_dir/php-fpm.conf /etc/php5/fpm/pool.d/$app.conf
@ -26,5 +58,9 @@ sudo cp -a $backup_dir/php-fpm.ini /etc/php5/fpm/conf.d/20-$app.ini
# And restart service # And restart service
sudo service php5-fpm reload sudo service php5-fpm reload
# Restart webserver # Set ssowat config
sudo service nginx reload if [ "$is_public" = "No" ];
then
sudo yunohost app setting $app skipped_uris -d
fi
sudo yunohost app ssowatconf

View file

@ -1,35 +1,51 @@
#!/bin/bash #!/bin/bash
# Récupère les infos de l'application. # Récupère les infos de l'application.
ynh_version=$(sudo yunohost -v | grep "moulinette:" | cut -d' ' -f2 | cut -d'.' -f1,2)
if [ $ynh_version = "2.4" ]; then
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
else
app=wordpressms
fi
domain=$(sudo yunohost app setting $app domain) domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path) path=$(sudo yunohost app setting $app path)
admin_wordpress=$(sudo yunohost app setting $app admin)
language=$(sudo yunohost app setting $app language)
is_public=$(sudo yunohost app setting $app is_public) is_public=$(sudo yunohost app setting $app is_public)
multisite=$(sudo yunohost app setting $app multisite) multisite=$(sudo yunohost app setting $app multisite)
final_path=$(sudo yunohost app setting $app final_path) final_path=$(sudo yunohost app setting $app final_path)
root_pwd=$(sudo cat /etc/yunohost/mysql)
db_name=$app
if [[ "$admin_wordpress" = "" ]];
then
mysql -u root -p$root_pwd $db_name -e "select MAX(user_login) from wp_users where user_status=0 INTO OUTFILE '/tmp/wordpressuser';"
admin_wordpress=$(cat /tmp/wordpressuser)
sudo rm -f /tmp/wordpressuser
sudo yunohost app setting $app admin -v $admin_wordpress
fi
# Décompresse la source if [[ "$final_path" = "" ]];
tar -x -f ../sources/wordpress.tar.gz then
# Copie les fichiers sources final_path=/var/www/$app
sudo cp -a wordpress/. "$final_path" sudo yunohost app setting $app final_path -v $final_path
# Copie les fichiers additionnels ou modifiés. fi
sudo cp -a ../sources/ajouts/. "$final_path"
# Et copie le fichier de config nginx if [[ "$language" = "" ]];
then
language=$(sudo grep WPLANG $final_path/wp-config.php | cut -d"'" -f4)
sudo yunohost app setting $app language -v $language
fi
# Check if admin is not null
if [[ "$admin_wordpress" = "" || "$is_public" = "" || "$language" = "" ]]; then
echo "Unable to upgrade, please contact support"
exit 1
fi
# Copie le fichier de config nginx
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Modifie les variables dans le fichier de configuration nginx # Modifie les variables dans le fichier de configuration nginx
sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf sudo sed -i "s@__PATHTOCHANGE__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf sudo sed -i "s@__FINALPATH__@$final_path@g" /etc/nginx/conf.d/$domain.d/$app.conf
sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf sudo sed -i "s@__NAMETOCHANGE__@$app@g" /etc/nginx/conf.d/$domain.d/$app.conf
# Créer le fichier de configuration du pool php-fpm et le configure. # Copie le fichier de configuration du pool php-fpm et le configure.
sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf sed -i "s@__NAMETOCHANGE__@$app@g" ../conf/php-fpm.conf
sed -i "s@__FINALPATH__@$final_path@g" ../conf/php-fpm.conf sed -i "s@__FINALPATH__@$final_path@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf finalphpconf=/etc/php5/fpm/pool.d/$app.conf
@ -43,40 +59,35 @@ sudo service php5-fpm reload
if [ "$multisite" = "Yes" ]; if [ "$multisite" = "Yes" ];
then then
sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf sudo sed -i "s@#--MULTISITE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
else else
multisite="No"
if [ "$is_public" = "No" ]; if [ "$is_public" = "No" ];
then then
sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/wordpressms.conf sudo sed -i "s@#--PRIVATE--@@g" /etc/nginx/conf.d/$domain.d/$app.conf
else else
sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php sudo sed -i "s@//--PUBLIC--define@define@g" $final_path/wp-config.php
fi fi
fi fi
sudo yunohost app setting $app multisite -v $multisite
# Configure les droits d'accès au fichiers # Configure les droits d'accès au fichiers
# -rw-r--r-- sur les fichiers # Les fichiers appartiennent à www-data, pour permettre les mises à jour.
sudo find $final_path -type f -print0 | xargs -0 sudo chmod 644 sudo chown -R www-data: $final_path
# drwxr-xr-x sur les dossiers # Sauf le fichier de config wp-config.php qui appartient à root
sudo find $final_path -type d -print0 | xargs -0 sudo chmod 755 sudo chown root: $final_path/wp-config.php
# Les fichiers appartiennent à root
sudo chown -R root: $final_path
# Sauf le dossier wp-content qui appartient à www-data
sudo chown -R www-data:root $final_path/wp-content
if [ "$is_public" = "No" ];
then sudo yunohost app setting $app skipped_uris -d # Retire le skipped_uris si il existe encore.
# Retire l'accès public if [ "$is_public" = "No" ]; then # Retire l'accès public
sudo yunohost app setting wordpressms skipped_uris -d sudo yunohost app setting $app unprotected_uris -d
sudo yunohost app ssowatconf else # Ou remplace le skipped_uris par unprotected_uris le cas échéant.
sudo yunohost app setting $app unprotected_uris -v "/"
fi fi
sudo yunohost app ssowatconf
# Recharge la configuration Nginx et php5-fpm # Recharge la configuration Nginx
sudo service nginx reload sudo service nginx reload
sudo service php5-fpm reload
# Régénère la configuration de SSOwat # Régénère la configuration de SSOwat
sudo yunohost app ssowatconf sudo yunohost app ssowatconf
# wp-cli me semble un peu trop permissif... Il a terminé son travail...
sudo rm $final_path/wp-cli.phar

View file

@ -15,6 +15,7 @@ if( isset( $_GET[ 'tab' ] ) ) {
<h2 class="nav-tab-wrapper"> <h2 class="nav-tab-wrapper">
<a href="<?php echo add_query_arg( array('tab' => 'simple'), $_SERVER['REQUEST_URI'] ); ?>" class="nav-tab <?php echo $active_tab == 'simple' ? 'nav-tab-active' : ''; ?>">Simple</a> <a href="<?php echo add_query_arg( array('tab' => 'simple'), $_SERVER['REQUEST_URI'] ); ?>" class="nav-tab <?php echo $active_tab == 'simple' ? 'nav-tab-active' : ''; ?>">Simple</a>
<a href="<?php echo add_query_arg( array('tab' => 'advanced'), $_SERVER['REQUEST_URI'] ); ?>" class="nav-tab <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>">Advanced</a> <a href="<?php echo add_query_arg( array('tab' => 'advanced'), $_SERVER['REQUEST_URI'] ); ?>" class="nav-tab <?php echo $active_tab == 'advanced' ? 'nav-tab-active' : ''; ?>">Advanced</a>
<a href="<?php echo add_query_arg( array('tab' => 'user'), $_SERVER['REQUEST_URI'] ); ?>" class="nav-tab <?php echo $active_tab == 'user' ? 'nav-tab-active' : ''; ?>">User</a>
<a href="<?php echo add_query_arg( array('tab' => 'help'), $_SERVER['REQUEST_URI'] ); ?>" class="nav-tab <?php echo $active_tab == 'help' ? 'nav-tab-active' : ''; ?>">Help</a> <a href="<?php echo add_query_arg( array('tab' => 'help'), $_SERVER['REQUEST_URI'] ); ?>" class="nav-tab <?php echo $active_tab == 'help' ? 'nav-tab-active' : ''; ?>">Help</a>
</h2> </h2>
@ -45,7 +46,7 @@ if( isset( $_GET[ 'tab' ] ) ) {
<td> <td>
<input type="text" name="<?php echo $this->get_field_name('base_dn'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('base_dn'); ?>" /> <input type="text" name="<?php echo $this->get_field_name('base_dn'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('base_dn'); ?>" />
<br/> <br/>
Example: For subdomain.domain.suffix, use DC=subdomain,DC=domain,DC=suffix. Do not specify an OU here. Example: For subdomain.domain.suffix, use DC=subdomain,DC=domain,DC=suffix. In most cases you should not specify an ou here.
</td> </td>
</tr> </tr>
<tr> <tr>
@ -106,12 +107,28 @@ if( isset( $_GET[ 'tab' ] ) ) {
<p>Most users should leave these alone.</p> <p>Most users should leave these alone.</p>
<table class="form-table"> <table class="form-table">
<tbody> <tbody>
<tr>
<th scope="row" valign="top">Group Base DN (optional)</th>
<td>
<input type="text" name="<?php echo $this->get_field_name('group_base_dn'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('group_base_dn'); ?>" />
<br/>
If you need to specify a different Base DN for group searches. Example: For subdomain.domain.suffix, use ou=groups,DC=subdomain,DC=domain,DC=suffix.
</td>
</tr>
<tr> <tr>
<th scope="row" valign="top">LDAP Login Attribute</th> <th scope="row" valign="top">LDAP Login Attribute</th>
<td> <td>
<input type="text" name="<?php echo $this->get_field_name('ol_login'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('ol_login'); ?>" /> <input type="text" name="<?php echo $this->get_field_name('ol_login'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('ol_login'); ?>" />
<br /> <br />
In case your installation uses something other than <b>uid</b>; Default: <b>uid</b>;
</td>
</tr>
<tr>
<th scope="row" valign="top">LDAP Group Attribute</th>
<td>
<input type="text" name="<?php echo $this->get_field_name('ol_group'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('ol_group'); ?>" />
<br />
In case your installation uses something other than <b>cn</b>;
</td> </td>
</tr> </tr>
<tr> <tr>
@ -135,6 +152,77 @@ if( isset( $_GET[ 'tab' ] ) ) {
Only applies to Open LDAP. Typically 3. Only applies to Open LDAP. Typically 3.
</td> </td>
</tr> </tr>
<tr>
<th scope="row" valign="top">Search Sub OUs</th>
<td>
<input type="hidden" name="<?php echo $this->get_field_name('search_sub_ous'); ?>" value="false" />
<label><input type="checkbox" name="<?php echo $this->get_field_name('search_sub_ous'); ?>" value="true" <?php if( str_true($this->get_setting('search_sub_ous')) ) echo "checked"; ?> /> Also search sub-OUs of Base DN. For example, if the base DN is "ou=People,dc=example,dc=com", also search "ou=Staff,ou=People,dc=example,dc=com for uid=<i>username</i></label><br/>
</td>
</tr>
<tr>
<th scope="row" valign="top">Login Domain</th>
<td>
<input type="text" name="<?php echo $this->get_field_name('login_domain'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('login_domain'); ?>" /><br/>
prefixes login names with this domain, f.i. mydomain\username
</td>
</tr>
</tbody>
</table>
<p><input class="button-primary" type="submit" value="Save Settings" /></p>
<?php elseif ( $active_tab == "user" ): ?>
<h3>User Data</h3>
<p>These settings give you control over which LDAP attributes are used for user creation.</p>
<table class="form-table" style="margin-bottom: 20px;">
<tbody>
<tr>
<th scope="row" valign="top">First name</th>
<td>
<input type="text" name="<?php echo $this->get_field_name('user_first_name_attribute'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('user_first_name_attribute'); ?>" />
<br/>
The LDAP attribute for the first name.
</td>
</tr>
<tr>
<th scope="row" valign="top">Last name</th>
<td>
<input type="text" name="<?php echo $this->get_field_name('user_last_name_attribute'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('user_last_name_attribute'); ?>" />
<br/>
The LDAP attribute for the last name.
</td>
</tr>
<tr>
<th scope="row" valign="top">Email</th>
<td>
<input type="text" name="<?php echo $this->get_field_name('user_email_attribute'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('user_email_attribute'); ?>" />
<br/>
The LDAP attribute for the email.
</td>
</tr>
<tr>
<th scope="row" valign="top">Website</th>
<td>
<input type="text" name="<?php echo $this->get_field_name('user_url_attribute'); ?>" value="<?php echo $SimpleLDAPLogin->get_setting('user_url_attribute'); ?>" />
<br/>
The LDAP attribute for the website.
</td>
</tr>
</tbody>
</table>
<hr />
<h3>Additional user data</h3>
<p>Additional user data can be stored as user meta data. You can specify the LDAP
attributes and the associated wordpress meta keys in the format <i>&lt;ldap_attribute_name&gt;:&lt;wordpress_meta_key&gt;</i>. Multiple attributes can be given on separate lines.</p>
<p> Example:<br/><i>phone:user_phone_number</i><br/><i>adress:user_home_address</i></p>
<table class="form-table" style="margin-bottom: 20px;">
<tbody>
<tr>
<th scope="row" valign="top">Meta data</th>
<td>
<textarea name="<?php echo $this->get_field_name('user_meta_data'); ?>">
<?php echo join("\n", array_map(function ($attr) { return join(':', $attr); }, $SimpleLDAPLogin->get_setting('user_meta_data'))); ?>
</textarea>
</td>
</tr>
</tbody> </tbody>
</table> </table>
<p><input class="button-primary" type="submit" value="Save Settings" /></p> <p><input class="button-primary" type="submit" value="Save Settings" /></p>
@ -142,7 +230,7 @@ if( isset( $_GET[ 'tab' ] ) ) {
<h3>Help</h3> <h3>Help</h3>
<p>Here's a brief primer on how to effectively use and test Simple LDAP Login.</p> <p>Here's a brief primer on how to effectively use and test Simple LDAP Login.</p>
<h4>Testing</h4> <h4>Testing</h4>
<p>The most effective way to test logins is to use two browsers. In other words, keep WordPress Admin open in Chrome, and use Firefox to try logging in. This will give you real time feedback on your settings and prevent you from inadvertently locking yourself out.</p> <p>The most effective way to test logins is to use two browsers. In other words, keep the WordPress Dashboard open in Chrome, and use Firefox to try logging in. This will give you real time feedback on your settings and prevent you from inadvertently locking yourself out.</p>
<h4>Which raises the question, what happens if I get locked out?</h4> <h4>Which raises the question, what happens if I get locked out?</h4>
<p>If you accidentally lock yourself out, the easiest way to get back in is to rename <strong><?php echo plugin_dir_path(__FILE__); ?></strong> to something else and then refresh. WordPress will detect the change and disable Simple LDAP Login. You can then rename the folder back to its previous name.</p> <p>If you accidentally lock yourself out, the easiest way to get back in is to rename <strong><?php echo plugin_dir_path(__FILE__); ?></strong> to something else and then refresh. WordPress will detect the change and disable Simple LDAP Login. You can then rename the folder back to its previous name.</p>
<?php endif; ?> <?php endif; ?>

View file

@ -3,7 +3,7 @@
Plugin Name: Simple LDAP Login Plugin Name: Simple LDAP Login
Plugin URI: http://clifgriffin.com/simple-ldap-login/ Plugin URI: http://clifgriffin.com/simple-ldap-login/
Description: Authenticate WordPress against LDAP. Description: Authenticate WordPress against LDAP.
Version: 1.5.5 Version: 1.6.0
Author: Clif Griffin Development Inc. Author: Clif Griffin Development Inc.
Author URI: http://cgd.io Author URI: http://cgd.io
*/ */
@ -14,8 +14,11 @@ class SimpleLDAPLogin {
var $settings = array(); var $settings = array();
var $adldap; var $adldap;
var $ldap; var $ldap;
var $network_version = null;
var $version = "160";
public function __construct () { public function __construct () {
$this->settings = $this->get_settings_obj( $this->prefix ); $this->settings = $this->get_settings_obj( $this->prefix );
if( $this->get_setting('directory') == "ad" ) { if( $this->get_setting('directory') == "ad" ) {
@ -32,7 +35,14 @@ class SimpleLDAPLogin {
} }
add_action('admin_init', array($this, 'save_settings') ); add_action('admin_init', array($this, 'save_settings') );
if ($this->is_network_version()) {
add_action('network_admin_menu', array($this, 'menu') );
}
else {
add_action('admin_menu', array($this, 'menu') ); add_action('admin_menu', array($this, 'menu') );
}
if ( str_true($this->get_setting('enabled')) ) { if ( str_true($this->get_setting('enabled')) ) {
add_filter('authenticate', array($this, 'authenticate'), 1, 3); add_filter('authenticate', array($this, 'authenticate'), 1, 3);
@ -41,7 +51,9 @@ class SimpleLDAPLogin {
register_activation_hook( __FILE__, array($this, 'activate') ); register_activation_hook( __FILE__, array($this, 'activate') );
// If version is false, and old version detected, run activation // If version is false, and old version detected, run activation
if( $this->get_setting('version') === false || get_option('simpleldap_domain_controllers', false) !== false ) $this->activate(); if( $this->get_setting('version') === false || $this->get_setting('version') != $version ) {
$this->upgrade_settings();
}
} }
public static function getInstance () { public static function getInstance () {
@ -57,91 +69,140 @@ class SimpleLDAPLogin {
$this->add_setting('base_dn', "DC=mydomain,DC=org"); $this->add_setting('base_dn', "DC=mydomain,DC=org");
$this->add_setting('domain_controllers', array("dc01.mydomain.local") ); $this->add_setting('domain_controllers', array("dc01.mydomain.local") );
$this->add_setting('directory', "ad"); $this->add_setting('directory', "ad");
$this->add_setting('role', "Contributor"); $this->add_setting('role', "contributor");
$this->add_setting('high_security', "true"); $this->add_setting('high_security', "true");
$this->add_setting('ol_login', "uid"); $this->add_setting('ol_login', "uid");
$this->add_setting('ol_group', "cn");
$this->add_setting('use_tls', "false"); $this->add_setting('use_tls', "false");
$this->add_setting('ldap_port', 389); $this->add_setting('ldap_port', 389);
$this->add_setting('ldap_version', 3); $this->add_setting('ldap_version', 3);
$this->add_setting('create_users', "false"); $this->add_setting('create_users', "false");
$this->add_setting('enabled', "false"); $this->add_setting('enabled', "false");
$this->add_setting('search_sub_ous', "false");
$this->add_setting('group_dn', "");
$this->add_setting('group_uid', "memberUid");
// User attribute settings
$this->add_setting('user_first_name_attribute', "givenname");
$this->add_setting('user_last_name_attribute', "sn");
$this->add_setting('user_email_attribute', "mail");
$this->add_setting('user_url_attribute', "wwwhomepage");
$this->add_setting('user_meta_data', array() );
}
function upgrade_settings() {
if( $this->get_setting('version') === false ) { if( $this->get_setting('version') === false ) {
$this->set_setting('version', '1.5');
$this->set_setting('enabled', 'true'); $this->set_setting('enabled', 'true');
if ( $this->set_setting('account_suffix', get_option('simpleldap_account_suffix')) ) { if ($this->is_network_version()) {
//delete_option('simpleldap_account_suffix'); $account_suffix = get_site_option('simpleldap_account_suffix');
$simpleldap_base_dn = get_site_option('simpleldap_base_dn');
$simpleldap_domain_controllers = get_site_option('simpleldap_domain_controllers');
$simpleldap_directory_type = get_site_option('simpleldap_directory_type');
$simpleldap_group = get_site_option('simpleldap_group');
$simpleldap_account_type = get_site_option('simpleldap_account_type');
$simpleldap_ol_login = get_site_option('simpleldap_ol_login');
$simpleldap_use_tls = get_site_option('simpleldap_use_tls');
$simpleldap_login_mode = get_site_option('simpleldap_login_mode');
$simpleldap_security_mode = get_site_option('simpleldap_security_mode');
}
else {
$account_suffix = get_option('simpleldap_account_suffix');
$simpleldap_base_dn = get_option('simpleldap_base_dn');
$simpleldap_domain_controllers = get_option('simpleldap_domain_controllers');
$simpleldap_directory_type = get_option('simpleldap_directory_type');
$simpleldap_group = get_option('simpleldap_group');
$simpleldap_account_type = get_option('simpleldap_account_type');
$simpleldap_ol_login = get_option('simpleldap_ol_login');
$simpleldap_use_tls = get_option('simpleldap_use_tls');
$simpleldap_login_mode = get_option('simpleldap_login_mode');
$simpleldap_security_mode = get_option('simpleldap_security_mode');
} }
if ( $this->set_setting('base_dn', get_option('simpleldap_base_dn')) ) { $this->set_setting('account_suffix', $account_suffix );
//delete_option('simpleldap_base_dn'); $this->set_setting('base_dn', $simpleldap_base_dn);
} $this->set_setting('domain_controllers', $simpleldap_domain_controllers);
$this->set_setting('groups', (array)$simpleldap_group );
$this->set_setting('role', $simpleldap_account_type);
$this->set_setting('ol_login', $simpleldap_ol_login);
$this->set_setting('use_tls', str_true( $simpleldap_use_tls ) );
if ( $this->set_setting('domain_controllers', get_option('simpleldap_domain_controllers')) ) { // Directory Type
//delete_option('simpleldap_domain_controllers'); if ( $simpleldap_directory_type == "directory_ad" ) {
} $this->set_setting('directory', 'ad');
$directory_result = false;
if ( get_option('simpleldap_directory_type') == "directory_ad" ) {
$directory_result = $this->set_setting('directory', 'ad');
} else { } else {
$directory_result = $this->set_setting('directory', 'ol'); $this->set_setting('directory', 'ol');
}
//if( $directory_result ) delete_option('simpleldap_directory_type');
unset($directory_result);
if ( $this->set_setting('groups', (array)get_option('simpleldap_group') ) ) {
//delete_option('simpleldap_group');
}
if ( $this->set_setting('role', get_option('simpleldap_account_type')) ) {
//delete_option('simpleldap_account_type');
}
if ( $this->set_setting('ol_login', get_option('simpleldap_ol_login')) ) {
//delete_option('simpleldap_ol_login');
}
if ( $this->set_setting('use_tls', str_true( get_option('simpleldap_use_tls') ) ) ) {
//delete_option('simpleldap_use_tls');
} }
// Create User Setting
$create_users = false; $create_users = false;
if ( get_option('simpleldap_login_mode') == "mode_create_all" || get_option('simpleldap_login_mode') == "mode_create_group" ) { if ( $simpleldap_login_mode == "mode_create_all" || $simpleldap_login_mode == "mode_create_group" ) {
$create_users = true; $this->set_setting('create_users', true);
}
if ( $this->set_setting('create_users', $create_users) ) {
//delete_option('simpleldap_login_mode');
} }
// High Security Setting
$high_security = false; $high_security = false;
if ( get_option('simpleldap_security_mode') == "security_high" ) { if ( $simpleldap_security_mode == "security_high" ) {
$high_security = true; $this->set_setting('high_security', true);
}
if ( $this->set_setting('high_security', $high_security) ) {
//delete_option('simpleldap_security_mode');
} }
} }
if ( $this->get_setting('version') < $this->version || $this->get_setting('version') === false ) {
$this->add_setting('search_sub_ous', "false");
$this->add_setting('group_base_dn', "");
$this->add_setting('group_uid', "memberUid");
// User attribute settings
$this->add_setting('user_first_name_attribute', "givenname");
$this->add_setting('user_last_name_attribute', "sn");
$this->add_setting('user_email_attribute', "mail");
$this->add_setting('user_url_attribute', "wwwhomepage");
$this->add_setting('user_meta_data', array() );
}
// Update version
$this->set_setting( 'version', $this->version );
} }
function menu () { function menu () {
if ($this->is_network_version()) {
add_submenu_page(
"settings.php",
"Simple LDAP Login",
"Simple LDAP Login",
'manage_network_plugins',
"simple-ldap-login",
array($this, 'admin_page')
);
}
else {
add_options_page("Simple LDAP Login", "Simple LDAP Login", 'manage_options', "simple-ldap-login", array($this, 'admin_page') ); add_options_page("Simple LDAP Login", "Simple LDAP Login", 'manage_options', "simple-ldap-login", array($this, 'admin_page') );
} }
}
function admin_page () { function admin_page () {
include 'Simple-LDAP-Login-Admin.php'; include 'Simple-LDAP-Login-Admin.php';
} }
function get_settings_obj () { function get_settings_obj () {
if ( $this->is_network_version() ) {
return get_site_option("{$this->prefix}settings", false);
}
else {
return get_option("{$this->prefix}settings", false); return get_option("{$this->prefix}settings", false);
} }
}
function set_settings_obj ( $newobj ) { function set_settings_obj ( $newobj ) {
if ( $this->is_network_version() ) {
return update_site_option("{$this->prefix}settings", $newobj);
}
else {
return update_option("{$this->prefix}settings", $newobj); return update_option("{$this->prefix}settings", $newobj);
} }
}
function set_setting ( $option = false, $newvalue ) { function set_setting ( $option = false, $newvalue ) {
if( $option === false ) return false; if( $option === false ) return false;
@ -175,7 +236,12 @@ class SimpleLDAPLogin {
foreach( $new_settings as $setting_name => $setting_value ) { foreach( $new_settings as $setting_name => $setting_value ) {
foreach( $setting_value as $type => $value ) { foreach( $setting_value as $type => $value ) {
if( $type == "array" ) { if( $setting_name == 'user_meta_data') {
$this->set_setting($setting_name,
array_map( function ($attr) { return explode(':', $attr); },
array_filter(preg_split('/\r\n|\n|\r|;/', $value))));
}
elseif( $type == "array") {
$this->set_setting($setting_name, explode(";", $value)); $this->set_setting($setting_name, explode(";", $value));
} else { } else {
$this->set_setting($setting_name, $value); $this->set_setting($setting_name, $value);
@ -208,6 +274,11 @@ class SimpleLDAPLogin {
$user_obj = get_user_by('login', $username); $user_obj = get_user_by('login', $username);
if( user_can($user_obj, 'update_core') ) $local_admin = true; if( user_can($user_obj, 'update_core') ) $local_admin = true;
$local_admin = apply_filters( 'sll_force_ldap', $local_admin );
$password = stripslashes($password);
// To force LDAP authentication, the filter should return boolean false
if ( empty($username) || empty($password) ) { if ( empty($username) || empty($password) ) {
$error = new WP_Error(); $error = new WP_Error();
@ -221,7 +292,7 @@ class SimpleLDAPLogin {
} }
// If high security mode is enabled, remove default WP authentication hook // If high security mode is enabled, remove default WP authentication hook
if ( str_true( $this->get_setting('high_security') ) && ! $local_admin ) { if ( apply_filters('sll_remove_default_authentication_hook', str_true( $this->get_setting('high_security') ) && ! $local_admin ) ) {
remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3); remove_filter('authenticate', 'wp_authenticate_username_password', 20, 3);
} }
@ -237,13 +308,19 @@ class SimpleLDAPLogin {
if ( ! $user || ( strtolower($user->user_login) !== strtolower($username) ) ) { if ( ! $user || ( strtolower($user->user_login) !== strtolower($username) ) ) {
if( ! str_true($this->get_setting('create_users')) ) { if( ! str_true($this->get_setting('create_users')) ) {
do_action( 'wp_login_failed', $username ); do_action( 'wp_login_failed', $username );
return new WP_Error('invalid_username', __('<strong>Simple LDAP Login Error</strong>: LDAP credentials are correct, but there is no matching WordPress user and user creation is not enabled.')); return $this->ldap_auth_error('invalid_username', __('<strong>Simple LDAP Login Error</strong>: LDAP credentials are correct, but there is no matching WordPress user and user creation is not enabled.'));
} }
$new_user = wp_insert_user( $this->get_user_data( $username, $this->get_setting('directory') ) ); $new_user = wp_insert_user( $this->get_user_data( $username, $this->get_setting('directory') ) );
if( ! is_wp_error($new_user) ) if( ! is_wp_error($new_user) )
{ {
// Add user meta data
$user_meta_data = $this->get_user_meta_data( $username, $this->get_setting('directory'));
foreach( $user_meta_data as $meta_key => $meta_value ) {
add_user_meta($new_user, $meta_key, $meta_value);
}
// Successful Login // Successful Login
$new_user = new WP_User($new_user); $new_user = new WP_User($new_user);
do_action_ref_array($this->prefix . 'auth_success', array($new_user) ); do_action_ref_array($this->prefix . 'auth_success', array($new_user) );
@ -253,42 +330,79 @@ class SimpleLDAPLogin {
else else
{ {
do_action( 'wp_login_failed', $username ); do_action( 'wp_login_failed', $username );
return new WP_Error("{$this->prefix}login_error", __('<strong>Simple LDAP Login Error</strong>: LDAP credentials are correct and user creation is allowed but an error occurred creating the user in WordPress. Actual error: '.$new_user->get_error_message() )); return $this->ldap_auth_error("{$this->prefix}login_error", __('<strong>Simple LDAP Login Error</strong>: LDAP credentials are correct and user creation is allowed but an error occurred creating the user in WordPress. Actual error: '.$new_user->get_error_message() ));
} }
} else { } else {
return new WP_User($user->ID); return new WP_User($user->ID);
} }
} else { } else {
return new WP_Error("{$this->prefix}login_error", __('<strong>Simple LDAP Login Error</strong>: Your LDAP credentials are correct, but you are not in an authorized LDAP group.')); return $this->ldap_auth_error("{$this->prefix}login_error", __('<strong>Simple LDAP Login Error</strong>: Your LDAP credentials are correct, but you are not in an authorized LDAP group.'));
} }
} elseif ( str_true($this->get_setting('high_security')) ) { } elseif ( str_true($this->get_setting('high_security')) ) {
return new WP_Error('invalid_username', __('<strong>Simple LDAP Login</strong>: Simple LDAP Login could not authenticate your credentials. The security settings do not permit trying the WordPress user database as a fallback.')); return $this->ldap_auth_error('invalid_username', __('<strong>Simple LDAP Login</strong>: Simple LDAP Login could not authenticate your credentials. The security settings do not permit trying the WordPress user database as a fallback.'));
} }
do_action($this->prefix . 'auth_failure'); do_action($this->prefix . 'auth_failure');
return false; return false;
} }
function get_domain_username( $username ) {
// Format username with domain prefix, if login_domain is set
$login_domain = $this->get_setting('login_domain');
if ( ! empty($login_domain) ) {
return $login_domain . '\\' . $username;
}
return $username;
}
function ldap_auth( $username, $password, $directory ) { function ldap_auth( $username, $password, $directory ) {
$result = false; $result = false;
if ( $directory == "ad" ) { if ( $directory == "ad" ) {
$result = $this->adldap->authenticate( $username, $password ); $result = $this->adldap->authenticate( $this->get_domain_username($username), $password );
} elseif ( $directory == "ol" ) { } elseif ( $directory == "ol" ) {
$this->ldap = ldap_connect( join(' ', (array)$this->get_setting('domain_controllers')), (int)$this->get_setting('ldap_port') ); $this->ldap = ldap_connect( join(' ', (array)$this->get_setting('domain_controllers')), (int)$this->get_setting('ldap_port') );
ldap_set_option($this->ldap, LDAP_OPT_PROTOCOL_VERSION, (int)$this->get_setting('ldap_version')); ldap_set_option($this->ldap, LDAP_OPT_PROTOCOL_VERSION, (int)$this->get_setting('ldap_version'));
if ( str_true($this->get_setting('use_tls')) ) { if ( str_true($this->get_setting('use_tls')) ) {
ldap_start_tls($this->ldap); ldap_start_tls($this->ldap);
} }
$ldapbind = @ldap_bind($this->ldap, $this->get_setting('ol_login') .'=' . $username . ',' . $this->get_setting('base_dn'), $password); $dn = $this->get_setting('ol_login') .'=' . $username . ',' . $this->get_setting('base_dn');
if (str_true($this->get_setting('search_sub_ous'))) {
// search for user's DN in the base DN and below
$filter = $this->get_setting('ol_login') .'=' . $username;
$sr = @ldap_search($this->ldap, $this->get_setting('base_dn'), $filter, array('cn'));
if ($sr !== FALSE) {
$info = @ldap_get_entries($this->ldap, $sr);
if ($info !== FALSE && $info['count'] > 0) {
$dn = $info[0]['dn'];
}
}
}
$ldapbind = @ldap_bind($this->ldap, $dn, $password);
$this->dn = $dn;
$result = $ldapbind; $result = $ldapbind;
} }
return apply_filters($this->prefix . 'ldap_auth', $result); return apply_filters($this->prefix . 'ldap_auth', $result);
} }
/**
* Prevent modification of the error message by other authenticate hooks
* before it is shown to the user
*
* @param string $code
* @param string $message
* @return WP_Error
*/
function ldap_auth_error( $code, $message ) {
remove_all_filters( 'authenticate' );
return new WP_Error( $code, $message );
}
function user_has_groups( $username = false, $directory ) { function user_has_groups( $username = false, $directory ) {
$result = false; $result = false;
$groups = (array)$this->get_setting('groups'); $groups = (array)$this->get_setting('groups');
@ -307,14 +421,15 @@ class SimpleLDAPLogin {
} elseif ( $directory == "ol" ) { } elseif ( $directory == "ol" ) {
if( $this->ldap === false ) return false; if( $this->ldap === false ) return false;
$result = ldap_search($this->ldap, $this->get_setting('base_dn'), '(' . $this->get_setting('ol_login') . '=' . $username . ')', array('cn')); $group_base_dn = $this->get_setting('group_base_dn') !== false ? $this->get_setting('group_base_dn') : $this->get_setting('base_dn');
$result = ldap_search($this->ldap, $group_base_dn, '(|(&(objectClass=groupOfUniqueNames)(uniquemember=' . $this->dn . '))(&(objectClass=groupOfNames)(member=' . $this->dn . '))(' . $this->get_setting('group_uid') . '=' . $username . '))', array($this->get_setting('ol_group')));
$ldapgroups = ldap_get_entries($this->ldap, $result); $ldapgroups = ldap_get_entries($this->ldap, $result);
// Ok, we should have the user, all the info, including which groups he is a member of. // Ok, we should have the user, all the info, including which groups he is a member of.
// Let's make sure he's in the right group before proceeding. // Let's make sure he's in the right group before proceeding.
$user_groups = array(); $user_groups = array();
for ( $i = 0; $i < $ldapgroups['count']; $i++) { for ( $i = 0; $i < $ldapgroups['count']; $i++) {
$user_groups[] .= $ldapgroups[$i]['cn'][0]; $user_groups[] = $ldapgroups[$i][$this->get_setting('ol_group')][0];
} }
$result = (bool)(count( array_intersect($user_groups, $groups) ) > 0); $result = (bool)(count( array_intersect($user_groups, $groups) ) > 0);
@ -332,6 +447,7 @@ class SimpleLDAPLogin {
'display_name' => '', 'display_name' => '',
'first_name' => '', 'first_name' => '',
'last_name' => '', 'last_name' => '',
'user_url' => '',
'role' => $this->get_setting('role') 'role' => $this->get_setting('role')
); );
@ -341,7 +457,15 @@ class SimpleLDAPLogin {
} elseif ( $directory == "ol" ) { } elseif ( $directory == "ol" ) {
if ( $this->ldap == null ) {return false;} if ( $this->ldap == null ) {return false;}
$result = ldap_search($this->ldap, $this->get_setting('base_dn'), '(' . $this->get_setting('ol_login') . '=' . $username . ')', array($this->get_setting('ol_login'), 'sn', 'givenname', 'mail')); $attributes = array(
$this->get_setting('ol_login'),
$this->get_setting('user_last_name_attribute'),
$this->get_setting('user_first_name_attribute'),
$this->get_setting('user_email_attribute'),
$this->get_setting('user_url_attribute')
);
$result = ldap_search($this->ldap, $this->get_setting('base_dn'), '(' . $this->get_setting('ol_login') . '=' . $username . ')', $attributes);
$userinfo = ldap_get_entries($this->ldap, $result); $userinfo = ldap_get_entries($this->ldap, $result);
if ($userinfo['count'] == 1) { if ($userinfo['count'] == 1) {
@ -350,15 +474,65 @@ class SimpleLDAPLogin {
} else return false; } else return false;
if( is_array($userinfo) ) { if( is_array($userinfo) ) {
$user_data['user_nicename'] = $userinfo['givenname'][0] . ' ' . $userinfo['sn'][0]; $user_data['user_nicename'] = strtolower($userinfo[$this->get_setting('user_first_name_attribute')][0]) . '-' . strtolower($userinfo[$this->get_setting('user_last_name_attribute')][0]);
$user_data['user_email'] = $userinfo['mail'][0]; $user_data['user_email'] = $userinfo[$this->get_setting('user_email_attribute')][0];
$user_data['display_name'] = $user_data['user_nicename']; $user_data['display_name'] = $userinfo[$this->get_setting('user_first_name_attribute')][0] . ' ' . $userinfo[$this->get_setting('user_last_name_attribute')][0];
$user_data['first_name'] = $userinfo['givenname'][0]; $user_data['first_name'] = $userinfo[$this->get_setting('user_first_name_attribute')][0];
$user_data['last_name'] = $userinfo['sn'][0]; $user_data['last_name'] = $userinfo[$this->get_setting('user_last_name_attribute')][0];
$user_data['user_url'] = $userinfo[$this->get_setting('user_url_attribute')][0];
} }
return apply_filters($this->prefix . 'user_data', $user_data); return apply_filters($this->prefix . 'user_data', $user_data);
} }
function get_user_meta_data( $username, $directory ) {
if ( $directory == "ad" ) {
// TODO: get user meta data for ad
return false;
} elseif ( $directory == "ol" ) {
if ( $this->ldap == null ) {return false;}
$attributes = array();
foreach( $this->get_setting('user_meta_data') as $attr ) {
$attributes[] = $attr[0];
}
$result = ldap_search($this->ldap, $this->get_setting('base_dn'), '(' . $this->get_setting('ol_login') . '=' . $username . ')', $attributes);
$userinfo = ldap_get_entries($this->ldap, $result);
if ($userinfo['count'] == 1) {
$userinfo = $userinfo[0];
}
} else return false;
$user_meta_data = array();
foreach( $this->get_setting('user_meta_data') as $attr ) {
$user_meta_data[$attr[1]] = $userinfo[$attr[0]][0];
}
return apply_filters($this->prefix . 'user_meta_data', $user_meta_data);
}
/**
* Returns whether this plugin is currently network activated
*/
function is_network_version() {
if ( $this->network_version !== null) {
return $this->network_version;
}
if ( ! function_exists( 'is_plugin_active_for_network' ) ) {
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
}
if ( is_plugin_active_for_network( plugin_basename(__FILE__) ) ) {
$this->network_version = true;
}
else {
$this->network_version = false;
}
return $this->network_version;
}
} }
if ( ! function_exists('str_true') ) { if ( ! function_exists('str_true') ) {

View file

@ -1,220 +0,0 @@
# Plugin Name #
**Contributors:** clifgriffin
**Donate link:** http://cgd.io
**Tags:** LDAP, authentication, login, active directory, adLDAP
**Requires at least:** 3.4
**Tested up to:** 3.6
**Stable tag:** 1.5.5
**License:** GPLv2 or later
Integrating WordPress with LDAP shouldn't be difficult. Now it isn't. Simple LDAP Login provides all of the features, none of the hassles.
## Description ##
Having a single login for every service is a must in large organizations. This plugin allows you to integrate WordPress with LDAP quickly and easily. Like, really really easy.
**Contributing**
The easiest way to contribute to this plugin is to submit a GitHub pull request. Here's the repo:
https://github.com/clifgriffin/simple-ldap-login
**NEW VERSION -- 1.5**
Just when you thought this project was dead, it sprang to life. I have spent some time completely rewriting Simple LDAP Login from the ground up. Proceed with caution as it's possible I have broken something in the process, but I'm reasonably certain it's fundamentally stable.
**If you have any problems with 1.5, please let me know:** clifgriffin@gmail.com
**Support**
If you need support, I recommend you leave a comment on the appropriate post on my blog:
http://clifgriffin.com/2009/05/13/simple-ldap-login-13-for-wordpress/
**Special Requests**
**If you need a customization or change specific to your install, I am available for hire. Shoot me an e-mail:** clifgriffin[at]gmail.com
### Features ###
* Supports Active Directory and OpenLDAP (and other directory systems which comply to the LDAP standard, such as OpenDS)
* Supports TLS
* Uses up-to-date methods for WordPress authentication routines.
* Authenticates existing WordPress usernames against LDAP.
* Can be configured to automatically create WordPress users for valid LDAP logins.
* You can restrict logins based on one or more LDAP groups.
* Intuitive control panel.
### Architecture ###
Simple LDAP Login adds an authentication filter to WordPress that authentication requests must pass. In doing so, it makes several decisions.
* Can the provided credentials be authenticated against LDAP?
* * If so, is the LDAP user a member of the required LDAP groups (if any)?
* * * Does a matching WordPress user exist?
* * * * If so, log the user in.
* * * * If not, is user creation enabled?
* * * * * Create the user and log them in.
This is high level overview. This should answer the philosophical questions about how the plugin works. If the plugin is unable to authenticate the user, it should pass it down the chain to WordPress. (Unless LDAP Exclusive is turned on, in which case it won't.)
## Upgrade Notice ##
I have spent some time completely rewriting Simple LDAP Login from the ground up. Proceed with caution as it's possible I have broken something in the process, but I'm reasonably certain it's fundamentally stable.
**If you have any problems with 1.5, please let me know:** clifgriffin@gmail.com
## Changelog ##
**Version 1.5.5**
* Fix syntax error.
* Dont sanitize user info.
**Version 1.5.4**
* Local admins will always fall back to local WP password.
* Fixes bug where new users do not have name or other information from LDAP directory
**Version 1.5.3**
* Fixing apparent security problem with blank passwords. (!)
* Fixing typo in filter name (did not affect any functionality)
* Local admin exception coming soon, as well as more bug fixes.
* Possible fix for login error upon arriving at login page when LDAP exclusive enabled.
**Version 1.5.2**
* Fixed bug with groups setting.
* Removed delete_option references in upgrade code to allow for easier rollbacks (sorry about that!)
* Fixed a few bugs in the user creation code.
* Fixed bug with storing default user role.
**Version 1.5.1**
* Fixed a bug where the domain controllers are passed as a string.
**Version 1.5**
* Complete rewritten from the ground up.
* It's Object Oriented, DRY and Singleton.
* The options have been overhauled to make configuration much easier. Focuses on individual features rather than "modes" that encapsulate several behaviors.
* Admin pages now use WordPress admin styles and behaviors.
* Tested with Active Directory. I recommend OpenLDAP users test carefully before implementing in their production environments.
* Added global on off switch so you can easily disable LDAP authentication without deactivating.
**Version 1.4.0.5.1**
* I broke it. Sorry guys! :(
* Downgraded adLDAP as some referenced functions no longer exist.
**Version 1.4.0.5**
* Updated adLDAP to version 4.x
* Fixed error in OpenLDAP group membership check
* As always TEST this first. Don't assume it works...I don't have a testing environment to ensure it will work correctly.
**Version 1.4.0.4**
* Fixes nickname bug accidentally put back in in last version. (My bad!)
**Version 1.4.0.3**
* Reverts bug introduced in 1.4.0.2
* If you installed 1.4.0.2 and use OpenLDAP, please update as soon as possible and verify users cannot login with incorrect passwords (and vice versa).
**Version 1.4.0.2 - Patches submitted by Jonas Genannt and Ilya Kozlov**
* Updates adLDAP to 3.3.2
* Fixes issue with users in recursive OUs not being found.
* Fixes issues with different Base DN formats.
*** NOTE:** Please be catious in updating. As I don't have an OpenLDAP install, I am unable to independently confirm these fix the problems. If you have issues, revert to 1.4.0.1 and e-mail me: clifgriffin[at]gmail.com. Likewise, If you can confirm these changes are effective, also let me know. :)
**Version 1.4.0.1**
* Fix for e-mail exists issue with WP 3.0+ for LDAP installations that don't populate the e-mail address attribute.
* Shows actual error message from WordPress upon failure.
**Version 1.4**
* First update in about a year. Thanks for your patience.
* Completely rewritten to support changes in WordPress 2.8+. Now fully supports WordPress 3.0.
* Much more manageable and efficient code structure. Less code repetition.
* Includes TLS support.
* Allows OpenLDAP users to specify an alternate LDAP attribute to use for logins for those not using UID.
**Version 1.3.0.3**
* Test form now implements wp_authenticate and uses the same routines as the actual login. This also means account creation and group membership are tested.
* Implemented stripslashes() to correct issue with some special characters such as a single quote and backslash.
* WordPress account "admin" is now allowed to login using local password even when security mode is set to high. For safety.
* Made some minor wording changes to the admin panel.
**Version 1.3.0.2.1**
* Fixed case sensitivity issue that could result in multiple accounts. There may be lingering case insensitivity issues due to the get_userdatabylogin function being case-sensitive. We'll figure this out in due time.
* Sorry for posting two updates on the same day!
**Version 1.3.0.2**
* Fixes several tickets including role assignment, case sensitivity, and potential compatibility issues with other themes/plugins.
* Added security mode setting to allow security to be tightened.
* Changed auto created accounts to use a random password rather than the LDAP password given.
* Fixed error with the way announcements are displayed in the admin panel.
* More code clean up.
**Version 1.3.0.1**
* Never officially released.
* Contained code cleanup and some attempted fixes.
**Version 1.3 Beta**
* Support for both Active Directory and OpenLDAP.
* The ability to create WordPress users automatically upon login based on LDAP group membership OR by LDAP authentication alone.
* The ability to test domain settings straight from admin panel.
* Announcements pane that allows me to update you with fixes, cautions, new beta versions, or other important information.
**Version 1.2.0.1**
* Changed required user level for admin page to 10, Administrators only.
**Version 1.2**
* Implemented multiple domain controllers.
* Changed field sizes on admin page to be more user friendly.
**Version 1.1**
* Moved settings to administration pages under settings.
* Upgraded to latest version of adLDAP 2.1.
* Got rid of credentials. (They are not neccessary for the authenticate function in adLDAP!)
* Plugin is now upgrade proof. Settings are stored using WordPress's setting functions.
**Version 1.0**
* Original release.
## Installation ##
1. Use the WordPress plugin directory to install the plugin or upload the directory `simple-ldap-login` to the `/wp-content/plugins/` directory.
1. Activate the plugin through the 'Plugins' menu in WordPress
1. Update the settings to those that best match your environment by going to Settings -> Simple LDAP Login
1. If you don't get the settings right the first time, don't fret! Just use your WordPress credentials. They should always work
1. Once you have the settings correct, you can toggle LDAP Exclusive mode (if you like).
1. To make your life easier, consider using two different browsers (e.g., Chrome and Firefox) to do testing. Change settings in one. Test in the other. This will prevent any chance of being locked out.
## Frequently Asked Questions ##
### Other than WordPress, what does my system require? ###
Your install of PHP must be configured/compiled with LDAP support.
### How do I know what the correct settings are? ###
I have tried to make the settings as self-explanatory as possible. If you are struggling figuring them out, you may need to speak with your LDAP administrator. I realize this is an obnoxious response, but there is no good, fool proof way to help you discover these settings. A good place to start, if you're feeling daring, might be to use ADSIEdit for Windows and Active Directory, or GQ for Linux and OpenLDAP.
### It's still not working, what other things can I try? ###
If you are confident your settings are correct and it still does not work, it may be time to check for port or firewall issues. If your LDAP server is running on a non-standard port or an obsolete version of the LDAP protocol you are going to have issues. Port 389 is the port this plugin, and nearly every other LDAP enabled software expects. They are also expecting protocol version 3. If you are using an old version of LDAP or running a non-standard port you may need to modify the code that the plugin runs or update your LDAP installation.
Unfortunately I can't be relied upon to assist with these types of requests. I chose not to support these scenarios because they are infrequent and because they confuse everyone else.
### It's still not working! How can I get help? ###
**The easiest way to get help is to post a comment on my blog:** http://clifgriffin.com/simple-ldap-login/. I'll do my best to get you up and running!
## Screenshots ##
1. Easy to use admin panel.
2. Advanced options for power users.

View file

@ -3,8 +3,8 @@ Contributors: clifgriffin
Donate link: http://cgd.io Donate link: http://cgd.io
Tags: LDAP, authentication, login, active directory, adLDAP Tags: LDAP, authentication, login, active directory, adLDAP
Requires at least: 3.4 Requires at least: 3.4
Tested up to: 3.6 Tested up to: 4.5.0
Stable tag: 1.5.5 Stable tag: 1.6.0
License: GPLv2 or later License: GPLv2 or later
Integrating WordPress with LDAP shouldn't be difficult. Now it isn't. Simple LDAP Login provides all of the features, none of the hassles. Integrating WordPress with LDAP shouldn't be difficult. Now it isn't. Simple LDAP Login provides all of the features, none of the hassles.
@ -13,19 +13,15 @@ Integrating WordPress with LDAP shouldn't be difficult. Now it isn't. Simple LDA
Having a single login for every service is a must in large organizations. This plugin allows you to integrate WordPress with LDAP quickly and easily. Like, really really easy. Having a single login for every service is a must in large organizations. This plugin allows you to integrate WordPress with LDAP quickly and easily. Like, really really easy.
**Contributing** **Contributing**
This is a community project now. Most development is done by users like you who find bugs and fix them, or find new ways to make the plugin more powerful for everyone.
The easiest way to contribute to this plugin is to submit a GitHub pull request. Here's the repo: The easiest way to contribute to this plugin is to submit a GitHub pull request. Here's the repo:
https://github.com/clifgriffin/simple-ldap-login https://github.com/clifgriffin/simple-ldap-login
**NEW VERSION -- 1.5**
Just when you thought this project was dead, it sprang to life. I have spent some time completely rewriting Simple LDAP Login from the ground up. Proceed with caution as it's possible I have broken something in the process, but I'm reasonably certain it's fundamentally stable.
If you have any problems with 1.5, please let me know: clifgriffin@gmail.com
**Support** **Support**
If you need support, I recommend you leave a comment on the appropriate post on my blog: If you need support, file an issue here:
http://clifgriffin.com/2009/05/13/simple-ldap-login-13-for-wordpress/ https://github.com/clifgriffin/simple-ldap-login/issues
**Special Requests** **Special Requests**
@ -53,12 +49,14 @@ Simple LDAP Login adds an authentication filter to WordPress that authentication
This is high level overview. This should answer the philosophical questions about how the plugin works. If the plugin is unable to authenticate the user, it should pass it down the chain to WordPress. (Unless LDAP Exclusive is turned on, in which case it won't.) This is high level overview. This should answer the philosophical questions about how the plugin works. If the plugin is unable to authenticate the user, it should pass it down the chain to WordPress. (Unless LDAP Exclusive is turned on, in which case it won't.)
== Upgrade Notice ==
I have spent some time completely rewriting Simple LDAP Login from the ground up. Proceed with caution as it's possible I have broken something in the process, but I'm reasonably certain it's fundamentally stable.
If you have any problems with 1.5, please let me know: clifgriffin@gmail.com
== Changelog == == Changelog ==
**Version 1.6.0**
* New filter sll_remove_default_authentication_hook lets you override local password fallback.
* Lots of new features from various pull requests from contributing users. Most of these focus on new settings for edge cases, and some general improvements.
* If we did our jobs right, nothing will break. But if it does, rolling back to 1.5.5 is the best place to start.
**Version 1.5.5** **Version 1.5.5**
* Fix syntax error. * Fix syntax error.

Binary file not shown.