mirror of
https://github.com/netbirdio/netbird.git
synced 2026-04-16 07:16:38 +00:00
[misc] Remove default zitadel admin user in deployment script (#4482)
* Delete default zitadel-admin user during initialization Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com> * Refactor Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com> --------- Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
This commit is contained in:
@@ -328,6 +328,45 @@ delete_auto_service_user() {
|
||||
echo "$PARSED_RESPONSE"
|
||||
}
|
||||
|
||||
delete_default_zitadel_admin() {
|
||||
INSTANCE_URL=$1
|
||||
PAT=$2
|
||||
|
||||
# Search for the default zitadel-admin user
|
||||
RESPONSE=$(
|
||||
curl -sS -X POST "$INSTANCE_URL/management/v1/users/_search" \
|
||||
-H "Authorization: Bearer $PAT" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
"queries": [
|
||||
{
|
||||
"userNameQuery": {
|
||||
"userName": "zitadel-admin@",
|
||||
"method": "TEXT_QUERY_METHOD_STARTS_WITH"
|
||||
}
|
||||
}
|
||||
]
|
||||
}'
|
||||
)
|
||||
|
||||
DEFAULT_ADMIN_ID=$(echo "$RESPONSE" | jq -r '.result[0].id // empty')
|
||||
|
||||
if [ -n "$DEFAULT_ADMIN_ID" ] && [ "$DEFAULT_ADMIN_ID" != "null" ]; then
|
||||
echo "Found default zitadel-admin user with ID: $DEFAULT_ADMIN_ID"
|
||||
|
||||
RESPONSE=$(
|
||||
curl -sS -X DELETE "$INSTANCE_URL/management/v1/users/$DEFAULT_ADMIN_ID" \
|
||||
-H "Authorization: Bearer $PAT" \
|
||||
-H "Content-Type: application/json" \
|
||||
)
|
||||
PARSED_RESPONSE=$(echo "$RESPONSE" | jq -r '.details.changeDate // "deleted"')
|
||||
handle_zitadel_request_response "$PARSED_RESPONSE" "delete_default_zitadel_admin" "$RESPONSE"
|
||||
|
||||
else
|
||||
echo "Default zitadel-admin user not found: $RESPONSE"
|
||||
fi
|
||||
}
|
||||
|
||||
init_zitadel() {
|
||||
echo -e "\nInitializing Zitadel with NetBird's applications\n"
|
||||
INSTANCE_URL="$NETBIRD_HTTP_PROTOCOL://$NETBIRD_DOMAIN"
|
||||
@@ -346,6 +385,9 @@ init_zitadel() {
|
||||
echo -n "Waiting for Zitadel to become ready "
|
||||
wait_api "$INSTANCE_URL" "$PAT"
|
||||
|
||||
echo "Deleting default zitadel-admin user..."
|
||||
delete_default_zitadel_admin "$INSTANCE_URL" "$PAT"
|
||||
|
||||
# create the zitadel project
|
||||
echo "Creating new zitadel project"
|
||||
PROJECT_ID=$(create_new_project "$INSTANCE_URL" "$PAT")
|
||||
|
||||
Reference in New Issue
Block a user