diff --git a/install-update-mattermost-oidc-plugin.sh b/install-update-mattermost-oidc-plugin.sh index 7db3758..7fdd9e3 100755 --- a/install-update-mattermost-oidc-plugin.sh +++ b/install-update-mattermost-oidc-plugin.sh @@ -901,6 +901,31 @@ else fatal_with_plugin_rollback "Plugin was installed but could not be enabled. ${_enable_error}" fi +if [[ "$INSTALLATION_MODE" = "initial-installation" ]]; then + echononl "Enable OIDC authentication for initial installation.." + _oidc_config_patch="${LOCK_DIR}/mattermost-oidc-enable.json" + + cat > "$_oidc_config_patch" < "$log_file" 2>&1 ; then + echo_ok + else + _config_patch_error="$(cat "$log_file")" + echo_failed + fatal_with_plugin_rollback "Plugin was installed and enabled, but OIDC authentication could not be enabled. ${_config_patch_error}" + fi +fi + # ---------- # Verify installation @@ -926,7 +951,6 @@ plugin_is_enabled _plugin_enabled_rc=$? if [[ $_plugin_enabled_rc -eq 0 ]]; then echo_ok - MM_ROLLBACK_REQUIRED=false elif [[ $_plugin_enabled_rc -eq 2 ]]; then echo_failed fatal_with_plugin_rollback "Plugin '${MM_OIDC_PLUGIN_ID}' is installed but not enabled." @@ -935,6 +959,35 @@ else fatal_with_plugin_rollback "Could not determine whether Mattermost OIDC Plugin '${MM_OIDC_PLUGIN_ID}' is enabled." fi +if [[ "$INSTALLATION_MODE" = "initial-installation" ]]; then + echononl "Verify OIDC authentication is enabled.." + _oidc_enabled="$("$MMCTL" --local config get PluginSettings.Plugins 2> "$log_file" | python3 -c ' +import json, sys +try: + data = json.load(sys.stdin) +except Exception: + raise SystemExit(1) + +value = data.get("mattermost-oidc", {}).get("enable") +if value is True: + print("true") +elif value is False: + print("false") +else: + print("unknown") +' 2>> "$log_file")" + _oidc_config_rc=$? + + if [[ $_oidc_config_rc -eq 0 && "$_oidc_enabled" = "true" ]]; then + echo_ok + else + echo_failed + fatal_with_plugin_rollback "OIDC authentication is not enabled after initial plugin installation." + fi +fi + +MM_ROLLBACK_REQUIRED=false + if [[ -n "$MM_ROLLBACK_BUNDLE" && -f "$MM_ROLLBACK_BUNDLE" ]]; then echononl "Remove temporary rollback bundle.."