mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-22 15:11:07 +02:00
* change entity_id to camel casing, remove "backends" key from stored auth data * fix tokenExpirationEpoch returning NaN, use authSuccess in auth service tests * camel case mfa_requirement references * refactor auth service * implement api service for token method * implement api service in standard auth methods * add lookupSelf request to persistAuthData method in auht service instead of calling in components * implement api service in oidc-jwt component * implement api service in okta component * implement api service in saml component * use api service for wrapped_token query param * remaining test updates, enterprise tests and stabilize auth helpers * upate renew() to use new persistAuthData method, add a test * revert as this will be addressed upstream * rename supported-login-methods to auth-form-helpers and delete old supported-auth-backends helper, update tests * cleanup normalize after testing mfa validation for each auth method * update type declarations, set displayName in each method component * stabilize redirect tests by waiting for login before asserting url * stabilize tests * modernize typescript syntax, move error const to util * use mirage instead of vault server to resolve test race conditions * fix file import
53 lines
1.2 KiB
JavaScript
53 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { service } from '@ember/service';
|
|
import { later } from '@ember/runloop';
|
|
import { action } from '@ember/object';
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
export default class SidebarUserMenuComponent extends Component {
|
|
@service auth;
|
|
@service currentCluster;
|
|
@service router;
|
|
|
|
@tracked fakeRenew = false;
|
|
|
|
get hasEntityId() {
|
|
// root users will not have an entity_id because they are not associated with an entity.
|
|
// in order to use the MFA end user setup they need an entity_id
|
|
return !!this.auth.authData?.entityId;
|
|
}
|
|
get isUserpass() {
|
|
return this.auth.authData?.authMethodType === 'userpass';
|
|
}
|
|
|
|
get isRenewing() {
|
|
return this.fakeRenew || this.auth.isRenewing;
|
|
}
|
|
|
|
transitionToRoute() {
|
|
this.router.transitionTo(...arguments);
|
|
}
|
|
|
|
@action
|
|
renewToken() {
|
|
this.fakeRenew = true;
|
|
later(() => {
|
|
this.auth.renew().then(() => {
|
|
this.fakeRenew = this.auth.isRenewing;
|
|
});
|
|
}, 200);
|
|
}
|
|
|
|
@action
|
|
revokeToken() {
|
|
this.auth.revokeCurrentToken().then(() => {
|
|
this.transitionToRoute('vault.cluster.logout');
|
|
});
|
|
}
|
|
}
|