1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/calibreweb_ynh.git synced 2024-09-03 18:16:20 +02:00

New version & New LDAP & script cleaning

New App version with better LDAP
Script cleaning : --time and new package check control. Add sleep to
deal with test too quick for service to start
New LDAP integration : import on both request and login
This commit is contained in:
Krakinou 2020-05-01 14:08:08 +02:00
parent 2421277c81
commit f585b5e8a5
11 changed files with 107 additions and 103 deletions

View file

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>calibre_ynh</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>

View file

@ -1,3 +1,3 @@
SOURCE_URL=https://github.com/janeczku/calibre-web/archive/06fde4fcd00fcd067a58939e1d9eabee62a86913.zip SOURCE_URL=https://github.com/janeczku/calibre-web/archive/0297823bda98de2dcfecf7fb5d3a612938f88ea3.zip
SOURCE_SUM=81aa6e95837569e9ebdb6da73529d8cbb33dfde65fd07a384ae6cc79dcfe5afa SOURCE_SUM=776fbee7906217f70ea1f84e0ce467a2a793750b4890f460add96e22e1bc253e
SOURCE_FORMAT=zip SOURCE_FORMAT=zip

View file

@ -1,19 +1,10 @@
#!/bin/bash #!/bin/bash
get_db() { PKG_DEPENDENCIES="sqlite3 python-dev libldap2-dev libsasl2-dev libssl-dev python3-pip imagemagick"
# $1 = nom de la table #PKG_DEPENDENCIES="sqlite3 python3-pip imagemagick"
# cette ligne de malade : DOSSIER_MEDIA=/home/yunohost.multimedia
# 1/ Recupere le schém de la table user LOG_FILE=/var/log/$app/$app.log
# 2/ En extrait les noms de champs (en prenant le premier mot après la tabulation) ACCESS_LOG_FILE=/var/log/$app/$app-access.log
# 3/ en supprime les clé UNIQUE, PRIMARY et CHECK dont on ne veut pas
# 4/ remplace la liste avec retour à la ligne par une liste séparé par des virgules
# 5/ Enlève la dernière virgule
sqlite3 $final_path/app.db ".schema $1" | awk '/\t/ {print $1}' | grep -v -e "UNIQUE" -e "PRIMARY" -e "CHECK" -e "FOREIGN" | awk '{printf "%s, ", $0}' | head -c -2
}
version_gt() {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
}
#================================================= #=================================================

View file

