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

Logout with wrapped token #14329

Merged
merged 2 commits into from
Mar 2, 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
3 changes: 3 additions & 0 deletions changelog/14329.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Fixes issue logging out with wrapped token query parameter
```
18 changes: 10 additions & 8 deletions ui/app/routes/vault/cluster/logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ export default Route.extend(ModelBoundaryRoute, {
console: service(),
permissions: service(),
namespaceService: service('namespace'),
router: service(),

modelTypes: computed(function () {
return ['secret', 'secret-engine'];
}),

beforeModel() {
beforeModel({ to: { queryParams } }) {
const authType = this.auth.getAuthType();
const baseUrl = window.location.origin;
const ns = this.namespaceService.path;
this.auth.deleteCurrentToken();
this.controlGroup.deleteTokens();
Expand All @@ -27,15 +27,17 @@ export default Route.extend(ModelBoundaryRoute, {
this.console.clearLog(true);
this.flashMessages.clearMessages();
this.permissions.reset();

queryParams.with = authType;
if (ns) {
queryParams.namespace = ns;
}
if (Ember.testing) {
// Don't redirect on the test
this.replaceWith('vault.cluster.auth', { queryParams: { with: authType } });
this.replaceWith('vault.cluster.auth', { queryParams });
} else {
let params = `?with=${authType}`;
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if you have a namespace with a query param for a wrapped token?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the auth-form component, if wrappedToken is provided it will automatically attempt to unseal the token and if successful it preforms the same action as if the form has been filled out and the user hits submit manually. If a namespace is present in the query param it should behave as if the user selected one in the dropdown.

if (ns) {
params = `${params}&namespace=${ns}`;
}
location.assign(`${baseUrl}/ui/vault/auth${params}`);
const { cluster_name } = this.paramsFor('vault.cluster');
location.assign(this.router.urlFor('vault.cluster.auth', cluster_name, { queryParams }));
}
},
});