Use SCOPE_ANY everywhere

This commit is contained in:
Girish Ramakrishnan
2018-04-30 21:44:24 -07:00
parent e7c8791356
commit 61d803f528
5 changed files with 18 additions and 14 deletions

View File

@@ -40,7 +40,7 @@ function validateScope(scope) {
exports.SCOPE_DOMAIN,
exports.SCOPE_CLIENTS,
exports.SCOPE_MAIL,
'*', // includes all scopes, but not roles
exports.SCOPE_ANY, // includes all scopes, but not roles
exports.SCOPE_ROLE_SDK
];
@@ -66,7 +66,7 @@ function validateRequestedScopes(authInfo, requestedScopes) {
return new Error('Missing required scope role "' + exports.SCOPE_ROLE_SDK + '"');
}
if (scopes.indexOf('*') !== -1) return null;
if (scopes.indexOf(exports.SCOPE_ANY) !== -1) return null;
for (var i = 0; i < requestedScopes.length; ++i) {
if (scopes.indexOf(requestedScopes[i]) === -1) {
@@ -82,7 +82,7 @@ function normalizeScope(maxScope, allowedScope) {
assert.strictEqual(typeof maxScope, 'string');
assert.strictEqual(typeof allowedScope, 'string');
if (maxScope === '*') return allowedScope;
if (maxScope === exports.SCOPE_ANY) return allowedScope;
return _.intersection(maxScope.split(','), allowedScope.split(',')).join(',');
}