feat: auto-generate secure default password for Wazuh worker provisioning (#656)
oliver-oat committed
Feb 2, 2026 at 19:47 UTC
eb41059f09d46e275473ca83d532723e6bb69e2b
1 file changed
+26
frontend/src/components/customers/provision/CustomerProvisionWizard.vue
+26
@@ -653,6 +653,27 @@ async function submit() {
653
})
654
}
655
656
+function generateRandomPassword(length: number = 20): string {
657
+ const uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
658
+ const lowercase = "abcdefghijklmnopqrstuvwxyz"
659
+ const numbers = "0123456789"
660
+ const allChars = uppercase + lowercase + numbers
661
+
662
+ let password = ""
663
+ // Ensure at least one of each character type
664
+ password += uppercase[Math.floor(Math.random() * uppercase.length)]
665
+ password += lowercase[Math.floor(Math.random() * lowercase.length)]
666
+ password += numbers[Math.floor(Math.random() * numbers.length)]
667
+
668
+ // Fill the rest randomly
669
+ for (let i = password.length; i < length; i++) {
670
+ password += allChars[Math.floor(Math.random() * allChars.length)]
671
+ }
672
+
673
+ // Shuffle the password to randomize the guaranteed characters
674
+ return password.split('').sort(() => Math.random() - 0.5).join('')
675
+}
676
+
677
function formPreset(step: number) {
678
switch (step) {
679
case 2:
@@ -660,6 +681,11 @@ function formPreset(step: number) {
681
form.value.customer_index_name = `wazuh-${form.value.customer_code}`
682
}
683
break
684
+ case 5:
685
+ if (!form.value.wazuh_auth_password) {
686
+ form.value.wazuh_auth_password = generateRandomPassword()
687
+ }
688
+ break
689
}
690
}
691