vault/ui/lib/pki/addon/components/parsed-certificate-info-rows.js
claire bontempo 570a33b6a6
UI: add info banner for not parsable certs (#20518)
* remove undefined payload.issuer_id

* add info banner to parsed display view

* add tests

* clean up conditional, add specific banner test selector

* check for undefined length
2023-05-04 20:54:10 +00:00

49 lines
1.8 KiB
JavaScript

import Component from '@glimmer/component';
import { parsedParameterKeys } from 'vault/utils/parse-pki-cert-oids';
/**
* @module ParsedCertificateInfoRowsComponent
* Renders attributes parsed from a PKI certificate (provided from parse-pki-cert util). It will only render rows for
* defined values that match `parsedParameterKeys` imported from the helper. It never renders common_name, even though
* the value is returned from the parse cert util, because `common_name` is important to PKI and we render it at the top.
*
* @example ```js
* <ParsedCertificateInfoRows @model={{@model.parsedCertificate}} />
* ```
*
* @param {object} model - object of parsed attributes from parse-pki-cert util
*/
export default class ParsedCertificateInfoRowsComponent extends Component {
get possibleFields() {
// We show common name elsewhere on the details view, so no need to render it here
const fieldKeys = parsedParameterKeys.filter((k) => k !== 'common_name');
const attrsByKey = {
other_sans: { label: 'Other SANs' },
alt_names: { label: 'Subject Alternative Names (SANs)' },
uri_sans: { label: 'URI SANs' },
ip_sans: { label: 'IP SANs' },
permitted_dns_domains: { label: 'Permitted DNS domains' },
exclude_cn_from_sans: { label: 'Exclude CN from SANs' },
use_pss: { label: 'Use PSS' },
ttl: { label: 'TTL' },
ou: { label: 'Organizational units (OU)' },
not_valid_after: { formatDate: 'MMM d yyyy HH:mm:ss a zzzz' },
not_valid_before: { formatDate: 'MMM d yyyy HH:mm:ss a zzzz' },
};
return fieldKeys.map((key) => {
return {
key,
...attrsByKey[key],
};
});
}
get parsingErrors() {
if (this.args.model?.parsing_errors?.length) {
return this.args.model.parsing_errors.map((e) => e.message).join(', ');
}
return '';
}
}