From 1db72311d2d9810b2f6dc0f998ecf711b3ca3b44 Mon Sep 17 00:00:00 2001 From: Maniack Crudelis Date: Mon, 6 May 2019 12:52:47 +0200 Subject: [PATCH 1/2] Add helpers for sso config And especially restore the old documentation about those keys --- data/helpers.d/setting | 92 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/data/helpers.d/setting b/data/helpers.d/setting index 799e26554..b5bd8c235 100644 --- a/data/helpers.d/setting +++ b/data/helpers.d/setting @@ -59,6 +59,98 @@ ynh_app_setting_delete() { ynh_app_setting "delete" "$app" "$key" } +# Add skipped_uris urls into the config +# +# usage: ynh_add_skipped_uris [--appid=app] --url=url1,url2 [--regex] +# | arg: -a, --appid - the application id +# | arg: -u, --url - the urls to add to the sso for this app +# | arg: -r, --regex - Use the key 'skipped_regex' instead of 'skipped_uris' +# +# An URL set with 'skipped_uris' key will be totally ignored by the SSO, +# which means that the access will be public and the logged-in user information will not be passed to the app. +# +# Requires YunoHost version ?.?.? or higher. +ynh_add_skipped_uris() { + # Declare an array to define the options of this helper. + local legacy_args=aur + declare -Ar args_array=( [a]=appid= [u]=url= [r]=regex ) + local appid + local url + local regex + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + appid={appid:-$app} + regex={regex:-0} + + local key=skipped_uris + if [ $regex -eq 1 ]; then + key=skipped_regex + fi + + ynh_app_setting_set --app=$appid --key=$key --value="$url" +} + +# Add unprotected_uris urls into the config +# +# usage: ynh_add_unprotected_uris [--appid=app] --url=url1,url2 [--regex] +# | arg: -a, --appid - the application id +# | arg: -u, --url - the urls to add to the sso for this app +# | arg: -r, --regex - Use the key 'unprotected_regex' instead of 'unprotected_uris' +# +# An URL set with unprotected_uris key will be accessible publicly, but if an user is logged in, +# his information will be accessible (through HTTP headers) to the app. +# +# Requires YunoHost version ?.?.? or higher. +ynh_add_unprotected_uris() { + # Declare an array to define the options of this helper. + local legacy_args=aur + declare -Ar args_array=( [a]=appid= [u]=url= [r]=regex ) + local appid + local url + local regex + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + appid={appid:-$app} + regex={regex:-0} + + local key=unprotected_uris + if [ $regex -eq 1 ]; then + key=unprotected_regex + fi + + ynh_app_setting_set --app=$appid --key=$key --value="$url" +} + +# Add protected_uris urls into the config +# +# usage: ynh_add_protected_uris [--appid=app] --url=url1,url2 [--regex] +# | arg: -a, --appid - the application id +# | arg: -u, --url - the urls to add to the sso for this app +# | arg: -r, --regex - Use the key 'protected_regex' instead of 'protected_uris' +# +# An URL set with protected_uris will be blocked by the SSO and accessible only to authenticated and authorized users. +# +# Requires YunoHost version ?.?.? or higher. +ynh_add_protected_uris() { + # Declare an array to define the options of this helper. + local legacy_args=aur + declare -Ar args_array=( [a]=appid= [u]=url= [r]=regex ) + local appid + local url + local regex + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + appid={appid:-$app} + regex={regex:-0} + + local key=protected_uris + if [ $regex -eq 1 ]; then + key=protected_regex + fi + + ynh_app_setting_set --app=$appid --key=$key --value="$url" +} + # Small "hard-coded" interface to avoid calling "yunohost app" directly each # time dealing with a setting is needed (which may be so slow on ARM boards) # From a61f956a0392a7312e6fb7453970cc890d474f48 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 21 May 2019 15:07:13 +0200 Subject: [PATCH 2/2] Set minimum version for these new helpers --- data/helpers.d/setting | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/helpers.d/setting b/data/helpers.d/setting index b5bd8c235..5ee737842 100644 --- a/data/helpers.d/setting +++ b/data/helpers.d/setting @@ -69,7 +69,7 @@ ynh_app_setting_delete() { # An URL set with 'skipped_uris' key will be totally ignored by the SSO, # which means that the access will be public and the logged-in user information will not be passed to the app. # -# Requires YunoHost version ?.?.? or higher. +# Requires YunoHost version 3.6.0 or higher. ynh_add_skipped_uris() { # Declare an array to define the options of this helper. local legacy_args=aur @@ -100,7 +100,7 @@ ynh_add_skipped_uris() { # An URL set with unprotected_uris key will be accessible publicly, but if an user is logged in, # his information will be accessible (through HTTP headers) to the app. # -# Requires YunoHost version ?.?.? or higher. +# Requires YunoHost version 3.6.0 or higher. ynh_add_unprotected_uris() { # Declare an array to define the options of this helper. local legacy_args=aur @@ -130,7 +130,7 @@ ynh_add_unprotected_uris() { # # An URL set with protected_uris will be blocked by the SSO and accessible only to authenticated and authorized users. # -# Requires YunoHost version ?.?.? or higher. +# Requires YunoHost version 3.6.0 or higher. ynh_add_protected_uris() { # Declare an array to define the options of this helper. local legacy_args=aur