Skip to content

Commit

Permalink
Cleanup stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Mar 12, 2021
1 parent d6a81c0 commit c77d60e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
4 changes: 2 additions & 2 deletions oada/services/http-handler/src/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,11 @@ router.get('/*', async function getResource(req, res, next) {
// get binary
if (req.oadaGraph['path_leftover']) {
req.log.trace(req.oadaGraph['path_leftover']);
throw new OADAError('Path Leftover on Binary GEt');
throw new OADAError('Path Leftover on Binary GET');
}

// Look up file size before streaming
let { integrity, size } = await cacache.get.info(
const { integrity, size } = await cacache.get.info(
CACHE_PATH,
req.oadaGraph['resource_id']
);
Expand Down
27 changes: 9 additions & 18 deletions oada/services/permissions-handler/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,11 @@ additionalScopesFiles.forEach((af) => {
trace('Trying to add additional scope ' + af);
const newscope = require('./scopes/additional-scopes/' + af);
Object.keys(newscope).forEach((k) => {
trace('Setting scopeTypes[' + k + '] to new scope ', newscope[k]);
trace('Setting scopeTypes[%s] to new scope %s', k, newscope[k]);
scopeTypes[k] = newscope[k]; // overwrite entire scope, or create new if doesn't exist
});
} catch (e) {
warn(
'FAILED to require(scopes/additional-scopes/' + af + ': error was %O',
e
);
warn('FAILED to require(scopes/additional-scopes/%s: error was %O', af, e);
}
});

Expand Down Expand Up @@ -92,12 +89,10 @@ responder.on('request', function handleReq(req) {
} else {
// Check for read permission
response.scopes.read = req.scope.some(function chkScope(scope) {
var type;
var perm;
[type, perm] = scope.split(':');
const [type, perm] = scope.split(':');

if (!scopeTypes[type]) {
warn('Unsupported scope type "' + type + '"');
warn('Unsupported scope type "%s"', type);
return false;
}
trace('User scope: %s', type);
Expand All @@ -107,11 +102,9 @@ responder.on('request', function handleReq(req) {
//let contentType = req.requestType === 'put' ? req.contentType : (resource ? resource._type : undefined);
//trace('contentType = ', 'is put:', req.requestType === 'put', 'req.contentType:', req.contentType, 'resource:', resource);
trace(
'Does user have scope?' +
'resulting contentType:' +
contentType +
'typeis check:' +
typeis.is(contentType, scopeTypes[type])
'Does user have scope? resulting contentType: %s typeis check: %s',
contentType,
typeis.is(contentType, scopeTypes[type])
);
trace('Does user have read scope? %s', scopePerm(perm, 'read'));
trace('TYPEIS aaa %s', typeis.is(contentType, scopeTypes[type]));
Expand All @@ -122,12 +115,10 @@ responder.on('request', function handleReq(req) {

// Check for write permission
response.scopes.write = req.scope.some(function chkScope(scope) {
var type;
var perm;
[type, perm] = scope.split(':');
const [type, perm] = scope.split(':');

if (!scopeTypes[type]) {
warn('Unsupported scope type "' + type + '"');
warn('Unsupported scope type "%s"', type);
return false;
}
//let contentType = req.requestType === 'put' ? req.contentType : (resource ? resource._type : undefined);
Expand Down

0 comments on commit c77d60e

Please sign in to comment.