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: Pki engine (redesign) routing changes #17997

Merged
merged 10 commits into from
Nov 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import Component from '@glimmer/component';
import { action } from '@ember/object';

/**
* @module KeyParameters
* KeyParameters components are used to set the default and update the key_bits pki role api param whenever the key_type changes.
* @module PkiKeyParameters
* PkiKeyParameters components are used to set the default and update the key_bits pki role api param whenever the key_type changes.
* key_bits is conditional on key_type and should be set as a default value whenever key_type changes.
* @example
* ```js
* <KeyParameters @model={@model} @group={group}/>
* <PkiKeyParameters @model={@model} @group={group}/>
* ```
* @param {class} model - The pki/role model.
* @param {string} group - The name of the group created in the model. In this case, it's the "Key parameters" group.
Expand All @@ -20,7 +20,7 @@ const KEY_BITS_OPTIONS = {
any: [0],
};

export default class KeyParameters extends Component {
export default class PkiKeyParameters extends Component {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hashishaw and I had discussed nesting these components in a pki/ folder so that there weren't any conflicts with the addon engine. But for some reason the role form had trouble finding <Pki::KeyParameters> so I opted for prefixing the files with pki- instead

get keyBitOptions() {
return KEY_BITS_OPTIONS[this.args.model.keyType];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@
</FormField>
{{/each}}
{{else if (eq group "Key usage")}}
<KeyUsage @model={{@model}} @group={{group}} />
<PkiKeyUsage @model={{@model}} @group={{group}} />

Check warning

Code scanning / Semgrep Scanner

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".

Check warning

Code scanning / Semgrep Scanner

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".
{{else if (eq group "Key parameters")}}
<KeyParameters @model={{@model}} @group={{group}} />
<PkiKeyParameters @model={{@model}} @group={{group}} />

Check warning

Code scanning / Semgrep Scanner

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".

Check warning

Code scanning / Semgrep Scanner

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".
{{else}}
{{! Groups hidden behind Toggles }}
{{#let (camelize (concat "show" group)) as |prop|}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import { task } from 'ember-concurrency';
import { tracked } from '@glimmer/tracking';

/**
* @module RoleForm
* RoleForm components are used to create and update PKI roles.
* @module PkiRoleForm
* PkiRoleForm components are used to create and update PKI roles.
*
* @example
* ```js
* <RoleForm @model={{this.model}}/>
* <PkiRoleForm @model={{this.model}}/>
* ```
* @callback onCancel
* @callback onSave
Expand All @@ -19,7 +19,7 @@ import { tracked } from '@glimmer/tracking';
* @param {onSave} onSave - Callback triggered on save success.
*/

