Enable OIDC authentication on initial plugin install

This commit is contained in:
2026-09-29 11:41:55 +02:00
parent 8ea53f6372
commit b5dffac07d
+54 -1
View File
@@ -901,6 +901,31 @@ else
fatal_with_plugin_rollback "Plugin was installed but could not be enabled. ${_enable_error}" fatal_with_plugin_rollback "Plugin was installed but could not be enabled. ${_enable_error}"
fi 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" <<EOF
{
"PluginSettings": {
"Plugins": {
"${MM_OIDC_PLUGIN_ID}": {
"enable": true
}
}
}
}
EOF
if "$MMCTL" --local config patch "$_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 # Verify installation
@@ -926,7 +951,6 @@ plugin_is_enabled
_plugin_enabled_rc=$? _plugin_enabled_rc=$?
if [[ $_plugin_enabled_rc -eq 0 ]]; then if [[ $_plugin_enabled_rc -eq 0 ]]; then
echo_ok echo_ok
MM_ROLLBACK_REQUIRED=false
elif [[ $_plugin_enabled_rc -eq 2 ]]; then elif [[ $_plugin_enabled_rc -eq 2 ]]; then
echo_failed echo_failed
fatal_with_plugin_rollback "Plugin '${MM_OIDC_PLUGIN_ID}' is installed but not enabled." 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." fatal_with_plugin_rollback "Could not determine whether Mattermost OIDC Plugin '${MM_OIDC_PLUGIN_ID}' is enabled."
fi 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 if [[ -n "$MM_ROLLBACK_BUNDLE" && -f "$MM_ROLLBACK_BUNDLE" ]]; then
echononl "Remove temporary rollback bundle.." echononl "Remove temporary rollback bundle.."