@ -1,6 +0,0 @@
#!/bin/bash
PKG_DEPENDENCIES="sqlite3 python-dev libldap2-dev libsasl2-dev libssl-dev python3-pip imagemagick"
DOSSIER_MEDIA=/home/yunohost.multimedia
LOG_FILE=/var/log/$app/$app.log
ACCESS_LOG_FILE=/var/log/$app/$app-access.log

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -19,9 +19,9 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading installation settings..." --time --weight=1 ynh_script_progression --message="Loading installation settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME
app=$YNH_APP_INSTANCE_NAME
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
path_url=$(ynh_app_setting_get $app path) path_url=$(ynh_app_setting_get $app path)
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
@ -32,6 +32,7 @@ calibre_dir=$(sqlite3 $final_path/app.db "SELECT config_calibre_dir FROM setting
calibre_dir=${calibre_dir%/} calibre_dir=${calibre_dir%/}
ynh_app_setting_set $app calibre_dir $calibre_dir ynh_app_setting_set $app calibre_dir $calibre_dir
source ../settings/scripts/_common.sh
#================================================= #=================================================
@ -39,7 +40,7 @@ ynh_app_setting_set $app calibre_dir $calibre_dir
#================================================= #=================================================
# STOP SYSTEMD SERVICE # STOP SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Stopping a systemd service..." --time --weight=1 ynh_script_progression --message="Stopping a systemd service..." --weight=1
ynh_systemd_action --service_name=$app --action="stop" ynh_systemd_action --service_name=$app --action="stop"
@ -48,7 +49,7 @@ ynh_systemd_action --service_name=$app --action="stop"
# BACKUP THE APP MAIN DIR # BACKUP THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Backing up the main app directory..." --time --weight=1 ynh_script_progression --message="Backing up the main app directory..." --weight=1
#This will backup the app.db file at the same time #This will backup the app.db file at the same time
ynh_backup --src_path="$final_path" ynh_backup --src_path="$final_path"
@ -56,7 +57,7 @@ ynh_backup --src_path="$final_path"
# BACKUP THE NGINX CONFIGURATION # BACKUP THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Backing up nginx web server configuration..." --time --weight=1 ynh_script_progression --message="Backing up nginx web server configuration..." --weight=1
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
@ -66,13 +67,13 @@ ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
# BACKUP LOGROTATE # BACKUP LOGROTATE
#================================================= #=================================================
ynh_script_progression --message="Backing up logrotate configuration..." --time --weight=1 ynh_script_progression --message="Backing up logrotate configuration..." --weight=1
ynh_backup --src_path="/etc/logrotate.d/$app" ynh_backup --src_path="/etc/logrotate.d/$app"
#================================================= #=================================================
# BACKUP SYSTEMD # BACKUP SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Backing up systemd configuration..." --time --weight=1 ynh_script_progression --message="Backing up systemd configuration..." --weight=1
ynh_backup --src_path="/etc/systemd/system/$app.service" ynh_backup --src_path="/etc/systemd/system/$app.service"
@ -87,12 +88,13 @@ ynh_backup --src_path="$calibre_dir" --is_big
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=5
ynh_systemd_action --service_name=$app --action="start" --log_path="/var/log/$app/$app.log" ynh_systemd_action --service_name=$app --action="start" -t 20
sleep 2s
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --time --last ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -26,6 +26,7 @@ ynh_script_progression --message="Loading installation settings..." --weight=1
# Needed for helper "ynh_add_nginx_config" # Needed for helper "ynh_add_nginx_config"
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get $app port)
source _common.sh
#================================================= #=================================================
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
@ -116,9 +117,10 @@ fi
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="start" -l "Starting Tornado server on :8083" -t 20 ynh_systemd_action --service_name=$app --action="start" -t 20
sleep 2s
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================

View file

@ -6,16 +6,8 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
# RETRIEVE ARGUMENTS FROM THE MANIFEST # RETRIEVE ARGUMENTS FROM THE MANIFEST
#================================================= #=================================================
@ -32,7 +24,19 @@ public_library=$7
if [ $is_public -eq 1 ]; then if [ $is_public -eq 1 ]; then
public_library=1 public_library=1
fi fi
source _settings.sh source _common.sh
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# MANAGE SCRIPT FAILURE
#=================================================
# Exit if an error occurs during the execution of the script
ynh_abort_if_errors
#================================================= #=================================================
@ -229,7 +233,8 @@ fi
#================================================= #=================================================
ynh_script_progression --message="Reload nginx and start $app..." --weight=5 ynh_script_progression --message="Reload nginx and start $app..." --weight=5
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
ynh_systemd_action -l "Starting Tornado server on :8083" -t 20 ynh_systemd_action --service_name=$app --action=start -t 20
sleep 2s
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT

View file

@ -6,7 +6,7 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -20,6 +20,8 @@ port=$(ynh_app_setting_get $app port)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
calibre_dir=$(ynh_app_setting_get $app calibre_dir) calibre_dir=$(ynh_app_setting_get $app calibre_dir)
source _common.sh
#================================================= #=================================================
# REMOVE SERVICE FROM ADMIN PANEL # REMOVE SERVICE FROM ADMIN PANEL
#================================================= #=================================================

View file

