diff --git a/ui/app/adapters/pki/key.js b/ui/app/adapters/pki/key.js
index 32e014baff94..91a979509a24 100644
--- a/ui/app/adapters/pki/key.js
+++ b/ui/app/adapters/pki/key.js
@@ -4,24 +4,21 @@ import { encodePath } from 'vault/utils/path-encoding-helpers';
export default class PkiKeyAdapter extends ApplicationAdapter {
namespace = 'v1';
- optionsForQuery(id) {
- const data = {};
- if (!id) {
- data['list'] = true;
- }
- return { data };
- }
-
- urlForQuery(backend, id) {
- let url = `${this.buildURL()}/${encodePath(backend)}/keys`;
+ getUrl(backend, id) {
+ const url = `${this.buildURL()}/${encodePath(backend)}`;
if (id) {
- url = url + '/' + encodePath(id);
+ return url + '/key/' + encodePath(id);
}
- return url;
+ return url + '/keys';
}
query(store, type, query) {
+ const { backend } = query;
+ return this.ajax(this.getUrl(backend), 'GET', { data: { list: true } });
+ }
+
+ queryRecord(store, type, query) {
const { backend, id } = query;
- return this.ajax(this.urlForQuery(backend, id), 'GET', this.optionsForQuery(id));
+ return this.ajax(this.getUrl(backend, id), 'GET');
}
}
diff --git a/ui/app/models/pki/key.js b/ui/app/models/pki/key.js
index 6c465a10d1ae..d767289e773f 100644
--- a/ui/app/models/pki/key.js
+++ b/ui/app/models/pki/key.js
@@ -1,10 +1,18 @@
import Model, { attr } from '@ember-data/model';
+import { expandAttributeMeta } from 'vault/utils/field-to-attrs';
export default class PkiKeyModel extends Model {
@attr('string', { readOnly: true }) backend;
@attr('boolean') isDefault;
- @attr('string') keyRef; // reference to an existing key: either, vault generate identifier, literal string 'default', or the name assigned to the key. Part of the request URL.
- @attr('string') keyId;
+ @attr('string', { possibleValues: ['internal', 'external'] }) type;
+ @attr('string', { detailsLabel: 'Key ID' }) keyId;
@attr('string') keyName;
@attr('string') keyType;
+ @attr('string', { detailsLabel: 'Key bit length' }) keyBits; // TODO confirm with crypto team to remove this field from details page
+
+ // TODO refactor when field-to-attrs util is refactored as decorator
+ constructor() {
+ super(...arguments);
+ this.formFields = expandAttributeMeta(this, ['keyId', 'keyName', 'keyType', 'keyBits']);
+ }
}
diff --git a/ui/app/serializers/pki/key.js b/ui/app/serializers/pki/key.js
index de645399d252..c2f7ef0b1d7e 100644
--- a/ui/app/serializers/pki/key.js
+++ b/ui/app/serializers/pki/key.js
@@ -1,11 +1,12 @@
import ApplicationSerializer from '../application';
export default class PkiKeySerializer extends ApplicationSerializer {
+ primaryKey = 'key_id';
// rehydrate each keys model so all model attributes are accessible from the LIST response
normalizeItems(payload) {
if (payload.data) {
if (payload.data?.keys && Array.isArray(payload.data.keys)) {
- return payload.data.keys.map((key) => ({ id: key, ...payload.data.key_info[key] }));
+ return payload.data.keys.map((key) => ({ key_id: key, ...payload.data.key_info[key] }));
}
Object.assign(payload, payload.data);
delete payload.data;
diff --git a/ui/lib/pki/addon/components/pki-key-details.hbs b/ui/lib/pki/addon/components/pki-key-details.hbs
new file mode 100644
index 000000000000..070eb1daceda
--- /dev/null
+++ b/ui/lib/pki/addon/components/pki-key-details.hbs
@@ -0,0 +1,56 @@
+
+
+