diff --git a/red/api/auth/index.js b/red/api/auth/index.js index 1152ce76e..10ecac7ac 100644 --- a/red/api/auth/index.js +++ b/red/api/auth/index.js @@ -56,7 +56,7 @@ function needsPermission(permission) { if (permissions.hasPermission(req.authInfo.scope,permission)) { return next(); } - log.audit({event: "permission.fail"},req); + log.audit({event: "permission.fail", permissions: permission},req); return res.status(401).end(); }); } else { diff --git a/red/api/auth/permissions.js b/red/api/auth/permissions.js index 4e1862cd9..362acb232 100644 --- a/red/api/auth/permissions.js +++ b/red/api/auth/permissions.js @@ -1,5 +1,5 @@ /** - * Copyright 2015 IBM Corp. + * Copyright 2015, 2016 IBM Corp. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,41 +20,44 @@ var readRE = /^((.+)\.)?read$/ var writeRE = /^((.+)\.)?write$/ function hasPermission(userScope,permission) { - var i; - if (util.isArray(userScope)) { - if (userScope.length === 0) { - return false; - } - for (i=0;i