@ -6,7 +6,6 @@
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -19,7 +18,7 @@ ynh_abort_if_errors
#================================================= #=================================================
# LOAD SETTINGS # LOAD SETTINGS
#================================================= #=================================================
ynh_script_progression --message="Loading settings..." --time --weight=1 ynh_script_progression --message="Loading settings..." --weight=1
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get $app domain) domain=$(ynh_app_setting_get $app domain)
@ -28,12 +27,12 @@ final_path=$(ynh_app_setting_get $app final_path)
calibre_dir=$(ynh_app_setting_get $app calibre_dir) calibre_dir=$(ynh_app_setting_get $app calibre_dir)
is_public=$(ynh_app_setting_get $app is_public) is_public=$(ynh_app_setting_get $app is_public)
port=$(ynh_app_setting_get $app port) port=$(ynh_app_setting_get $app port)
source ../settings/scripts/_settings.sh source ../settings/scripts/_common.sh
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
#================================================= #=================================================
ynh_script_progression --message="Validating restoration parameters..." --time --weight=1 ynh_script_progression --message="Validating restoration parameters..." --weight=1
ynh_webpath_available $domain $path_url \ ynh_webpath_available $domain $path_url \
|| ynh_die "Path not available: ${domain}${path_url}" || ynh_die "Path not available: ${domain}${path_url}"
test ! -d $final_path \ test ! -d $final_path \
@ -44,7 +43,7 @@ test ! -d $final_path \
#================================================= #=================================================
# RESTORE THE NGINX CONFIGURATION # RESTORE THE NGINX CONFIGURATION
#================================================= #=================================================
ynh_script_progression --message="Restoring nginx configuration..." --time --weight=1 ynh_script_progression --message="Restoring nginx configuration..." --weight=1
ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file "/etc/nginx/conf.d/$domain.d/$app.conf"
#================================================= #=================================================
@ -59,7 +58,7 @@ ynh_app_setting_set $app port $port
# RECREATE THE DEDICATED USER # RECREATE THE DEDICATED USER
#================================================= #=================================================
ynh_script_progression --message="Recreating the dedicated system user..." --time --weight=1 ynh_script_progression --message="Recreating the dedicated system user..." --weight=1
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app ynh_system_user_create --username=$app
@ -67,7 +66,7 @@ ynh_system_user_create --username=$app
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================
ynh_script_progression --message="Restoring the app main directory..." --time --weight=1 ynh_script_progression --message="Restoring the app main directory..." --weight=1
ynh_restore_file --origin_path="$final_path" ynh_restore_file --origin_path="$final_path"
@ -85,7 +84,7 @@ chown -R $app: $final_path
#================================================= #=================================================
# Define and install dependencies # Define and install dependencies
ynh_script_progression --message="Reinstalling dependencies..." --time --weight=1 ynh_script_progression --message="Reinstalling dependencies..." --weight=15
ynh_install_app_dependencies $PKG_DEPENDENCIES ynh_install_app_dependencies $PKG_DEPENDENCIES
#pip package not required as already in app directory #pip package not required as already in app directory
#pip install --target $final_path/vendor -r $final_path/requirements.txt #pip install --target $final_path/vendor -r $final_path/requirements.txt
@ -93,7 +92,7 @@ ynh_install_app_dependencies $PKG_DEPENDENCIES
#================================================= #=================================================
# RESTORE SYSTEMD # RESTORE SYSTEMD
#================================================= #=================================================
ynh_script_progression --message="Restoring the systemd configuration..." --time --weight=1 ynh_script_progression --message="Restoring the systemd configuration..." --weight=1
ynh_restore_file --origin_path="/etc/systemd/system/$app.service" ynh_restore_file --origin_path="/etc/systemd/system/$app.service"
systemctl enable $app.service systemctl enable $app.service
@ -153,21 +152,22 @@ fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="start" -l "Starting Tornado server on :8083" -t 20 ynh_systemd_action --service_name=$app --action="start" -t 20
sleep 2s
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Restoration completed for $app" --time --last ynh_script_progression --message="Restoration completed for $app" --last
#================================================= #=================================================
# WARNING FOR READ ACCESS # WARNING FOR READ ACCESS
#================================================= #=================================================

View file

