diff --git a/ui/app/models/pki/pki-role-engine.js b/ui/app/models/pki/pki-role-engine.js
index 1b9d8eaf50..8460ca5e75 100644
--- a/ui/app/models/pki/pki-role-engine.js
+++ b/ui/app/models/pki/pki-role-engine.js
@@ -1,6 +1,5 @@
import Model, { attr } from '@ember-data/model';
import lazyCapabilities, { apiPath } from 'vault/macros/lazy-capabilities';
-import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
import { withModelValidations } from 'vault/decorators/model-validations';
import fieldToAttrs from 'vault/utils/field-to-attrs';
@@ -105,21 +104,9 @@ export default class PkiRoleEngineModel extends Model {
@attr('string', {
label: 'Key bits',
+ defaultValue: 2048,
})
- keyBits;
-
- // "possibleValues" for the field "keyBits" depends on the value of the selected "keyType"
- get keyBitsConditional() {
- const keyBitOptions = {
- rsa: [2048, 3072, 4096],
- ec: [256, 224, 384, 521],
- ed25519: [0],
- any: [0],
- };
- const attrs = expandAttributeMeta(this, ['keyBits']);
- attrs[0].options['possibleValues'] = keyBitOptions[this.keyType];
- return attrs[0];
- }
+ keyBits; // keyBits is a conditional value based on keyType. The model param is handled in the pkiKeyParameters component.
@attr('number', {
label: 'Signature bits',
@@ -286,11 +273,6 @@ export default class PkiRoleEngineModel extends Model {
docLink: '/api-docs/secret/pki#allowed_domains',
},
},
- 'Key parameters': {
- header: {
- text: `These are the parameters for generating or validating the certificate's key material.`,
- },
- },
'Subject Alternative Name (SAN) Options': {
header: {
text: `Subject Alternative Names (SANs) are identities (domains, IP addresses, and URIs) Vault attaches to the requested certificates.`,
diff --git a/ui/lib/pki/addon/components/pki-key-parameters.hbs b/ui/lib/pki/addon/components/pki-key-parameters.hbs
new file mode 100644
index 0000000000..2715338d00
--- /dev/null
+++ b/ui/lib/pki/addon/components/pki-key-parameters.hbs
@@ -0,0 +1,67 @@
+{{#let (camelize (concat "show" @group)) as |prop|}}
+
+ {{#if (get @model prop)}}
+
+
+ {{#each @model.fieldGroups as |fieldGroup|}}
+ {{#each-in fieldGroup as |group fields|}}
+ {{#if (eq group "Key parameters")}}
+ {{#each fields as |attr|}}
+ {{#if (eq attr.name "keyBits")}}
+
+
+
+
+
+
+
+
+ {{else}}
+
+
+
+
+
+
+
+
+ {{/if}}
+ {{/each}}
+ {{/if}}
+ {{/each-in}}
+ {{/each}}
+
+ {{/if}}
+{{/let}}
\ No newline at end of file
diff --git a/ui/lib/pki/addon/components/pki-key-parameters.js b/ui/lib/pki/addon/components/pki-key-parameters.js
new file mode 100644
index 0000000000..ac6d692990
--- /dev/null
+++ b/ui/lib/pki/addon/components/pki-key-parameters.js
@@ -0,0 +1,45 @@
+import Component from '@glimmer/component';
+import { action } from '@ember/object';
+
+/**
+ * @module PkiKeyParameters
+ * PkiKeyParameters components are used to set the default and update the key_bits pki role api param whenever the key_type changes.
+ * key_bits is conditional on key_type and should be set as a default value whenever key_type changes.
+ * @example
+ * ```js
+ *
+ * ```
+ * @param {class} model - The pki/pki-role-engine model.
+ * @param {string} group - The name of the group created in the model. In this case, it's the "Key parameters" group.
+ */
+
+const KEY_BITS_OPTIONS = {
+ rsa: [2048, 3072, 4096],
+ ec: [256, 224, 384, 521],
+ ed25519: [0],
+ any: [0],
+};
+
+export default class PkiKeyParameters extends Component {
+ get keyBitOptions() {
+ return KEY_BITS_OPTIONS[this.args.model.keyType];
+ }
+
+ get keyBitsDefault() {
+ return Number(KEY_BITS_OPTIONS[this.args.model.keyType][0]);
+ }
+
+ @action onKeyBitsChange(selection) {
+ this.args.model.set('keyBits', Number(selection.target.value));
+ }
+
+ @action onSignatureBitsOrKeyTypeChange(name, selection) {
+ if (name === 'signatureBits') {
+ this.args.model.set(name, Number(selection.target.value));
+ }
+ if (name === 'keyType') {
+ this.args.model.set(name, selection.target.value);
+ this.args.model.set('keyBits', this.keyBitsDefault);
+ }
+ }
+}
diff --git a/ui/lib/pki/addon/components/pki-role-form.hbs b/ui/lib/pki/addon/components/pki-role-form.hbs
index 11cd877b51..3ec446c9b1 100644
--- a/ui/lib/pki/addon/components/pki-role-form.hbs
+++ b/ui/lib/pki/addon/components/pki-role-form.hbs
@@ -48,6 +48,8 @@
{{/each}}
{{else if (eq group "Key usage")}}
+ {{else if (eq group "Key parameters")}}
+
{{else}}
{{! Groups hidden behind Toggles }}
{{#let (camelize (concat "show" group)) as |prop|}}
@@ -77,7 +79,7 @@
{{#each fields as |attr|}}
-
+
Tidy
-
+
Edit configuration
diff --git a/ui/lib/pki/addon/templates/issuers/index.hbs b/ui/lib/pki/addon/templates/issuers/index.hbs
index ea56d846b1..34c685be58 100644
--- a/ui/lib/pki/addon/templates/issuers/index.hbs
+++ b/ui/lib/pki/addon/templates/issuers/index.hbs
@@ -10,7 +10,7 @@
/>
-
+
Import
diff --git a/ui/lib/pki/addon/templates/keys/index.hbs b/ui/lib/pki/addon/templates/keys/index.hbs
index 59dc3b9894..8cf40fbee3 100644
--- a/ui/lib/pki/addon/templates/keys/index.hbs
+++ b/ui/lib/pki/addon/templates/keys/index.hbs
@@ -10,10 +10,10 @@
/>
-
+
Import
-
+
Generate
diff --git a/ui/lib/pki/addon/templates/overview.hbs b/ui/lib/pki/addon/templates/overview.hbs
index 7fa8c6e0d8..9f27316275 100644
--- a/ui/lib/pki/addon/templates/overview.hbs
+++ b/ui/lib/pki/addon/templates/overview.hbs
@@ -10,7 +10,7 @@
/>
-
+
Configure PKI
diff --git a/ui/lib/pki/addon/templates/roles/index.hbs b/ui/lib/pki/addon/templates/roles/index.hbs
index 9fb96973e8..92fb8e34dc 100644
--- a/ui/lib/pki/addon/templates/roles/index.hbs
+++ b/ui/lib/pki/addon/templates/roles/index.hbs
@@ -10,7 +10,7 @@
/>
-
+
Create role