Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/src/Authentication/Type/OIDC.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ private function getUser($token)
global $sso_user_key;

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->getProviderConfig()->userinfo_endpoint);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $token));
curl_setopt($ch, CURLOPT_URL, $this->getProviderConfig()->introspection_endpoint);
curl_setopt($ch, CURLOPT_POSTFIELDS, array('token' => $token));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Basic ' . $this->getProviderConfig()->b64ClientCreds));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
Expand Down
2 changes: 1 addition & 1 deletion api/src/Controllers/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private function checkAuthRequiredForSpecificSituations($parts): bool
($parts[0] == 'shipment' && $parts[1] == 'containers' && $parts[2] == 'history' && in_array($_SERVER["REMOTE_ADDR"], $bcr)) ||

# Allow shipping service to update dewar status
($parts[0] == 'shipment' && $parts[1] == 'dewars' && ($parts[2] == 'confirmdispatch' || $parts[2] == 'confirmpickup'))
($parts[0] == 'shipment' && $parts[1] == 'dewars' && $parts[2] == 'confirm')
)
{
$need_auth = false;
Expand Down
51 changes: 37 additions & 14 deletions api/src/Page/Shipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class Shipment extends Page
'PROPOSALTYPE' => '\w+',
'pickup_confirmation_code' => '\w+',
'status' => '\w+',
'journey_type' => '\w+',

'manifest' => '\d',
'currentuser' => '\d',
Expand Down Expand Up @@ -210,8 +211,7 @@ class Shipment extends Page

array('/dewars/transfer', 'post', '_transfer_dewar'),
array('/dewars/dispatch', 'post', '_dispatch_dewar'),
array('/dewars/confirmdispatch/did/:did/token/:TOKEN', 'post', '_outgoing_shipment_confirmation'),
array('/dewars/confirmpickup/sid/:sid/token/:TOKEN', 'post', '_incoming_shipment_confirmation'),
array('/dewars/confirm/did/:did/token/:TOKEN', 'post', '_shipment_confirmation'),

array('/dewars/tracking(/:DEWARID)', 'get', '_get_dewar_tracking'),

Expand Down Expand Up @@ -1109,7 +1109,7 @@ function _dispatch_dewar_shipment_request($dewar)
array($token, $external_id)
);

$callback_url = "/api/shipment/dewars/confirmdispatch/did/{$external_id}/token/{$token}";
$callback_url = "/api/shipment/dewars/confirm/did/{$external_id}/token/{$token}";
$external_shipping_id = $this->_create_dewars_shipment_request($dewars, $proposal, $session_number, $external_id, $shipping_id, $callback_url);

$this->db->pq(
Expand Down Expand Up @@ -1403,15 +1403,43 @@ function _dispatch_dewar()
}
}

function _outgoing_shipment_confirmation()
function _shipment_confirmation()
{
if (!$this->has_arg('journey_type'))
$this->_error('No journey type specified');
if (!$this->has_arg('did'))
$this->_error('No dewar specified');
if (!$this->has_arg('TOKEN'))
$this->_error('No token specified');
if (!$this->has_arg('status'))
$this->_error('No status specified');

$dew = $this->db->pq(
"SELECT d.shippingid,
json_unquote(json_extract(d.extra, '$.token')) as token
FROM dewar d
WHERE d.dewarid=:1",
array($this->arg('did'))
);
if (!sizeof($dew))
$this->_error('No such dewar');
else
$dew = $dew[0];

if (!$this->has_arg('TOKEN') || $this->arg('TOKEN') !== $dew['TOKEN']) {
$this->_error('Incorrect token');
}

if ($this->arg('journey_type') === 'TO_FACILITY') {
$this->set_arg('sid', $dew['SHIPPINGID']);
$this->_incoming_shipment_confirmation();
} else if ($this->arg('journey_type') === 'FROM_FACILITY') {
$this->_outgoing_shipment_confirmation();
} else {
$this->_error('Invalid journey type');
}
}

