Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI: remodel shamir flow #21871

Merged
merged 26 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a8a339c
clickable label on raft join
hashishaw Jul 12, 2023
76265e4
Small adjustments on current shamir components
hashishaw Jul 13, 2023
c512826
Add shamir/form with stub test
hashishaw Jul 13, 2023
c3ca3bb
Add WIP shamir/flow component which works for unseal action
hashishaw Jul 13, 2023
d6b4eb5
Use new components on unseal flow
hashishaw Jul 13, 2023
42818d3
WIP
hashishaw Jul 14, 2023
5a01308
Add ChoosePgpKeyForm component for selecting PGP key
hashishaw Jul 14, 2023
f16bf04
Add Shamir/DrTokenFlow component and updates to Shamir/Flow which it …
hashishaw Jul 14, 2023
4c749ea
Small updates to Shamir/Form
hashishaw Jul 14, 2023
79c4c7e
Use updated Shamir components for unseal and replication generate token
hashishaw Jul 14, 2023
ce6b34c
remove old shamir components
hashishaw Jul 14, 2023
d8c963e
Merge branch 'main' into ui/revisit-shamir-flow
hashishaw Jul 18, 2023
8568325
Shamir/Form test
hashishaw Jul 14, 2023
74f56f9
Move selectors to shared, Shamir::Flow tests, cleanup
hashishaw Jul 14, 2023
fda9b8d
Test coverage for cluster adapter generateDrOperationToken
hashishaw Jul 17, 2023
fd16390
Choose-pgp-key-form tests
hashishaw Jul 18, 2023
31cae97
dr-token-flow-test
hashishaw Jul 18, 2023
5ce7248
Shamir/form test cleanup
hashishaw Jul 18, 2023
43003a9
Update generateDrOperationToken to match latest docs
hashishaw Jul 18, 2023
467efcf
cleanup, address comments
hashishaw Jul 18, 2023
b0df709
fix tests
hashishaw Jul 19, 2023
646337e
Add changelog
hashishaw Jul 19, 2023
54c010a
Merge branch 'main' into ui/revisit-shamir-flow
hashishaw Jul 19, 2023
5b4aa03
Address comments
hashishaw Jul 19, 2023
c98e74d
Fix lint
hashishaw Jul 19, 2023
01c0bfc
Merge branch 'main' into ui/revisit-shamir-flow
hashishaw Jul 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions ui/app/adapters/cluster.js
hashishaw marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,19 @@ export default ApplicationAdapter.extend({
},

generateDrOperationToken(data, options) {
let verb = options && options.checkStatus ? 'GET' : 'PUT';
if (options.cancel) {
verb = 'DELETE';
}
let verb = 'POST';
let url = `${this.buildURL()}/replication/dr/secondary/generate-operation-token/`;
if (!data || data.pgp_key || data.attempt) {
// start the generation
url = url + 'attempt';
if (options?.cancel) {
verb = 'DELETE';
url += 'attempt';
} else if (options?.checkStatus) {
verb = 'GET';
url += 'attempt';
} else if (data?.pgp_key || data?.attempt) {
url += 'attempt';
} else {
// progress the operation
url = url + 'update';
url += 'update';
}
return this.ajax(url, verb, {
data,
Expand Down
4 changes: 4 additions & 0 deletions ui/app/controllers/vault/cluster/unseal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export default Controller.extend({
});
},

reloadCluster() {
return this.model.reload();
},

isUnsealed(data) {
return data.sealed === false;
},
Expand Down
44 changes: 0 additions & 44 deletions ui/app/styles/components/vlt-radio.scss

This file was deleted.

1 change: 0 additions & 1 deletion ui/app/styles/core.scss
Original file line number Diff line number Diff line change
Expand Up @@ -120,5 +120,4 @@
@import './components/unseal-warning';
// @import './components/ui-wizard'; // remove, see PR https://github.com/hashicorp/vault/pull/19220
@import './components/vault-loading';
@import './components/vlt-radio';
hashishaw marked this conversation as resolved.
Show resolved Hide resolved
@import './components/vlt-table';
10 changes: 4 additions & 6 deletions ui/app/templates/components/raft-join.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,25 @@
<br />
How do you want to get started?
</h2>
<div class="vlt-radio is-block">
<div class="has-bottom-margin-s">
hashishaw marked this conversation as resolved.
Show resolved Hide resolved
<RadioButton
id="join"
name="setup-pref"
@value="join"
@groupValue={{this.preference}}
@onChange={{fn (mut this.preference)}}
/>
<label for="join"></label>
Join an existing Raft cluster
<label for="join">Join an existing Raft cluster</label>
</div>
<div class="vlt-radio is-block">
<div>
<RadioButton
id="init"
name="setup-pref"
@value="init"
@groupValue={{this.preference}}
@onChange={{fn (mut this.preference)}}
/>
<label for="init" data-test-join-init></label>
Create a new Raft cluster
<label for="init" data-test-join-init>Create a new Raft cluster</label>
</div>
</div>
<div class="box is-marginless is-shadowless">
Expand Down
34 changes: 20 additions & 14 deletions ui/app/templates/vault/cluster/unseal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,27 @@
is
{{if this.model.unsealed "unsealed" "sealed"}}
</p>
<p>
Unseal Vault by entering portions of the unseal key. This can be done via multiple mechanisms on multiple
computers. Once all portions are entered, the root key will be decrypted and Vault will unseal.
</p>
{{#if this.model.unsealed}}
<p>Please wait while we redirect you.</p>
{{else}}
<p>
Unseal Vault by entering portions of the unseal key. This can be done via multiple mechanisms on multiple
computers. Once all portions are entered, the root key will be decrypted and Vault will unseal.
</p>
<Shamir::Flow
@action="unseal"
@threshold={{this.model.sealThreshold}}
@progress={{this.model.sealProgress}}
@updateProgress={{action "reloadCluster"}}
@inputLabel="Unseal Key Portion"
@buttonText="Unseal"
@onLicenseError={{action "handleLicenseError"}}
@checkComplete={{action "isUnsealed"}}
@onShamirSuccess={{action "transitionToCluster"}}
class="has-top-margin-m"
hashishaw marked this conversation as resolved.
Show resolved Hide resolved
/>
{{/if}}
</div>
<ShamirFlow
@action="unseal"
@onLicenseError={{action "handleLicenseError"}}
@onShamirSuccess={{action "transitionToCluster"}}
@buttonText="Unseal"
@thresholdPath="t"
@isComplete={{action "isUnsealed"}}
@threshold={{this.model.sealThreshold}}
@progress={{this.model.sealProgress}}
/>
</Page.content>
<Page.footer>
<div class="box is-borderless is-shadowless">
Expand Down
65 changes: 65 additions & 0 deletions ui/lib/core/addon/components/choose-pgp-key-form.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{{#if this.selectedPgp}}
<form
id="confirm-pgp-key"
{{on "submit" this.handleSubmit}}
aria-label="begin token generation with PGP key"
data-test-confirm-pgp-key
>
<div>
<p class="has-bottom-margin-m" data-test-pgp-key-confirm>
{{or
@confirmText
(concat
'Below is the base-64 encoded PGP Key that will be used. Click the "' this.buttonText '" button to proceed.'
)
}}
</p>
<h4 class="field-title has-bottom-padding-m is-fullwidth">
PGP Key
hashishaw marked this conversation as resolved.
Show resolved Hide resolved
{{this.pgpKeyFile.filename}}
</h4>
<div class="message is-list has-copy-button" tabindex="-1">
<HoverCopyButton @copyValue={{this.pgpKey}} />
<code class="is-word-break" data-test-pgp-key-copy>{{this.pgpKey}}</code>
</div>
</div>
<div class="field is-grouped">
<div class="control">
<button type="button" class="button" {{on "click" (fn (mut this.selectedPgp) "")}} data-test-confirm-pgp-back-button>
Back
</button>
</div>
<div class="control">
<button type="submit" disabled={{not this.pgpKey}} class="button is-primary" data-test-confirm-pgp-key-submit>
{{this.buttonText}}
</button>
</div>
</div>
</form>
{{else}}
<form
id="choose-pgp-key"
{{on "submit" this.usePgpKey}}
aria-label="provide PGP key"
data-test-choose-pgp-key-form="begin"
>
<div class="has-bottom-margin-m">
<p data-test-choose-pgp-key-description>
{{this.formText}}
</p>
<PgpFile @index="" @key={{this.pgpKeyFile}} @onChange={{this.setKey}} />
</div>
<div class="field is-grouped">
<div class="control">
<button type="button" class="button" {{on "click" @onCancel}} data-test-use-pgp-key-cancel>
Back
</button>
</div>
<div class="control">
<button type="submit" disabled={{not this.pgpKeyFile.value}} class="button is-primary" data-test-use-pgp-key-button>
Use PGP Key
</button>
</div>
</div>
</form>
{{/if}}
53 changes: 53 additions & 0 deletions ui/lib/core/addon/components/choose-pgp-key-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { action } from '@ember/object';
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';

const pgpKeyFileDefault = () => ({ value: '' });

/**
* @module ChoosePgpKeyForm
* ChoosePgpKeyForm component is used for DR Operation Token Generation workflow. It provides
* an interface for the user to upload or paste a PGP key for use
*
* @example
* ```js
* <ChoosePgpKeyForm @onCancel={{this.reset}} @onSubmit={{handleGenerateWithPgpKey}}>
* ```
* @param {function} onCancel - required - This function will be triggered when the modal intends to be closed
* @param {function} onSubmit - required - When the PGP key is confirmed, it will call this method with the pgpKey value as the only param
* @param {string} buttonText - Button text for onSubmit. Defaults to "Continue with key"
* @param {string} formText - Form text above where the users uploads or pastes the key. Has default
*/
export default class ChoosePgpKeyForm extends Component {
@tracked pgpKeyFile = pgpKeyFileDefault();
hashishaw marked this conversation as resolved.
Show resolved Hide resolved
@tracked selectedPgp = '';

get pgpKey() {
return this.pgpKeyFile.value;
}

get buttonText() {
return this.args.buttonText || 'Continue with key';
}

get formText() {
return (
this.args.formText ||
'Choose a PGP Key from your computer or paste the contents of one in the form below.'
);
}

@action setKey(_, keyFile) {
this.pgpKeyFile = keyFile;
}

// Form submit actions:
@action usePgpKey(evt) {
evt.preventDefault();
this.selectedPgp = this.pgpKey;
}
@action handleSubmit(evt) {
evt.preventDefault();
this.args.onSubmit(this.pgpKey);
}
}
Loading
Loading