@ -1,12 +1,15 @@
#!/bin/bash #!/bin/bash
version_gt() {
test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1";
}
#================================================= #=================================================
# GENERIC START # GENERIC START
#================================================= #=================================================
# IMPORT GENERIC HELPERS # IMPORT GENERIC HELPERS
#================================================= #=================================================
source _common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#================================================= #=================================================
@ -23,7 +26,6 @@ is_public=$(ynh_app_setting_get $app is_public)
final_path=$(ynh_app_setting_get $app final_path) final_path=$(ynh_app_setting_get $app final_path)
language=$(ynh_app_setting_get $app language) language=$(ynh_app_setting_get $app language)
#Get settings from database in case it has been changed in the app and save it in settings so that it can be used back afterward #Get settings from database in case it has been changed in the app and save it in settings so that it can be used back afterward
calibre_dir=$(sqlite3 $final_path/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1") calibre_dir=$(sqlite3 $final_path/app.db "SELECT config_calibre_dir FROM settings WHERE ID=1")
calibre_dir=${calibre_dir%/} calibre_dir=${calibre_dir%/}
@ -32,7 +34,7 @@ ynh_app_setting_set $app calibre_dir $calibre_dir
upload=$(sqlite3 $final_path/app.db "SELECT config_uploading FROM settings WHERE ID=1") upload=$(sqlite3 $final_path/app.db "SELECT config_uploading FROM settings WHERE ID=1")
ynh_app_setting_set $app upload $upload ynh_app_setting_set $app upload $upload
source _settings.sh source _common.sh
#================================================= #=================================================
# CHECK VERSION # CHECK VERSION
@ -137,7 +139,7 @@ fi
#================================================= #=================================================
# Create a dedicated user (if not existing) # Create a dedicated user (if not existing)
ynh_script_progression --message="Making sure dedicated system user exists..." --time --weight=1 ynh_script_progression --message="Making sure dedicated system user exists..." --weight=1
ynh_system_user_create $app ynh_system_user_create $app
# Set permissions on app files (required to be able to update database) # Set permissions on app files (required to be able to update database)
@ -148,7 +150,7 @@ chown -R $app: $final_path
#================================================= #=================================================
#build multimedia directory #build multimedia directory
#================================================= #=================================================
ynh_script_progression --message="Create Multimedia dir..." --time --weight=1 ynh_script_progression --message="Create Multimedia dir..." --weight=1
#Create multimedia directory but we do not change the calibre_dir : It's the user to make this choice. #Create multimedia directory but we do not change the calibre_dir : It's the user to make this choice.
ynh_multimedia_build_main_dir ynh_multimedia_build_main_dir
ynh_multimedia_addaccess $app ynh_multimedia_addaccess $app
@ -156,7 +158,7 @@ ynh_multimedia_addaccess $app
#================================================= #=================================================
#Update database structure #Update database structure
#================================================= #=================================================
ynh_script_progression --message="Update database..." --time --weight=1 ynh_script_progression --message="Update database..." --weight=1
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script. ### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it. ### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
ynh_backup_if_checksum_is_different "$final_path/app.db" ynh_backup_if_checksum_is_different "$final_path/app.db"
@ -178,7 +180,7 @@ ynh_store_file_checksum "$final_path/app.db"
#================================================= #=================================================
# Use logrotate to manage app-specific logfile(s) # Use logrotate to manage app-specific logfile(s)
ynh_script_progression --message="Upgrading logrotate configuration..." --time --weight=1 ynh_script_progression --message="Upgrading logrotate configuration..." --weight=1
ynh_use_logrotate --non-append ynh_use_logrotate --non-append
@ -187,7 +189,7 @@ ynh_use_logrotate --non-append
#================================================= #=================================================
# Create a dedicated systemd config # Create a dedicated systemd config
ynh_script_progression --message="Upgrading systemd configuration..." --time --weight=1 ynh_script_progression --message="Upgrading systemd configuration..." --weight=1
ynh_add_systemd_config ynh_add_systemd_config
#================================================= #=================================================
@ -222,18 +224,19 @@ fi
#================================================= #=================================================
# RELOAD NGINX # RELOAD NGINX
#================================================= #=================================================
ynh_script_progression --message="Reloading nginx web server..." --time --weight=1 ynh_script_progression --message="Reloading nginx web server..." --weight=1
ynh_systemd_action --service_name=nginx --action=reload ynh_systemd_action --service_name=nginx --action=reload
#================================================= #=================================================
# START SYSTEMD SERVICE # START SYSTEMD SERVICE
#================================================= #=================================================
ynh_script_progression --message="Starting a systemd service..." --time --weight=1 ynh_script_progression --message="Starting a systemd service..." --weight=2
ynh_systemd_action --service_name=$app --action="start" -l "Starting Tornado server on :8083" -t 20 ynh_systemd_action --service_name=$app --action="start" -t 20
sleep 2s
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================
ynh_script_progression --message="Upgrade of $app completed" --time --last ynh_script_progression --message="Upgrade of $app completed" --last

View file

@ -1,30 +1,52 @@
--- a/cps/web.py 2020-04-18 11:48:34.000000000 +0200 --- a/cps/web.py 2020-05-01 13:54:41.755888435 +0200
+++ b/cps/web.py 2020-04-19 13:42:18.719536869 +0200 +++ b/cps/web.py" 2020-05-01 14:03:01.337768210 +0200
@@ -1206,6 +1206,13 @@ @@ -281,6 +281,10 @@
if not config.db_configured and request.endpoint not in (
'admin.basic_configuration', 'login') and '/static/' not in request.path:
return redirect(url_for('admin.basic_configuration'))
+#Début Modif Yunohost 1/4
+ if config.config_login_type == constants.LOGIN_LDAP and services.ldap:
+ import_ldap_users()
+#Fin Modif Yunohost 1/4
@app.route('/import_ldap_users')
@@ -313,7 +317,10 @@
log.warning("Could Not Parse LDAP User: %s", user)
continue
if ub.session.query(ub.User).filter(ub.User.nickname == user.lower()).first():
- log.warning("LDAP User: %s Already in Database", user)
+# Début Modif Yunohost 2/4
+# log.warning("LDAP User: %s Already in Database", user)
+ log.debug("LDAP User: %s Already in Database", user)
+#Fin Modif Yunohost 2/4
continue
user_data = services.ldap.get_object_details(user=user,
group=None,
@@ -1216,6 +1223,10 @@
if not config.db_configured: if not config.db_configured:
log.debug(u"Redirect to initial configuration") log.debug(u"Redirect to initial configuration")
return redirect(url_for('admin.basic_configuration')) return redirect(url_for('admin.basic_configuration'))
+#Début Modif Yunohost 3/4
+ if config.config_login_type == constants.LOGIN_LDAP and services.ldap: + if config.config_login_type == constants.LOGIN_LDAP and services.ldap:
+ import_ldap_users() + import_ldap_users()
+ auth_user = request.headers.get('X-Remote-User') +#Fin Modif Yunohost 3/4
+ if auth_user:
+ user = ub.session.query(ub.User).filter(func.lower(ub.User.nickname) == auth_user.strip().lower()).first()
+ log.info("Login of user %s", user.nickname)
+ login_user(user)
if current_user is not None and current_user.is_authenticated: if current_user is not None and current_user.is_authenticated:
return redirect(url_for('web.index')) return redirect(url_for('web.index'))
if config.config_login_type == constants.LOGIN_LDAP and not services.ldap: if config.config_login_type == constants.LOGIN_LDAP and not services.ldap:
@@ -1284,8 +1291,11 @@ @@ -1290,8 +1301,13 @@
logout_user()
if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3): if feature_support['oauth'] and (config.config_login_type == 2 or config.config_login_type == 3):
logout_oauth_user() logout_oauth_user()
- log.debug(u"User logged out") log.debug(u"User logged out")
- return redirect(url_for('web.login')) - return redirect(url_for('web.login'))
+ auth_user = request.headers.get('X-Remote-User') -
+ if auth_user: +#Début Modif Yunohost 4/4
+# return redirect(url_for('web.login'))
+ if config.config_login_type == constants.LOGIN_LDAP and services.ldap:
+ return redirect(request.host_url) + return redirect(request.host_url)
+ else: + else:
+ return redirect(url_for('web.login')) + return redirect(url_for('web.login'))
+#Fin Modif Yunohost 4/4
@web.route('/remote/login') @web.route('/remote/login')
@remote_login_required