UI: add issuerRef getter in case issuer is nameless (#18968)

* add issuerRef getter in case issuer is nameless

* declare as getter

* remove changes to test, oops!
This commit is contained in:
claire bontempo 2023-02-03 13:07:59 -08:00 committed by GitHub
parent 543f524190
commit 06bec24b00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 14 additions and 9 deletions

View File

@ -7,7 +7,7 @@ export default class PkiActionAdapter extends ApplicationAdapter {
urlForCreateRecord(modelName, snapshot) {
const { type } = snapshot.record;
const { actionType, useIssuer, issuerName, mount } = snapshot.adapterOptions;
const { actionType, useIssuer, issuerRef, mount } = snapshot.adapterOptions;
// if the backend mount is passed, we want that to override the URL's mount path
const backend = mount || snapshot.record.backend;
if (!backend || !actionType) {
@ -24,7 +24,7 @@ export default class PkiActionAdapter extends ApplicationAdapter {
? `${baseUrl}/issuers/generate/intermediate/${type}`
: `${baseUrl}/intermediate/generate/${type}`;
case 'sign-intermediate':
return `${baseUrl}/issuer/${encodePath(issuerName)}/sign-intermediate`;
return `${baseUrl}/issuer/${encodePath(issuerRef)}/sign-intermediate`;
default:
assert('actionType must be one of import, generate-root, generate-csr or sign-intermediate');
}

View File

@ -31,6 +31,10 @@ export default class PkiIssuerModel extends PkiCertificateBaseModel {
return false;
}
get issuerRef() {
return this.issuerName || this.issuerId;
}
@attr isDefault; // readonly
@attr('string') issuerId;

View File

@ -50,7 +50,7 @@
@route="externalMountIssuer"
@models={{array (get crossSignRow "intermediateMount") data.issuerId}}
>
{{data.issuerName}}
{{data.issuerRef}}
</LinkToExternal>
{{/if}}
</div>

View File

@ -21,7 +21,7 @@ import { parseCertificate } from 'vault/utils/parse-pki-cert';
* 2. Create a new CSR based on this existing issuer ID
* -> POST /:intermediateMount/intermediate/generate/existing
* 3. Sign it with the new parent issuer, minting a new certificate.
* -> POST /this.args.parentIssuer.backend/issuer/this.args.parentIssuer.issuerName/sign-intermediate
* -> POST /this.args.parentIssuer.backend/issuer/this.args.parentIssuer.issuerRef/sign-intermediate
* 4. Import it back into the existing mount
* -> POST /:intermediateMount/issuers/import/bundle
* 5. Read the imported issuer
@ -145,7 +145,7 @@ export default class PkiIssuerCrossSign extends Component {
adapterOptions: {
actionType: 'sign-intermediate',
mount: this.args.parentIssuer.backend,
issuerName: this.args.parentIssuer.issuerName,
issuerRef: this.args.parentIssuer.issuerRef,
},
})
.then(({ caChain }) => caChain.join('\n'));

View File

@ -49,7 +49,7 @@
<div>
<Icon @name="certificate" class="has-text-grey-light" />
<span class="has-text-weight-semibold is-underline">
{{or pkiIssuer.issuerName pkiIssuer.id}}
{{pkiIssuer.issuerRef}}
</span>
<div class="is-flex-row has-left-margin-l has-top-margin-xs">
{{#if pkiIssuer.isDefault}}

View File

@ -21,7 +21,7 @@
<ol class="has-left-margin-m has-bottom-margin-s">
<li>You identify which intermediates need to be cross-signed.</li>
<li>The new CSR for your intermediate(s) will be generated.</li>
<li>The CSR is signed with the root <strong>{{this.model.issuerName}}</strong>.</li>
<li>The CSR is signed with the root <strong>{{this.model.issuerRef}}</strong>.</li>
<li>Your new intermediate(s) are imported into any existing mount(s).</li>
</ol>
Then, you can begin re-issuing leaf certs and phase out the old root.

View File

@ -22,7 +22,7 @@ module('Unit | Serializer | pki/action', function (hooks) {
const store = this.owner.lookup('service:store');
const record = store.createRecord('pki/action', {
pemBundle: this.pemBundle,
issuerName: 'do-not-send',
issuerRef: 'do-not-send',
keyType: 'do-not-send',
});
const expectedResult = {

View File

@ -3,9 +3,10 @@ import { FormField, FormFieldGroups, ModelValidations } from 'vault/app-types';
export default class PkiIssuerModel extends PkiCertificateBaseModel {
useOpenAPI(): boolean;
issuerId: string;
issuerName: string;
issuerRef(): string;
keyId: string;
uriSans: string;
issuerName: string;
leafNotAfterBehavior: string;
usage: string;
manualChain: string;