-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
567 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
```release-note:feature | ||
**New PKI UI**: Add beta support for new and improved PKI UI | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { encodePath } from 'vault/utils/path-encoding-helpers'; | ||
import ApplicationAdapter from '../application'; | ||
|
||
export default class PkiSignIntermediateAdapter extends ApplicationAdapter { | ||
namespace = 'v1'; | ||
|
||
createRecord(store, type, snapshot) { | ||
const serializer = store.serializerFor(type.modelName); | ||
const { backend, issuerRef } = snapshot.record; | ||
const url = `${this.buildURL()}/${encodePath(backend)}/issuer/${encodePath(issuerRef)}/sign-intermediate`; | ||
const data = serializer.serialize(snapshot, type); | ||
return this.ajax(url, 'POST', { data }).then((result) => ({ | ||
// sign-intermediate can happen multiple times per issuer, | ||
// so the ID needs to be unique from the issuer ID | ||
id: result.request_id, | ||
...result, | ||
})); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
import { attr } from '@ember-data/model'; | ||
import { withFormFields } from 'vault/decorators/model-form-fields'; | ||
import { withModelValidations } from 'vault/decorators/model-validations'; | ||
import PkiCertificateBaseModel from './certificate/base'; | ||
|
||
const validations = { | ||
csr: [{ type: 'presence', message: 'CSR is required.' }], | ||
}; | ||
@withModelValidations(validations) | ||
@withFormFields([ | ||
'csr', | ||
'useCsrValues', | ||
'commonName', | ||
'customTtl', | ||
'notBeforeDuration', | ||
'format', | ||
'permittedDnsDomains', | ||
'maxPathLength', | ||
]) | ||
export default class PkiSignIntermediateModel extends PkiCertificateBaseModel { | ||
getHelpUrl(backend) { | ||
return `/v1/${backend}/issuer/example/sign-intermediate?help=1`; | ||
} | ||
|
||
@attr issuerRef; | ||
|
||
@attr('string', { | ||
label: 'CSR', | ||
editType: 'textarea', | ||
subText: 'The PEM-encoded CSR to be signed.', | ||
}) | ||
csr; | ||
|
||
@attr('boolean', { | ||
label: 'Use CSR values', | ||
subText: | ||
'Subject information and key usages specified in the CSR will be used over parameters provided here, and extensions in the CSR will be copied into the issued certificate.', | ||
docLink: '/vault/api-docs/secret/pki#use_csr_values', | ||
}) | ||
useCsrValues; | ||
|
||
@attr({ | ||
label: 'Not valid after', | ||
detailsLabel: 'Issued certificates expire after', | ||
subText: | ||
'The time after which this certificate will no longer be valid. This can be a TTL (a range of time from now) or a specific date.', | ||
editType: 'yield', | ||
}) | ||
customTtl; | ||
|
||
@attr({ | ||
label: 'Backdate validity', | ||
detailsLabel: 'Issued certificate backdating', | ||
helperTextDisabled: 'Vault will use the default value, 30s', | ||
helperTextEnabled: | ||
'Also called the not_before_duration property. Allows certificates to be valid for a certain time period before now. This is useful to correct clock misalignment on various systems when setting up your CA.', | ||
editType: 'ttl', | ||
defaultValue: '30s', | ||
}) | ||
notBeforeDuration; | ||
|
||
@attr('string') | ||
commonName; | ||
|
||
@attr({ | ||
label: 'Permitted DNS domains', | ||
subText: | ||
'DNS domains for which certificates are allowed to be issued or signed by this CA certificate. Enter each value as a new input.', | ||
}) | ||
permittedDnsDomains; | ||
|
||
@attr({ | ||
subText: 'Specifies the maximum path length to encode in the generated certificate. -1 means no limit', | ||
defaultValue: '-1', | ||
}) | ||
maxPathLength; | ||
|
||
/* Signing Options overrides */ | ||
@attr({ | ||
label: 'Use PSS', | ||
subText: | ||
'If checked, PSS signatures will be used over PKCS#1v1.5 signatures when a RSA-type issuer is used. Ignored for ECDSA/Ed25519 issuers.', | ||
}) | ||
usePss; | ||
|
||
@attr({ | ||
label: 'Subject Key Identifier (SKID)', | ||
subText: | ||
'Value for the subject key identifier, specified as a string in hex format. If this is empty, Vault will automatically calculate the SKID. ', | ||
}) | ||
skid; | ||
|
||
@attr({ | ||
possibleValues: ['0', '256', '384', '512'], | ||
}) | ||
signatureBits; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import ApplicationSerializer from '../application'; | ||
|
||
export default class PkiRoleSerializer extends ApplicationSerializer {} | ||
export default class PkiRoleSerializer extends ApplicationSerializer { | ||
attrs = { | ||
name: { serialize: false }, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
ui/lib/pki/addon/components/pki-sign-intermediate-form.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
{{#if @model.id}} | ||
{{! Model only has ID once form has been submitted and saved }} | ||
<Toolbar /> | ||
<main data-test-sign-intermediate-result> | ||
<div class="box is-sideless is-fullwidth is-shadowless"> | ||
<AlertBanner | ||
@title="Next steps" | ||
@type="warning" | ||
@message="The CA Chain and Issuing CA values will only be available once. Make sure you copy and save it now." | ||
/> | ||
|
||
{{#each this.showFields as |fieldName|}} | ||
{{#let (find-by "name" fieldName @model.allFields) as |attr|}} | ||
<InfoTableRow @label={{or attr.options.label (humanize (dasherize attr.name))}} @value={{get @issuer attr.name}}> | ||
{{#if (and attr.options.masked (get @model attr.name))}} | ||
<MaskedInput @value={{get @model attr.name}} @displayOnly={{true}} @allowCopy={{true}} /> | ||
{{else if (eq attr.name "serialNumber")}} | ||
<LinkTo | ||
@route="certificates.certificate.details" | ||
@model={{@model.serialNumber}} | ||
>{{@model.serialNumber}}</LinkTo> | ||
{{else}} | ||
<Icon @name="minus" /> | ||
{{/if}} | ||
</InfoTableRow> | ||
{{/let}} | ||
{{/each}} | ||
</div> | ||
</main> | ||
{{else}} | ||
<form {{on "submit" (perform this.save)}} data-test-sign-intermediate-form> | ||
<div class="box is-sideless is-fullwidth is-marginless"> | ||
<MessageError @errorMessage={{this.errorBanner}} class="has-top-margin-s" /> | ||
<NamespaceReminder @mode={{"create"}} @noun="signed intermediate" /> | ||
{{#each @model.formFields as |attr|}} | ||
<FormField | ||
data-test-field={{attr}} | ||
@attr={{attr}} | ||
@model={{@model}} | ||
@modelValidations={{this.modelValidations}} | ||
@showHelpText={{false}} | ||
> | ||
{{! attr customTtl has editType yield and will show this component }} | ||
<PkiNotValidAfterForm @attr={{attr}} @model={{@model}} /> | ||
</FormField> | ||
{{/each}} | ||
|
||
<PkiGenerateToggleGroups @model={{@model}} @groups={{this.groups}} /> | ||
</div> | ||
<div class="has-top-padding-s"> | ||
<button | ||
type="submit" | ||
class="button is-primary {{if this.save.isRunning 'is-loading'}}" | ||
disabled={{this.save.isRunning}} | ||
data-test-pki-sign-intermediate-save | ||
> | ||
Save | ||
</button> | ||
<button | ||
type="button" | ||
class="button has-left-margin-s" | ||
disabled={{this.save.isRunning}} | ||
{{on "click" this.cancel}} | ||
data-test-pki-sign-intermediate-cancel | ||
> | ||
Cancel | ||
</button> | ||
{{#if this.inlineFormAlert}} | ||
<div class="control"> | ||
<AlertInline | ||
@type="danger" | ||
@paddingTop={{true}} | ||
@message={{this.inlineFormAlert}} | ||
@mimicRefresh={{true}} | ||
data-test-form-error | ||
/> | ||
</div> | ||
{{/if}} | ||
</div> | ||
</form> | ||
{{/if}} |
Oops, something went wrong.