From f7d3dfdac0e7f5cd33315e67aeaaf17770174a29 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 8 Sep 2021 13:40:18 -0400 Subject: [PATCH 1/8] chore: remove redundant text --- ui/admin/app/templates/scopes/scope/groups/index.hbs | 1 - 1 file changed, 1 deletion(-) diff --git a/ui/admin/app/templates/scopes/scope/groups/index.hbs b/ui/admin/app/templates/scopes/scope/groups/index.hbs index 1e5f038db..2026ac1c5 100644 --- a/ui/admin/app/templates/scopes/scope/groups/index.hbs +++ b/ui/admin/app/templates/scopes/scope/groups/index.hbs @@ -71,7 +71,6 @@ as |message| > - {{t 'resources.group.description'}} {{#if (can 'list collection' this.scope collection='groups')}} {{! can list (at least): show default welcome message}} {{t 'resources.group.description'}} From c462fa4c512fabd3879500ed9b3c1505d5a060d2 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 8 Sep 2021 13:52:51 -0400 Subject: [PATCH 2/8] =?UTF-8?q?fix:=20=F0=9F=90=9B=20create-without-read?= =?UTF-8?q?=20case=20should=20redirect=20to=20index?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/app/routes/scopes/scope/groups.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ui/admin/app/routes/scopes/scope/groups.js b/ui/admin/app/routes/scopes/scope/groups.js index 1784799cc..e1346ae4d 100644 --- a/ui/admin/app/routes/scopes/scope/groups.js +++ b/ui/admin/app/routes/scopes/scope/groups.js @@ -57,7 +57,11 @@ export default class ScopesScopeGroupsRoute extends Route { ) async save(group) { await group.save(); - await this.transitionTo('scopes.scope.groups.group', group); + if (this.can.can('read model', group)) { + await this.transitionTo('scopes.scope.groups.group', group); + } else { + await this.transitionTo('scopes.scope.groups'); + } this.refresh(); } From e389494a3b0c27a703aa772dbd960f668f343ee8 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 8 Sep 2021 14:20:04 -0400 Subject: [PATCH 3/8] =?UTF-8?q?chore:=20=F0=9F=A4=96=20redirect=20to=20ind?= =?UTF-8?q?ex=20on=20save=20in=20create-without-read=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scope/auth-methods/auth-method/accounts.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts.js b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts.js index d4e1ab55a..6166ae16b 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods/auth-method/accounts.js @@ -60,10 +60,14 @@ export default class ScopesScopeAuthMethodsAuthMethodAccountsRoute extends Route adapterOptions.password = password; } await account.save({ adapterOptions }); - await this.transitionTo( - 'scopes.scope.auth-methods.auth-method.accounts.account', - account - ); + if (this.can.can('read model', account)) { + await this.transitionTo( + 'scopes.scope.auth-methods.auth-method.accounts.account', + account + ); + } else { + await this.transitionTo('scopes.scope.auth-methods.auth-method.accounts'); + } this.refresh(); } From 92572395bbccc4da2b9c2ab7ce11e20bc5529f34 Mon Sep 17 00:00:00 2001 From: dharini Date: Wed, 8 Sep 2021 11:29:13 -0700 Subject: [PATCH 4/8] =?UTF-8?q?fix:=20=F0=9F=90=9B=20redirect=20to=20index?= =?UTF-8?q?=20on=20save=20without=20read?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/admin/app/routes/scopes/scope/auth-methods.js | 12 ++++++++---- ui/admin/app/routes/scopes/scope/roles.js | 6 +++++- ui/admin/app/routes/scopes/scope/targets.js | 6 +++++- ui/admin/app/routes/scopes/scope/users.js | 6 +++++- 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/ui/admin/app/routes/scopes/scope/auth-methods.js b/ui/admin/app/routes/scopes/scope/auth-methods.js index 938ce6d16..7e4ca740b 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods.js @@ -60,10 +60,14 @@ export default class ScopesScopeAuthMethodsRoute extends Route { ) async save(authMethod) { await authMethod.save(); - await this.transitionTo( - 'scopes.scope.auth-methods.auth-method', - authMethod - ); + if (this.can.can('read model', authMethod)) { + await this.transitionTo( + 'scopes.scope.auth-methods.auth-method', + authMethod + ); + } else { + await this.transitionTo('scopes.scope.auth-method'); + } this.refresh(); } diff --git a/ui/admin/app/routes/scopes/scope/roles.js b/ui/admin/app/routes/scopes/scope/roles.js index cbc1dfcc5..f83c69135 100644 --- a/ui/admin/app/routes/scopes/scope/roles.js +++ b/ui/admin/app/routes/scopes/scope/roles.js @@ -58,7 +58,11 @@ export default class ScopesScopeRolesRoute extends Route { ) async save(role) { await role.save(); - await this.transitionTo('scopes.scope.roles.role', role); + if (this.can.can('read model', role)) { + await this.transitionTo('scopes.scope.roles.role', role); + } else { + await this.transitionTo('scopes.scope.roles'); + } this.refresh(); } diff --git a/ui/admin/app/routes/scopes/scope/targets.js b/ui/admin/app/routes/scopes/scope/targets.js index 2adb5ca84..85a27eab1 100644 --- a/ui/admin/app/routes/scopes/scope/targets.js +++ b/ui/admin/app/routes/scopes/scope/targets.js @@ -60,7 +60,11 @@ export default class ScopesScopeTargetsRoute extends Route { ) async save(target) { await target.save(); - await this.transitionTo('scopes.scope.targets.target', target); + if (this.can.can('read model', target)) { + await this.transitionTo('scopes.scope.targets.target', target); + } else { + await this.transitionTo('scopes.scope.targets'); + } this.refresh(); } diff --git a/ui/admin/app/routes/scopes/scope/users.js b/ui/admin/app/routes/scopes/scope/users.js index aa3dde96a..6512c6aeb 100644 --- a/ui/admin/app/routes/scopes/scope/users.js +++ b/ui/admin/app/routes/scopes/scope/users.js @@ -59,7 +59,11 @@ export default class ScopesScopeUsersRoute extends Route { ) async save(user) { await user.save(); - await this.transitionTo('scopes.scope.users.user', user); + if (this.can.can('read model', user)) { + await this.transitionTo('scopes.scope.users.user', user); + } else { + await this.transitionTo('scopes.scope.users'); + } this.refresh(); } From 8f11765b960cf780ab359fff90eee7e20760bd1a Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 8 Sep 2021 14:31:16 -0400 Subject: [PATCH 5/8] =?UTF-8?q?chore:=20=F0=9F=A4=96=20redirect=20to=20ind?= =?UTF-8?q?ex=20on=20save=20in=20create-without-read=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../credential-store/credential-libraries.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js index 06748f330..d38d9a2f9 100644 --- a/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js +++ b/ui/admin/app/routes/scopes/scope/credential-stores/credential-store/credential-libraries.js @@ -55,10 +55,16 @@ export default class ScopesScopeCredentialStoresCredentialStoreCredentialLibrari ) async save(credentialLibrary) { await credentialLibrary.save(); - await this.transitionTo( - 'scopes.scope.credential-stores.credential-store.credential-libraries.credential-library', - credentialLibrary - ); + if (this.can.can('read model', credentialLibrary)) { + await this.transitionTo( + 'scopes.scope.credential-stores.credential-store.credential-libraries.credential-library', + credentialLibrary + ); + } else { + await this.transitionTo( + 'scopes.scope.credential-stores.credential-store.credential-libraries' + ); + } this.refresh(); } From 557076276b77fe782ad46b4783f168def17e8fed Mon Sep 17 00:00:00 2001 From: Dharini Jeeva Date: Wed, 8 Sep 2021 11:35:47 -0700 Subject: [PATCH 6/8] Update auth-methods.js --- ui/admin/app/routes/scopes/scope/auth-methods.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/admin/app/routes/scopes/scope/auth-methods.js b/ui/admin/app/routes/scopes/scope/auth-methods.js index 7e4ca740b..687c5ef81 100644 --- a/ui/admin/app/routes/scopes/scope/auth-methods.js +++ b/ui/admin/app/routes/scopes/scope/auth-methods.js @@ -66,7 +66,7 @@ export default class ScopesScopeAuthMethodsRoute extends Route { authMethod ); } else { - await this.transitionTo('scopes.scope.auth-method'); + await this.transitionTo('scopes.scope.auth-methods'); } this.refresh(); } From 16e83b742840abd668734647b07a3eb39ff00fe2 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 8 Sep 2021 15:04:23 -0400 Subject: [PATCH 7/8] =?UTF-8?q?chore:=20=F0=9F=A4=96=20redirect=20to=20ind?= =?UTF-8?q?ex=20on=20save=20in=20create-without-read=20case?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../scope/host-catalogs/host-catalog/host-sets.js | 14 ++++++++++---- .../scope/host-catalogs/host-catalog/hosts.js | 12 ++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js index 36d341bc4..d70b5dab0 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/host-sets.js @@ -59,10 +59,16 @@ export default class ScopesScopeHostCatalogsHostCatalogHostSetsRoute extends Rou ) async save(hostSet) { await hostSet.save(); - await this.transitionTo( - 'scopes.scope.host-catalogs.host-catalog.host-sets.host-set', - hostSet - ); + if (this.can.can('read model', hostSet)) { + await this.transitionTo( + 'scopes.scope.host-catalogs.host-catalog.host-sets.host-set', + hostSet + ); + } else { + await this.transitionTo( + 'scopes.scope.host-catalogs.host-catalog.host-sets' + ); + } this.refresh(); } diff --git a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js index 5969a8b67..cb91be6ed 100644 --- a/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js +++ b/ui/admin/app/routes/scopes/scope/host-catalogs/host-catalog/hosts.js @@ -58,10 +58,14 @@ export default class ScopesScopeHostCatalogsHostCatalogHostsRoute extends Route ) async save(host) { await host.save(); - await this.transitionTo( - 'scopes.scope.host-catalogs.host-catalog.hosts.host', - host - ); + if (this.can.can('read model', host)) { + await this.transitionTo( + 'scopes.scope.host-catalogs.host-catalog.hosts.host', + host + ); + } else { + await this.transitionTo('scopes.scope.host-catalogs.host-catalog.hosts'); + } this.refresh(); } From d07407e881dfce1c917d24260904bfc888295f16 Mon Sep 17 00:00:00 2001 From: Randall Morey Date: Wed, 8 Sep 2021 16:03:10 -0400 Subject: [PATCH 8/8] chore: mocks should have scope collection grants --- addons/api/mirage/factories/scope.js | 1 + 1 file changed, 1 insertion(+) diff --git a/addons/api/mirage/factories/scope.js b/addons/api/mirage/factories/scope.js index edd0aeb11..b631c00e0 100644 --- a/addons/api/mirage/factories/scope.js +++ b/addons/api/mirage/factories/scope.js @@ -15,6 +15,7 @@ export default factory.extend({ authorized_collection_actions: () => { return { + scopes: ['create', 'list'], users: ['create', 'list'], sessions: ['list'], groups: ['create', 'list'],