export default class RoleForm extends Component {
export default class PkiRoleForm extends Component {
@service store;
@service flashMessages;

Expand Down
27 changes: 13 additions & 14 deletions ui/lib/pki/addon/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,44 @@ import buildRoutes from 'ember-engines/routes';
export default buildRoutes(function () {
this.route('overview');
this.route('configuration', function () {
this.route('index', { path: '/' });
this.route('tidy');
this.route('create', function () {
this.route('index', { path: '/' });
this.route('import-ca');
this.route('generate-root');
this.route('generate-csr');
});
this.route('create');
Copy link
Contributor Author

@hellobontempo hellobontempo Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The initial configuration has three radio buttons that provide a different configuration view, but they are all the same route. Instead of them each being separate routes, different components will render based on the user's selection
Screen Shot 2022-11-16 at 3 34 34 PM

this.route('edit');
this.route('details');
Copy link
Contributor Author

@hellobontempo hellobontempo Nov 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the config details will instead live at pki/configuration

});
this.route('roles', function () {
this.route('index', { path: '/' });
this.route('create');
this.route('role', { path: '/:id' }, function () {
this.route('role', { path: '/:role' }, function () {
this.route('details');
this.route('edit');
this.route('generate');
this.route('sign');
});
});
this.route('issuers', function () {
this.route('index', { path: '/' });
this.route('issuer', { path: '/:id' }, function () {
this.route('import');
this.route('generate-root');
this.route('generate-intermediate');
this.route('issuer', { path: '/:issuer_ref' }, function () {
this.route('details');
this.route('edit');
this.route('sign');
this.route('cross-sign');
});
});
this.route('certificates', function () {
this.route('index', { path: '/' });
this.route('create');
this.route('certificate', { path: '/:id' }, function () {
this.route('certificate', { path: '/:serial' }, function () {
this.route('details');
this.route('edit');
});
});
this.route('keys', function () {
this.route('index', { path: '/' });
this.route('generate');
this.route('create');
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

opted for create over generate to align with standard CRUD operation verbs

this.route('import');
this.route('key', { path: '/:id' }, function () {
this.route('key', { path: '/:key_ref' }, function () {
this.route('details');
this.route('edit');
});
Expand Down
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/certificates/certificate/details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiCertificateDetailsRoute extends Route {}
4 changes: 2 additions & 2 deletions ui/lib/pki/addon/routes/certificates/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default class PkiCertificatesIndexRoute extends Route {

beforeModel() {
// Must call this promise before the model hook otherwise it doesn't add OpenApi to record.
return this.pathHelp.getNewModel('pki/pki-certificate-engine', 'pki');
return this.pathHelp.getNewModel('pki/certificate', 'pki');
}

model() {
return this.store
.query('pki/pki-certificate-engine', { backend: this.secretMountPath.currentPath })
.query('pki/certificate', { backend: this.secretMountPath.currentPath })
.then((certificateModel) => {
return { certificateModel, parentModel: this.modelFor('certificates') };
})
Expand Down
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/configuration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiConfigurationRoute extends Route {}
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/configuration/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiConfigurationCreateRoute extends Route {}

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions ui/lib/pki/addon/routes/configuration/create/import-ca.js

This file was deleted.

3 changes: 0 additions & 3 deletions ui/lib/pki/addon/routes/configuration/create/index.js

This file was deleted.

3 changes: 0 additions & 3 deletions ui/lib/pki/addon/routes/configuration/details.js

This file was deleted.

3 changes: 0 additions & 3 deletions ui/lib/pki/addon/routes/configuration/index.js

This file was deleted.

3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/issuers/generate-intermediate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiIssuersGenerateIntermediateRoute extends Route {}
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/issuers/generate-root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiIssuersGenerateRootRoute extends Route {}
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/issuers/import.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiIssuersImportRoute extends Route {}
7 changes: 3 additions & 4 deletions ui/lib/pki/addon/routes/issuers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ export default class PkiIssuersIndexRoute extends Route {

beforeModel() {
// Must call this promise before the model hook otherwise it doesn't add OpenApi to record.
return this.pathHelp.getNewModel('pki/pki-issuer-engine', 'pki');
return this.pathHelp.getNewModel('pki/issuer', 'pki');
}

model() {
// the pathHelp service is needed for adding openAPI to the model
this.pathHelp.getNewModel('pki/pki-issuer-engine', 'pki');

this.pathHelp.getNewModel('pki/issuer', 'pki');
return this.store
.query('pki/pki-issuer-engine', { backend: this.secretMountPath.currentPath })
.query('pki/issuer', { backend: this.secretMountPath.currentPath })
.then((issuersModel) => {
return { issuersModel, parentModel: this.modelFor('issuers') };
})
Expand Down
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/issuers/issuer/cross-sign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiIssuerCrossSignRoute extends Route {}
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/issuers/issuer/details.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiIssuerDetailsRoute extends Route {}
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/issuers/issuer/edit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiIssuerEditRoute extends Route {}
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/issuers/issuer/sign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiIssuerSignRoute extends Route {}
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/keys/create.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiKeysCreateRoute extends Route {}
3 changes: 0 additions & 3 deletions ui/lib/pki/addon/routes/keys/generate.js

This file was deleted.

4 changes: 2 additions & 2 deletions ui/lib/pki/addon/routes/keys/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ export default class PkiKeysIndexRoute extends Route {

beforeModel() {
// Must call this promise before the model hook otherwise it doesn't add OpenApi to record.
return this.pathHelp.getNewModel('pki/pki-key-engine', 'pki');
return this.pathHelp.getNewModel('pki/key', 'pki');
}

model() {
return this.store
.query('pki/pki-key-engine', { backend: this.secretMountPath.currentPath })
.query('pki/key', { backend: this.secretMountPath.currentPath })
.then((keyModel) => {
return { keyModel, parentModel: this.modelFor('keys') };
})
Expand Down
2 changes: 1 addition & 1 deletion ui/lib/pki/addon/routes/keys/key/details.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiKeysKeyDetailsRoute extends Route {}
export default class PkiKeyDetailsRoute extends Route {}
2 changes: 1 addition & 1 deletion ui/lib/pki/addon/routes/keys/key/edit.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiKeysKeyEditRoute extends Route {}
export default class PkiKeyEditRoute extends Route {}
2 changes: 1 addition & 1 deletion ui/lib/pki/addon/routes/roles/role/details.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Route from '@ember/routing/route';

export default class RolesRoleDetailsRoute extends Route {}
export default class PkiRoleDetailsRoute extends Route {}
2 changes: 1 addition & 1 deletion ui/lib/pki/addon/routes/roles/role/edit.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import Route from '@ember/routing/route';

export default class RolesRoleEditRoute extends Route {}
export default class PkiRoleEditRoute extends Route {}
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/roles/role/generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiRoleGenerateRoute extends Route {}
3 changes: 3 additions & 0 deletions ui/lib/pki/addon/routes/roles/role/sign.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Route from '@ember/routing/route';

export default class PkiRoleSignRoute extends Route {}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route: certificate.details
2 changes: 1 addition & 1 deletion ui/lib/pki/addon/templates/certificates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{{/each}}
{{else}}
<EmptyState @title="PKI not configured" @message="This PKI mount hasn't yet been configured with a certificate issuer.">
<LinkTo @route="configuration.create.index" @model={{this.model.certificateModel}}>
<LinkTo @route="configuration.create">
{{! ARG TODO if configuration of engine not setup then direct toward setting that up otherwise replace with new design language }}
</LinkTo>
</EmptyState>
Expand Down
1 change: 1 addition & 0 deletions ui/lib/pki/addon/templates/configuration/create.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route: pki.configuration.create

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion ui/lib/pki/addon/templates/configuration/details.hbs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route: issuers.generate-intermediate
1 change: 1 addition & 0 deletions ui/lib/pki/addon/templates/issuers/generate-root.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route: issuers.generate-root
2 changes: 2 additions & 0 deletions ui/lib/pki/addon/templates/issuers/import.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
{{! https://github.com/hashicorp/vault/blob/main/website/content/api-docs/secret/pki.mdx#import-ca-certificates-and-keys }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooh the documentation right in the route stub! I love it!

route: issuers.import POST /pki/issuers/import/bundle POST /pki/issuers/import/cert
8 changes: 4 additions & 4 deletions ui/lib/pki/addon/templates/issuers/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/>
<Toolbar>
<ToolbarActions>
<ToolbarLink @route="configuration.create.import-ca">
<ToolbarLink @route="issuers.import">
Import
</ToolbarLink>
<BasicDropdown @class="popup-menu" @horizontalPosition="auto-right" @verticalPosition="below" as |D|>
Expand All @@ -22,12 +22,12 @@
<nav class="box menu" aria-label="generate options">
<ul class="menu-list">
<li class="action">
<LinkTo @route="configuration.create.generate-root" {{on "click" (fn this.onLinkClick D)}}>
<LinkTo @route="issuers.generate-root" {{on "click" (fn this.onLinkClick D)}}>

Check warning

Code scanning / Semgrep Scanner

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".
Root
</LinkTo>
</li>
<li class="action">
<LinkTo @route="configuration.create.generate-csr" {{on "click" (fn this.onLinkClick D)}}>
<LinkTo @route="issuers.generate-intermediate" {{on "click" (fn this.onLinkClick D)}}>

Check warning

Code scanning / Semgrep Scanner

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".

Detected a unquoted template variable as an attribute. If unquoted, a malicious actor could inject custom JavaScript handlers. To fix this, add quotes around the template expression, like this: "{{ expr }}".
Intermediate CSR
</LinkTo>
</li>
Expand Down Expand Up @@ -82,7 +82,7 @@
{{/each}}
{{else}}
<EmptyState @title="PKI not configured" @message="This PKI mount hasn’t yet been configured with a certificate issuer.">
<LinkTo @route="configuration.create.index" @model={{this.model.issuersModel}}>
<LinkTo @route="configuration.create">
Configure PKI
</LinkTo>
</EmptyState>
Expand Down
1 change: 1 addition & 0 deletions ui/lib/pki/addon/templates/issuers/issuer/cross-sign.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route: issuers.issuer.cross-sign
1 change: 1 addition & 0 deletions ui/lib/pki/addon/templates/issuers/issuer/details.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route: issuers.issuer.details
1 change: 1 addition & 0 deletions ui/lib/pki/addon/templates/issuers/issuer/edit.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route: issuers.issuer.edit
1 change: 1 addition & 0 deletions ui/lib/pki/addon/templates/issuers/issuer/sign.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route: issuers.issuer.sign
4 changes: 2 additions & 2 deletions ui/lib/pki/addon/templates/keys/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<ToolbarLink @route="keys.import" @type="download">
Import
</ToolbarLink>
<ToolbarLink @route="keys.generate" @type="add">
<ToolbarLink @route="keys.create" @type="add">
Generate
</ToolbarLink>
</ToolbarActions>
Expand Down Expand Up @@ -63,7 +63,7 @@
{{/each}}
{{else}}
<EmptyState @title="PKI not configured" @message="This PKI mount hasn’t yet been configured with a certificate issuer.">
<LinkTo @route="configuration.create.index" @model={{this.model.keyModel}}>
<LinkTo @route="configuration.create">
ARG TODO waiting for language from design
</LinkTo>
</EmptyState>
Expand Down
4 changes: 2 additions & 2 deletions ui/lib/pki/addon/templates/overview.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
/>
<Toolbar>
<ToolbarActions>
<ToolbarLink @route="configuration.create.index">
<ToolbarLink @route="configuration.create">
Configure PKI
</ToolbarLink>
</ToolbarActions>
</Toolbar>

<EmptyState @title="PKI not configured" @message="This PKI mount hasn’t yet been configured with a certificate issuer.">
<LinkTo @route="configuration.create.index" @model={{this.model}}>
<LinkTo @route="configuration.create" @model={{this.model}}>
Configure PKI
</LinkTo>
</EmptyState>
2 changes: 1 addition & 1 deletion ui/lib/pki/addon/templates/roles/create.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<RoleForm
<PkiRoleForm
@model={{this.model}}
@onCancel={{transition-to "vault.cluster.secrets.backend.pki.roles.index"}}
@onSave={{transition-to "vault.cluster.secrets.backend.pki.roles.role.details" this.model.id}}
Expand Down
1 change: 1 addition & 0 deletions ui/lib/pki/addon/templates/roles/role/generate.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
route: roles.role.generate
Loading