function _outgoing_shipment_confirmation()
{
if ($this->arg('status') === 'CREATED') {
$this->_cancel_dispatch_dewar_confirmation();
} else if ($this->arg('status') === 'BOOKED' || $this->arg('status') === 'PENDING') {
Expand Down Expand Up @@ -1563,13 +1591,6 @@ function _cancel_dispatch_dewar_confirmation()

function _incoming_shipment_confirmation()
{
if (!$this->has_arg('sid'))
$this->_error('No shipment specified');
if (!$this->has_arg('TOKEN'))
$this->_error('No token specified');
if (!$this->has_arg('status'))
$this->_error('No status specified');

if ($this->arg('status') === 'CREATED') {
$this->_cancel_pickup_dewar_confirmation();
} else if ($this->arg('status') === 'BOOKED' || $this->arg('status') === 'PENDING') {
Expand Down Expand Up @@ -3514,14 +3535,16 @@ function _create_shipment_shipment_request($shipment, array $dewars): int
{

$shipping_id = (int) $shipment['SHIPPINGID'];
// Any dewar id is ok for callback as it will be converted back to a shipping id
$dewar_id = (int) $dewars[0]['DEWARID'];

$token = Utils::generateRandomMd5(7);
$this->db->pq(
"UPDATE dewar SET extra = JSON_SET(IFNULL(extra, '{}'), '$.token', :1 ) WHERE shippingid=:2",
array($token, $shipping_id)
);

$callback_url = "/api/shipment/dewars/confirmpickup/sid/{$shipping_id}/token/{$token}";
$callback_url = "/api/shipment/dewars/confirm/did/{$dewar_id}/token/{$token}";

$external_shipping_id = $this->_create_dewars_shipment_request(
$dewars,
Expand Down
15 changes: 15 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"backgrid": "0.3.8",
"backgrid-paginator": "0.3.9",
"backgrid-select-all": "0.3.5",
"caman-dist-only": "^4.1.3",
"ci": "^2.2.0",
"csv-file-validator": "^2.2.0",
"d3-scale": "^4.0.2",
Expand All @@ -73,6 +74,7 @@
"flot-axislabels": "^1.0.0",
"flot-pie": "^1.0.0",
"font-awesome": "^4.2.0",
"heatmap.js": "^2.0.5",
"jquery": "^1.12.4",
"jquery-color": "^3.0.0-alpha.1",
"jquery-flot-resize": "^1.0.0",
Expand Down
6 changes: 3 additions & 3 deletions client/src/js/modules/dc/views/gridplot.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ define(['jquery', 'marionette',
'utils/canvas',
'modules/dc/views/viridis',
'templates/dc/gridplot.html',
'heatmap',
'heatmap.js',
'utils',
'utils/xhrimage',
'jquery-ui',
Expand Down Expand Up @@ -489,8 +489,8 @@ define(['jquery', 'marionette',

// Dont zero values < 1 if data is scaled to max==1
data.push({
x: x,
y: y,
x: Math.round(x),
y: Math.round(y),
value: val < 1 && max > 1 ? 0 : val,
radius: radius
})
Expand Down
6 changes: 3 additions & 3 deletions client/src/js/modules/dc/views/imageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ define(['jquery', 'marionette',
'utils/canvas',
'templates/dc/imageviewer.html',
'templates/dc/imageviewer_embedded.html',
'caman',
'caman-dist-only',
'utils',
'utils/xhrimage',
'jquery-ui/ui/widgets/progressbar'
], function($, Marionette, CanvasMixin, template, embed, caman, utils, XHRImage) {

const Caman = window.Caman

// Note we do not import the caman libray as Caman.
// This is because Caman is added to the window global object
return Marionette.ItemView.extend(_.extend({}, CanvasMixin, {
className: function() {
return 'content' + (this.getOption('embed') ? ' embed' : '')
Expand Down
2 changes: 1 addition & 1 deletion client/src/js/modules/imaging/views/imageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define(['marionette',
'utils/editable',
'utils',
'utils/xhrimage',
'heatmap',
'heatmap.js',
'templates/imaging/imageviewer.html',
'backbone-validation',
], function(Marionette,
Expand Down
Loading
Loading