]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: rgw_crypt_kmip_addr in SSE-KMS kmip address input field validation... 65223/head
authorAbhishek Desai <abhishek.desai1@ibm.com>
Mon, 4 Aug 2025 19:30:52 +0000 (01:00 +0530)
committerAbhishek Desai <abhishek.desai1@ibm.com>
Tue, 26 Aug 2025 05:15:05 +0000 (10:45 +0530)
fixes : https://tracker.ceph.com/issues/72408

Signed-off-by: Abhishek Desai <abhishek.desai1@ibm.com>
(cherry picked from commit 4aa462b091780dcfc7a297e57b314ba5a3a479fe)

src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-config-modal/rgw-config-modal.component.ts
src/pybind/mgr/dashboard/frontend/src/app/shared/forms/cd-validators.ts

index 54cbf64ee705644b33ba1985b828895e94f5f4f2..946ced0185fdb7a9ed8af01fba018eb14c4babd7 100644 (file)
@@ -25,8 +25,6 @@ import { KmipConfig, VaultConfig } from '~/app/shared/models/rgw-encryption-conf
   styleUrls: ['./rgw-config-modal.component.scss']
 })
 export class RgwConfigModalComponent implements OnInit {
-  readonly vaultAddress = /^((https?:\/\/)|(www.))(?:([a-zA-Z]+)|(\d+\.\d+.\d+.\d+)):\d{4}$/;
-
   kmsProviders: string[];
 
   configForm: CdFormGroup;
@@ -133,18 +131,7 @@ export class RgwConfigModalComponent implements OnInit {
 
   createForm() {
     this.configForm = this.formBuilder.group({
-      addr: [
-        null,
-        [
-          Validators.required,
-          CdValidators.custom('vaultPattern', (value: string) => {
-            if (_.isEmpty(value)) {
-              return false;
-            }
-            return !this.vaultAddress.test(value);
-          })
-        ]
-      ],
+      addr: [null, [CdValidators.urlWithProtocolOption(false), Validators.required]],
       kms_provider: ['vault', Validators.required],
       encryptionType: ['kms', Validators.required],
       auth: [
index 5c236730d467c5c88a6489f648bdcbe7e85bd268..531a2790cdf980302b2ea2193ab9e4d0fbd159ee 100644 (file)
@@ -689,7 +689,20 @@ export class CdValidators {
    * Validator function to validate endpoints, allowing FQDN, IPv4, and IPv6 addresses with ports.
    * Accepts multiple endpoints separated by commas.
    */
+
   static url(control: AbstractControl): ValidationErrors | null {
+    return CdValidators.urlInternal(control, true);
+  }
+
+  static urlWithProtocolOption(require_protocol: boolean) {
+    return (control: AbstractControl): ValidationErrors | null =>
+      CdValidators.urlInternal(control, require_protocol);
+  }
+
+  private static urlInternal(
+    control: AbstractControl,
+    require_protocol: boolean
+  ): ValidationErrors | null {
     const value = control.value;
 
     if (_.isEmpty(value)) {
@@ -701,7 +714,7 @@ export class CdValidators {
     const invalidUrls = urls.filter(
       (url: string) =>
         !validator.isURL(url, {
-          require_protocol: true,
+          require_protocol: require_protocol,
           allow_underscores: true,
           require_tld: false
         }) && !validator.isIP(url)