Skip to content

Commit

Permalink
feature/NRLF-658-enable-s3-auth-2 Added authorization logic to Connec…
Browse files Browse the repository at this point in the history
…tionmetadata
  • Loading branch information
Rowan Gill authored and Chris Kemp committed Aug 10, 2023
1 parent 85166fe commit 923ca78
Showing 1 changed file with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,40 @@
return;
}

// Read the associated `nrl-ods-<ods_code>` custom attribute from the APIGEE app
var nrlPointerTypes = context.getVariable('app.nrl-ods-' + odsCode);
if (!nrlPointerTypes) {
//This will trigger RaiseFault.403NoPointers.xml - see targets/target.xml
return;
}

// Convert it into a complex object
var lines = nrlPointerTypes.split(/\s+/);
var enableAuthorizationLookup = context.getVariable("app.enable-authorization-lookup");

if(enableAuthorizationLookup == "true") {
enableAuthorizationLookup = true
} else if (enableAuthorizationLookup === null) {
enableAuthorizationLookup = false
} else {
//This will trigger RaiseFault.403NoPointers.xml - see targets/target.xml
return;
}


var pointerTypes = [];
for (var i=0;i<lines.length;i++) {
// Read the associated `nrl-ods-<ods_code>` custom attribute from the APIGEE app
var nrlPointerTypes = context.getVariable("app.nrl-ods-" + odsCode);

if ((enableAuthorizationLookup === true && nrlPointerTypes) || (enableAuthorizationLookup === false && !nrlPointerTypes)) {
//This will trigger RaiseFault.403NoPointers.xml - see targets/target.xml
return;
}

if (nrlPointerTypes){
// Convert it into a complex object
var lines = nrlPointerTypes.split(/\s+/);

for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (line && line.trim().length !== 0) {
pointerTypes.push(line);
pointerTypes.push(line);
}
}
}
}


var odsCodeExtension = context.getVariable(
"request.header.NHSD-End-User-Organisation"
Expand Down

0 comments on commit 923ca78

Please sign in to comment.