From b7b73bbf895d4fad85b5bb3898f58d99026c1551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josu=C3=A9=20Tille?= Date: Wed, 13 Dec 2023 10:38:10 +0100 Subject: [PATCH] Add jwt secret because gitea edit config if not present --- conf/app.ini | 9 ++++++--- scripts/install | 2 ++ scripts/upgrade | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index 0cd9439..9136e24 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -2,7 +2,7 @@ APP_NAME = Gitea RUN_USER = __APP__ RUN_MODE = prod -WORK_PATH =__INSTALL_DIR__ +WORK_PATH = __INSTALL_DIR__ [actions] ENABLED = false @@ -78,8 +78,8 @@ logger.access.MODE = logger.router.MODE = router logger.xorm.MODE = xorm -REDIRECT_MACARON_LOG= true -MACARON = file +REDIRECT_MACARON_LOG = true +MACARON = file [log.file] FILE_NAME = gitea.log @@ -101,3 +101,6 @@ SECRET_KEY = __SECRET_KEY__ REVERSE_PROXY_AUTHENTICATION_USER = REMOTE-USER REVERSE_PROXY_TRUSTED_PROXIES = 127.0.0.0/8,::1/128 INTERNAL_TOKEN = __INTERNAL_TOKEN__ + +[oauth2] +JWT_SECRET = __JWT_SECRET__ diff --git a/scripts/install b/scripts/install index f48b969..b5954c5 100644 --- a/scripts/install +++ b/scripts/install @@ -45,10 +45,12 @@ ynh_script_progression --message="Configuring application, step 1/2..." internal_token=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret INTERNAL_TOKEN) secret_key=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret SECRET_KEY) lfs_jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET) +jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET) ynh_app_setting_set --app="$app" --key=internal_token --value="$internal_token" ynh_app_setting_set --app="$app" --key=secret_key --value="$secret_key" ynh_app_setting_set --app="$app" --key=lfs_jwt_secret --value="$lfs_jwt_secret" +ynh_app_setting_set --app "$app" --key jwt_secret --value="$jwt_secret" ynh_add_config --template='app.ini' --destination="$install_dir/custom/conf/app.ini" diff --git a/scripts/upgrade b/scripts/upgrade index f6bb022..dd8a354 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -81,6 +81,11 @@ if [[ -z "${lfs_jwt_secret:-}" ]]; then ynh_app_setting_set --app "$app" --key lfs_jwt_secret --value="$lfs_jwt_secret" fi +if [[ -z "${jwt_secret:-}" ]]; then + jwt_secret=$(ynh_exec_as "$app" "$install_dir/gitea" generate secret JWT_SECRET) + ynh_app_setting_set --app "$app" --key jwt_secret --value="$jwt_secret" +fi + #================================================= # UPDATE A CONFIG FILE #=================================================