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

MFA method and enforcement list view #15353

Merged
merged 2 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 12 additions & 10 deletions ui/app/adapters/mfa-method.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@ import ApplicationAdapter from './application';
export default class MfaMethodAdapter extends ApplicationAdapter {
namespace = 'v1';

urlForQuery(methodType) {
let baseUrl = this.buildURL() + '/identity/mfa/method';
if (methodType) {
return `${baseUrl}/${methodType}`;
}
return baseUrl;
pathForType() {
return 'identity/mfa/method';
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
}

queryRecord(type, id) {
return this.ajax(this.urlForQuery(type), 'POST', {
queryRecord(store, type, query) {
const { id } = query;
if (!id) {
return;
}
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
const url = this.urlForQuery(query, type.modelName);
return this.ajax(url, 'POST', {
data: {
id,
},
});
}

query() {
return this.ajax(this.urlForQuery(), 'GET', {
query(store, type, query) {
const url = this.urlForQuery(query, type.modelName);
return this.ajax(url, 'GET', {
data: {
list: true,
},
Expand Down
9 changes: 9 additions & 0 deletions ui/app/controllers/vault/cluster/access/mfa/enforcements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Controller from '@ember/controller';

export default class MfaEnforcementListController extends Controller {
queryParams = {
page: 'page',
};

page = 1;
}
3 changes: 0 additions & 3 deletions ui/app/controllers/vault/cluster/access/mfa/index.js

This file was deleted.

9 changes: 9 additions & 0 deletions ui/app/controllers/vault/cluster/access/mfa/methods.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Controller from '@ember/controller';

export default class MfaMethodsListController extends Controller {
queryParams = {
page: 'page',
};

page = 1;
}
8 changes: 6 additions & 2 deletions ui/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ Router.map(function () {
this.route('section', { path: '/:section_name' });
});
this.route('mfa', function () {
// lookup
this.route('index', { path: '/' });
this.route('configure', { path: '/landing' });
this.route('methods', { path: '/' });
this.route('method', { path: '/method/:method_id' }, function () {
this.route('index', { path: '/' });
zofskeez marked this conversation as resolved.
Show resolved Hide resolved
});
this.route('enforcements', { path: '/enforcement-list' });
this.route('enforcement', { path: '/enforcement/:id' });
});
this.route('leases', function () {
// lookup
Expand Down
2 changes: 1 addition & 1 deletion ui/app/routes/vault/cluster/access/mfa/configure.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Route from '@ember/routing/route';

export default class ConfigureRoute extends Route {
export default class MfaConfigureRoute extends Route {
model() {
return {};
}
Expand Down
27 changes: 27 additions & 0 deletions ui/app/routes/vault/cluster/access/mfa/enforcements.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Route from '@ember/routing/route';

export default class MfaEnforcementsRoute extends Route {
queryParams = {
page: {
refreshModel: true,
},
};

model(params) {
return this.store
.lazyPaginatedQuery('mfa-login-enforcement', {
responsePath: 'data.keys',
page: params.page || 1,
})
.catch((err) => {
if (err.httpStatus === 404) {
return [];
} else {
throw err;
}
});
}
setupController(controller, model) {
controller.set('model', model);
}
}
10 changes: 10 additions & 0 deletions ui/app/routes/vault/cluster/access/mfa/method.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import Route from '@ember/routing/route';

export default class MfaMethodRoute extends Route {
model(params) {
return this.store.findRecord('mfa-method', params['method_id']);
}
setupController(controller, model) {
controller.set('model', model);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class MfaRoute extends Route {
export default class MfaMethodsRoute extends Route {
@service router;

queryParams = {
Expand Down
12 changes: 12 additions & 0 deletions ui/app/templates/components/mfa/nav.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="tabs-container box is-sideless is-fullwidth is-paddingless is-marginless">
<nav class="tabs">
<ul>
<LinkTo @route="vault.cluster.access.mfa.methods">
Methods
</LinkTo>
<LinkTo @route="vault.cluster.access.mfa.enforcements">
Enforcements
</LinkTo>
</ul>
</nav>
</div>
40 changes: 40 additions & 0 deletions ui/app/templates/vault/cluster/access/mfa/enforcements.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<PageHeader as |p|>
<p.levelLeft>
<h1 class="title is-3">
Multi-factor Authentication
</h1>
</p.levelLeft>
</PageHeader>

<Mfa::Nav />

<Toolbar>
<ToolbarActions>
<ToolbarLink @type="add" @params={{array "vault.cluster.access.mfa.configure"}}>
New enforcement
</ToolbarLink>
</ToolbarActions>
</Toolbar>

{{#if this.model.meta.total}}
{{#each this.model as |item|}}
<LinkedBlock class="list-item-row" @params={{array "vault.cluster.access.mfa.enforcement" item.id}}>
<div class="level is-mobile">
<div class="level-left">
<div>
<span class="has-text-weight-semibold has-text-black">
{{item.name}}
</span>
</div>
</div>
</div>
</LinkedBlock>
{{/each}}
{{/if}}
{{#if (gt this.model.meta.lastPage 1)}}
<ListPagination
@page={{this.model.meta.currentPage}}
@lastPage={{this.model.meta.lastPage}}
@link={{concat "vault.cluster.access.mfa.enforcements"}}
/>
{{/if}}
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<PageHeader as |p|>
<p.levelLeft>
<h1 class="title is-3">
Multi-factor Authentication
{{this.model.type}}
</h1>
</p.levelLeft>
</PageHeader>

List view
<Toolbar>
<ToolbarActions />
</Toolbar>

{{this.model.id}}
45 changes: 45 additions & 0 deletions ui/app/templates/vault/cluster/access/mfa/methods.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<PageHeader as |p|>
<p.levelLeft>
<h1 class="title is-3">
Multi-factor Authentication
</h1>
</p.levelLeft>
</PageHeader>

<Mfa::Nav />

<Toolbar>
<ToolbarActions>
<ToolbarLink @type="add" @params={{array "vault.cluster.access.mfa.configure"}}>
New MFA method
</ToolbarLink>
</ToolbarActions>
</Toolbar>

{{#if this.model.meta.total}}
{{#each this.model as |item|}}
<LinkedBlock class="list-item-row" @params={{array "vault.cluster.access.mfa.method" item.id}}>
<div class="level is-mobile">
<div class="level-left">
<div>
<span class="has-text-weight-semibold has-text-black">
<Icon @size="24" @name={{item.type}} />
{{item.type}}
</span>
<br />
<code class="has-text-grey is-size-8">
{{item.id}}
</code>
</div>
</div>
</div>
</LinkedBlock>
{{/each}}
{{/if}}
{{#if (gt this.model.meta.lastPage 1)}}
<ListPagination
@page={{this.model.meta.currentPage}}
@lastPage={{this.model.meta.lastPage}}
@link={{concat "vault.cluster.access.mfa.methods"}}
/>
{{/if}}
2 changes: 2 additions & 0 deletions ui/lib/core/icon-mappings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export const localIconMap = {
radius: 'user',
ssh: 'terminal-screen',
totp: 'history',
duo: null,
pingid: null,
transit: 'swap-horizontal',
userpass: 'identity-user',
stopwatch: 'clock',
Expand Down
5 changes: 5 additions & 0 deletions ui/public/duo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions ui/public/okta.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions ui/public/pingid.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.