mirror of
https://github.com/Security-Onion-Solutions/securityonion.git
synced 2025-12-06 17:22:49 +01:00
Migrate users from locked to inactive during soup
This commit is contained in:
@@ -385,6 +385,19 @@ EOF
|
||||
fi
|
||||
}
|
||||
|
||||
function migrateLockedUsers() {
|
||||
# This is a migration function to convert locked users from prior to 2.3.90
|
||||
# to inactive users using the newer Kratos functionality. This should only
|
||||
# find locked users once.
|
||||
lockedEmails=$(curl -s http://localhost:4434/identities | jq -r '.[] | select(.traits.status == "locked") | .traits.email')
|
||||
if [[ -n "$lockedEmails" ]]; then
|
||||
echo "Disabling locked users..."
|
||||
for email in $lockedEmails; do
|
||||
updateStatus "$email" locked
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
function updateStatus() {
|
||||
email=$1
|
||||
status=$2
|
||||
@@ -398,7 +411,7 @@ function updateStatus() {
|
||||
schemaId=$(echo "$response" | jq -r .schema_id)
|
||||
|
||||
# Capture traits and remove obsolete 'status' trait if exists
|
||||
traitBlock=$(echo "$response" | jq -r .traits | grep -v "\"status\":")
|
||||
traitBlock=$(echo "$response" | jq -c .traits | sed -re 's/,?"status":".*?"//')
|
||||
|
||||
state="active"
|
||||
if [[ "$status" == "locked" ]]; then
|
||||
@@ -545,6 +558,11 @@ case "${operation}" in
|
||||
echo "Password is acceptable"
|
||||
;;
|
||||
|
||||
"migrate")
|
||||
migrateLockedUsers
|
||||
echo "User migration complete"
|
||||
;;
|
||||
|
||||
*)
|
||||
fail "Unsupported operation: $operation"
|
||||
;;
|
||||
|
||||
@@ -1037,6 +1037,9 @@ main() {
|
||||
echo "Checking sudoers file."
|
||||
check_sudoers
|
||||
|
||||
echo "Checking for necessary user migrations."
|
||||
so-user migrate
|
||||
|
||||
if [[ -n $lsl_msg ]]; then
|
||||
case $lsl_msg in
|
||||
'distributed')
|
||||
|
||||
Reference in New Issue
Block a user