diff --git a/ui/app/services/permissions.js b/ui/app/services/permissions.js index afbcd46a8965..612de50610aa 100644 --- a/ui/app/services/permissions.js +++ b/ui/app/services/permissions.js @@ -138,7 +138,9 @@ export default Service.extend({ hasMatchingGlobPath(pathName, capability) { const globPaths = this.get('globPaths'); if (globPaths) { - const matchingPath = Object.keys(globPaths).find(k => pathName.includes(k)); + const matchingPath = Object.keys(globPaths).find(k => { + return pathName.includes(k) || pathName.includes(k.replace(/\/$/, '')); + }); const hasMatchingPath = (matchingPath && !this.isDenied(globPaths[matchingPath])) || globPaths.hasOwnProperty(''); diff --git a/ui/tests/unit/services/permissions-test.js b/ui/tests/unit/services/permissions-test.js index 0926da44ee77..7359a37a8c68 100644 --- a/ui/tests/unit/services/permissions-test.js +++ b/ui/tests/unit/services/permissions-test.js @@ -20,6 +20,9 @@ const PERMISSIONS_RESPONSE = { 'baz/biz': { capabilities: ['read'], }, + 'ends/in/slash/': { + capabilities: ['list'], + }, }, }, }; @@ -76,6 +79,13 @@ module('Unit | Service | permissions', function(hooks) { assert.equal(service.hasPermission('boo'), false); }); + test('it returns true if passed path does not end in a slash but globPath does', function(assert) { + let service = this.owner.lookup('service:permissions'); + service.set('globPaths', PERMISSIONS_RESPONSE.data.glob_paths); + assert.equal(service.hasPermission('ends/in/slash'), true, 'matches without slash'); + assert.equal(service.hasPermission('ends/in/slash/'), true, 'matches with slash'); + }); + test('it returns false if a policy does not includes access to a path', function(assert) { let service = this.owner.lookup('service:permissions'); assert.equal(service.hasPermission('danger'), false);