diff --git a/changelog/23277.txt b/changelog/23277.txt new file mode 100644 index 0000000000000..329b3ebc6fb18 --- /dev/null +++ b/changelog/23277.txt @@ -0,0 +1,3 @@ +```release-note:improvement +ui: Add warning message to the namespace picker warning users about the behavior when logging in with a root token. +``` \ No newline at end of file diff --git a/ui/app/components/dashboard/vault-version-title.js b/ui/app/components/dashboard/vault-version-title.js index e117481aea158..1462844740acc 100644 --- a/ui/app/components/dashboard/vault-version-title.js +++ b/ui/app/components/dashboard/vault-version-title.js @@ -25,10 +25,4 @@ export default class DashboardVaultVersionTitle extends Component { ? `Vault v${this.version.version.slice(0, this.version.version.indexOf('+'))}` : `Vault v${this.version.version}`; } - - get namespaceDisplay() { - if (this.namespace.inRootNamespace) return 'root'; - const parts = this.namespace.path?.split('/'); - return parts[parts.length - 1]; - } } diff --git a/ui/app/controllers/vault/cluster/auth.js b/ui/app/controllers/vault/cluster/auth.js index 93b267bf3307f..3d4142ca41aef 100644 --- a/ui/app/controllers/vault/cluster/auth.js +++ b/ui/app/controllers/vault/cluster/auth.js @@ -2,7 +2,6 @@ * Copyright (c) HashiCorp, Inc. * SPDX-License-Identifier: BUSL-1.1 */ - import { inject as service } from '@ember/service'; import { alias } from '@ember/object/computed'; import Controller, { inject as controller } from '@ember/controller'; @@ -67,6 +66,7 @@ export default Controller.extend({ } transition.followRedirects().then(() => { if (isRoot) { + this.auth.set('isRootToken', true); this.flashMessages.warning( 'You have logged in with a root token. As a security precaution, this root token will not be stored by your browser and you will need to re-authenticate after the window is closed or refreshed.' ); diff --git a/ui/app/services/auth.js b/ui/app/services/auth.js index d44b41bfb756d..0c68d63e5ab70 100644 --- a/ui/app/services/auth.js +++ b/ui/app/services/auth.js @@ -36,6 +36,7 @@ export default Service.extend({ expirationCalcTS: null, isRenewing: false, mfaErrors: null, + isRootToken: false, get tokenExpired() { const expiration = this.tokenExpirationDate; diff --git a/ui/app/services/namespace.js b/ui/app/services/namespace.js index 94489d219160b..07802320a0314 100644 --- a/ui/app/services/namespace.js +++ b/ui/app/services/namespace.js @@ -6,6 +6,7 @@ import { alias, equal } from '@ember/object/computed'; import Service, { inject as service } from '@ember/service'; import { task } from 'ember-concurrency'; +import { computed } from '@ember/object'; const ROOT_NAMESPACE = ''; export default Service.extend({ @@ -20,6 +21,13 @@ export default Service.extend({ inRootNamespace: equal('path', ROOT_NAMESPACE), + currentNamespace: computed('inRootNamespace', 'path', function () { + if (this.inRootNamespace) return 'root'; + + const parts = this.path?.split('/'); + return parts[parts.length - 1]; + }), + setNamespace(path) { if (!path) { this.set('path', ''); diff --git a/ui/app/templates/components/dashboard/vault-version-title.hbs b/ui/app/templates/components/dashboard/vault-version-title.hbs index c32fc1f0b96a4..f66454c1ef996 100644 --- a/ui/app/templates/components/dashboard/vault-version-title.hbs +++ b/ui/app/templates/components/dashboard/vault-version-title.hbs @@ -3,7 +3,7 @@

{{this.versionHeader}} {{#if @version.isEnterprise}} - + {{/if}}

diff --git a/ui/app/templates/components/namespace-link.hbs b/ui/app/templates/components/namespace-link.hbs index f4b352df4b070..14f99ced3b049 100644 --- a/ui/app/templates/components/namespace-link.hbs +++ b/ui/app/templates/components/namespace-link.hbs @@ -2,7 +2,6 @@ Copyright (c) HashiCorp, Inc. SPDX-License-Identifier: BUSL-1.1 ~}} -
+ {{#if this.auth.isRootToken}} +
+ + + You are logged in with a root token and will have to reauthenticate when switching namespaces. + +
+ {{/if}} +
{{#unless this.isUserRootNamespace}} {{! Only show license banners for Enterprise }} {{#if this.activeCluster.version.isEnterprise}}