UI/okta duo push notification (#11442)

* initial setup

* add delay and modify message

* test

* changing to different style because unable to interrupt the yield of authentication

* cleanup

* more consitency in messssage placement

* fix test

* clean up test notification

* clean up

* remove click

* changelog

* Update 11442.txt

* revert changes so a message is delayed by not calling yield

* amend test

* remove padding-bottom as no longer needed with reposition of message location
This commit is contained in:
Angel Garbarino 2021-05-06 12:29:39 -06:00 committed by GitHub
parent 977b6e3bbb
commit 7012aab272
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 66 additions and 11 deletions

3
changelog/11442.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
ui: Add push notification message when selecting okta auth.
```

View File

@ -1,3 +1,4 @@
import Ember from 'ember';
import { next } from '@ember/runloop'; import { next } from '@ember/runloop';
import { inject as service } from '@ember/service'; import { inject as service } from '@ember/service';
import { match, alias, or } from '@ember/object/computed'; import { match, alias, or } from '@ember/object/computed';
@ -6,7 +7,7 @@ import { dasherize } from '@ember/string';
import Component from '@ember/component'; import Component from '@ember/component';
import { computed } from '@ember/object'; import { computed } from '@ember/object';
import { supportedAuthBackends } from 'vault/helpers/supported-auth-backends'; import { supportedAuthBackends } from 'vault/helpers/supported-auth-backends';
import { task } from 'ember-concurrency'; import { task, timeout } from 'ember-concurrency';
const BACKENDS = supportedAuthBackends(); const BACKENDS = supportedAuthBackends();
/** /**
@ -208,6 +209,9 @@ export default Component.extend(DEFAULTS, {
authenticate: task(function*(backendType, data) { authenticate: task(function*(backendType, data) {
let clusterId = this.cluster.id; let clusterId = this.cluster.id;
try { try {
if (backendType === 'okta') {
this.delayAuthMessageReminder.perform();
}
let authResponse = yield this.auth.authenticate({ clusterId, backend: backendType, data }); let authResponse = yield this.auth.authenticate({ clusterId, backend: backendType, data });
let { isRoot, namespace } = authResponse; let { isRoot, namespace } = authResponse;
@ -235,6 +239,15 @@ export default Component.extend(DEFAULTS, {
} }
}).withTestWaiter(), }).withTestWaiter(),
delayAuthMessageReminder: task(function*() {
if (Ember.testing) {
this.showLoading = true;
yield timeout(0);
return;
}
yield timeout(5000);
}),
actions: { actions: {
doSubmit() { doSubmit() {
let passedData, e; let passedData, e;

View File

@ -119,6 +119,14 @@
&.has-top { &.has-top {
margin-top: 1rem; margin-top: 1rem;
} }
&.size-small {
font-size: $size-7;
}
&.padding-top {
padding-top: $size-8;
}
} }
.has-text-highlight { .has-text-highlight {

View File

@ -19,7 +19,12 @@
oninput={{action @onPathChange value="target.value"}} oninput={{action @onPathChange value="target.value"}}
/> />
</div> </div>
<AlertInline @type="info" @message="If this backend was mounted using a non-default path, enter it here." /> <AlertInline
@sizeSmall=true
@paddingTop=true
@type="info"
@message="If this backend was mounted using a non-default path, enter it here."
/>
</div> </div>
{{/if}} {{/if}}
</div> </div>

View File

@ -1,9 +1,4 @@
<div class="auth-form"> <div class="auth-form">
{{#if showLoading}}
<div class="vault-loader">
<VaultLogoSpinner />
</div>
{{/if}}
{{#if hasMethodsWithPath}} {{#if hasMethodsWithPath}}
<nav class="tabs is-marginless"> <nav class="tabs is-marginless">
<ul> <ul>
@ -80,6 +75,15 @@
<button data-test-auth-submit=true type="submit" disabled={{authenticate.isRunning}} class="button is-primary {{if authenticate.isRunning 'is-loading'}}" id="auth-submit"> <button data-test-auth-submit=true type="submit" disabled={{authenticate.isRunning}} class="button is-primary {{if authenticate.isRunning 'is-loading'}}" id="auth-submit">
Sign In Sign In
</button> </button>
{{#if (and delayAuthMessageReminder.isIdle showLoading)}}
<AlertInline
@paddingTop=true
@sizeSmall=true
@type="info"
@message="If login takes longer than usual, you may need to check your device for an MFA notification, or contact your administrator if login times out."
data-test-auth-message="push"
/>
{{/if}}
</form> </form>
{{/if}} {{/if}}
</div> </div>

View File

@ -18,7 +18,12 @@
data-test-role data-test-role
/> />
</div> </div>
<AlertInline @type="info" @message="Leave blank to sign in with the default role if one is configured" /> <AlertInline
@sizeSmall=true
@paddingTop=true
@type="info"
@message="Leave blank to sign in with the default role if one is configured"
/>
</div> </div>
{{#unless this.isOIDC}} {{#unless this.isOIDC}}
<div class="field"> <div class="field">

View File

@ -14,6 +14,8 @@ import layout from '../templates/components/alert-inline';
* *
* @param type=null{String} - The alert type. This comes from the message-types helper. * @param type=null{String} - The alert type. This comes from the message-types helper.
* @param [message=null]{String} - The message to display within the alert. * @param [message=null]{String} - The message to display within the alert.
* @param [sizeSmall=false]{Boolean} - Whether or not to display a small font with padding below of alert message.
* @param [paddingTop=false]{Boolean} - Whether or not to add padding above component.
* *
*/ */
@ -21,8 +23,10 @@ export default Component.extend({
layout, layout,
type: null, type: null,
message: null, message: null,
sizeSmall: false,
paddingTop: false,
classNames: ['message-inline'], classNames: ['message-inline'],
classNameBindings: ['sizeSmall:size-small', 'paddingTop:padding-top'],
textClass: computed('type', function() { textClass: computed('type', function() {
if (this.type == 'danger') { if (this.type == 'danger') {

View File

@ -1,7 +1,7 @@
import { module, test } from 'qunit'; import { module, test } from 'qunit';
import { setupApplicationTest } from 'ember-qunit'; import { setupApplicationTest } from 'ember-qunit';
import sinon from 'sinon'; import sinon from 'sinon';
import { currentURL, visit, settled } from '@ember/test-helpers'; import { click, currentURL, visit, settled } from '@ember/test-helpers';
import { supportedAuthBackends } from 'vault/helpers/supported-auth-backends'; import { supportedAuthBackends } from 'vault/helpers/supported-auth-backends';
import authForm from '../pages/components/auth-form'; import authForm from '../pages/components/auth-form';
import jwtForm from '../pages/components/auth-jwt'; import jwtForm from '../pages/components/auth-jwt';
@ -105,4 +105,17 @@ module('Acceptance | auth', function(hooks) {
await visit('/vault/access'); await visit('/vault/access');
assert.dom('[data-test-allow-expiration="true"]').doesNotExist('hides beacon when the api is used again'); assert.dom('[data-test-allow-expiration="true"]').doesNotExist('hides beacon when the api is used again');
}); });
test('it shows the push notification warning only for okta auth method after submit', async function(assert) {
await visit('/vault/auth');
await component.selectMethod('token');
await click('[data-test-auth-submit="true"]');
assert
.dom('[data-test-auth-message="push"]')
.doesNotExist('message is not shown for other authentication methods');
await component.selectMethod('okta');
await click('[data-test-auth-submit="true"]');
assert.dom('[data-test-auth-message="push"]').exists('shows push notification message');
});
}); });