hardeing changes and UAT tweaks
This commit is contained in:
@@ -52,13 +52,18 @@ const getSASToken = () => {
|
||||
function checkProxyPath(queryPath) {
|
||||
const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY;
|
||||
|
||||
var hashPath =
|
||||
queryPath.indexOf("/api/proxy/") == -1
|
||||
? queryPath
|
||||
: queryPath.split("/api/proxy/")[1];
|
||||
|
||||
const wordKey = WORDKEY;
|
||||
var hashlink = CryptoJS.HmacSHA256(
|
||||
decodeURI(queryPath),
|
||||
decodeURI(hashPath),
|
||||
CryptoJS.enc.Hex.parse(wordKey)
|
||||
);
|
||||
|
||||
hashlink = hashlink.toString();
|
||||
hashlink = hashlink.toString(CryptoJS.enc.Hex);
|
||||
|
||||
return hashlink;
|
||||
}
|
||||
@@ -66,13 +71,24 @@ function checkProxyPath(queryPath) {
|
||||
export default async function ApiProxy(req, res) {
|
||||
var data = JSON.stringify(req.body);
|
||||
const SASToken = getSASToken();
|
||||
const isDocument = req.url.indexOf("/documents/download") > -1;
|
||||
|
||||
let hashCheckPath = isDocument
|
||||
? req.url.split("?hash=")[0]
|
||||
: req.url.split("&hash=")[0];
|
||||
let hashCheckValue = isDocument
|
||||
? req.url.split("?hash=")[1]
|
||||
: req.url.split("&hash=")[1];
|
||||
let hashFromRequest = checkProxyPath(hashCheckPath);
|
||||
|
||||
var configNoData = {
|
||||
method: req.method,
|
||||
//url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")",
|
||||
url:
|
||||
PROXY_RELAY_URL +
|
||||
req.url.split("&hash=")[0].split("/api/proxy/")[1],
|
||||
req.url.split("&hash=")[0].split("/api/proxy/")[1] +
|
||||
"&hash=" +
|
||||
req.url.split("&hash=")[1],
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -86,7 +102,11 @@ export default async function ApiProxy(req, res) {
|
||||
|
||||
var config = {
|
||||
method: req.method,
|
||||
url: PROXY_RELAY_URL + req.query.route[0],
|
||||
url:
|
||||
PROXY_RELAY_URL +
|
||||
req.query.route[0] +
|
||||
"&hash=" +
|
||||
req.url.split("&hash=")[1],
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -102,7 +122,9 @@ export default async function ApiProxy(req, res) {
|
||||
method: req.method,
|
||||
url:
|
||||
PROXY_RELAY_URL +
|
||||
req.url.split("&hash=")[0].split("/api/proxy/")[1],
|
||||
req.url.split("?hash=")[0].split("/api/proxy/")[1] +
|
||||
"?hash=" +
|
||||
req.url.split("?hash=")[1],
|
||||
headers: {
|
||||
"OData-MaxVersion": "4.0",
|
||||
"OData-Version": "4.0",
|
||||
@@ -114,10 +136,6 @@ export default async function ApiProxy(req, res) {
|
||||
responseType: "arraybuffer",
|
||||
};
|
||||
|
||||
let hashCheckPath = req.url.split("&hash=")[0];
|
||||
let hashCheckValue = req.url.split("&hash=")[1];
|
||||
let hashFromRequest = checkProxyPath(hashCheckPath);
|
||||
|
||||
if (hashCheckValue == hashFromRequest) {
|
||||
return new Promise((resolve, reject) => {
|
||||
let hasDocument =
|
||||
|
||||
Reference in New Issue
Block a user