From 0762da3a629a6b50f887d5e6a3f440cdd99e5b52 Mon Sep 17 00:00:00 2001 From: John Cowen Date: Thu, 15 Jul 2021 12:19:07 +0100 Subject: [PATCH] ui: [BUGFIX] Ensure we use the ns query param name when requesting permissions (#10608) Previously when namespaces were enabled, we weren't requesting permission for the actively selected namespace, and instead always checking the permissions for the default namespace. This commit ensures we request permissions for the actively selected namespace. --- .changelog/10608.txt | 3 +++ ui/packages/consul-ui/app/adapters/permission.js | 2 +- ui/packages/consul-ui/app/routes/dc.js | 2 +- ui/packages/consul-ui/app/routes/settings.js | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 .changelog/10608.txt diff --git a/.changelog/10608.txt b/.changelog/10608.txt new file mode 100644 index 0000000000..4e189257a4 --- /dev/null +++ b/.changelog/10608.txt @@ -0,0 +1,3 @@ +```release-note:bug +ui: **(Enterprise only)** Ensure permissions are checked based on the actively selected namespace +``` diff --git a/ui/packages/consul-ui/app/adapters/permission.js b/ui/packages/consul-ui/app/adapters/permission.js index dcd357ae29..ee3a2110d4 100644 --- a/ui/packages/consul-ui/app/adapters/permission.js +++ b/ui/packages/consul-ui/app/adapters/permission.js @@ -7,7 +7,7 @@ export default class PermissionAdapter extends Adapter { requestForAuthorize(request, { dc, ns, resources = [], index }) { // the authorize endpoint is slightly different to all others in that it // ignores an ns parameter, but accepts a Namespace property on each - // resource. Here we hide this different from the rest of the app as + // resource. Here we hide this difference from the rest of the app as // currently we never need to ask for permissions/resources for multiple // different namespaces in one call so here we use the ns param and add // this to the resources instead of passing through on the queryParameter diff --git a/ui/packages/consul-ui/app/routes/dc.js b/ui/packages/consul-ui/app/routes/dc.js index 588fd296cc..e915478b74 100644 --- a/ui/packages/consul-ui/app/routes/dc.js +++ b/ui/packages/consul-ui/app/routes/dc.js @@ -21,7 +21,7 @@ export default class DcRoute extends Route { // When disabled nspaces is [], so nspace is undefined const permissions = await this.permissionsRepo.findAll({ dc: params.dc, - nspace: get(nspace || {}, 'Name'), + ns: get(nspace || {}, 'Name'), }); // the model here is actually required for the entire application // but we need to wait until we are in this route so we know what the dc diff --git a/ui/packages/consul-ui/app/routes/settings.js b/ui/packages/consul-ui/app/routes/settings.js index 2b7f32f10d..d4cf8372c9 100644 --- a/ui/packages/consul-ui/app/routes/settings.js +++ b/ui/packages/consul-ui/app/routes/settings.js @@ -28,7 +28,7 @@ export default class SettingsRoute extends Route { typeof app.permissions === 'undefined' ? await this.permissionsRepo.findAll({ dc: dc.Name, - nspace: nspace.Name, + ns: nspace.Name, }) : app.permissions;