hashing function
This commit is contained in:
+5
-2
@@ -33,6 +33,9 @@ I18N_DOMAIN = "cymru.local"
|
|||||||
GOOGLE_TAG_MANAGER = GTM-T78CBC3
|
GOOGLE_TAG_MANAGER = GTM-T78CBC3
|
||||||
SHOWLOGIN = "false"
|
SHOWLOGIN = "false"
|
||||||
SHOWREPRESENTATIONS = "false"
|
SHOWREPRESENTATIONS = "false"
|
||||||
BASIC_AUTH_CREDENTIALS = pinswg:password|pinswg2:password2
|
BASIC_AUTH_CREDENTIALS,, = pinswg:password|pinswg2:password2
|
||||||
|
|
||||||
|
NEXT_PUBLIC_ISHARESECRETPHRASE = "Secret phrase"
|
||||||
|
|
||||||
|
HASHKEY = 028ffbae928d7191c0017f298260995f901d78eabde1436c0af0423459cc3715832136d84f68818d3a96399467b52143e273d4f3bf4ae190848891535421cd6c
|
||||||
|
|
||||||
NEXT_PUBLIC_ISHARESECRETPHRASE = "Secret phrase"
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import https from "https";
|
import https from "https";
|
||||||
import CryptoJS from "crypto-js";
|
import CryptoJS from "crypto-js";
|
||||||
import { response } from "express";
|
import HmacSHA256 from "crypto-js/hmac-sha256";
|
||||||
|
|
||||||
const PROXY_RELAY_URL =
|
const PROXY_RELAY_URL =
|
||||||
"https://" +
|
"https://" +
|
||||||
@@ -48,16 +48,33 @@ const getSASToken = () => {
|
|||||||
return token;
|
return token;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function hashProxyPath(queryPath) {
|
||||||
|
const wordKey = process.env.HASHKEY;
|
||||||
|
//console.log(CryptoJS.enc.Hex.parse(wordKey));
|
||||||
|
var hashlink = CryptoJS.HmacSHA256(
|
||||||
|
queryPath,
|
||||||
|
CryptoJS.enc.Hex.parse(wordKey)
|
||||||
|
);
|
||||||
|
|
||||||
|
hashlink = hashlink.toString(CryptoJS.enc.Base64);
|
||||||
|
|
||||||
|
console.log("&hash=" + hashlink);
|
||||||
|
|
||||||
|
return queryPath; //+ "&hash=" + hashlink;
|
||||||
|
}
|
||||||
|
|
||||||
export default async function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
//console.log(req.method);
|
//console.log(req.method);
|
||||||
|
|
||||||
var data = JSON.stringify(req.body);
|
var data = JSON.stringify(req.body);
|
||||||
const SASToken = getSASToken();
|
const SASToken = getSASToken();
|
||||||
|
|
||||||
|
//console.log("the request", req.query.route, req.url);
|
||||||
|
|
||||||
var configNoData = {
|
var configNoData = {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
//url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")",
|
//url: PROXY_RELAY_URL + updateFormCollection + "(" + incidentId + ")",
|
||||||
url: PROXY_RELAY_URL + req.url.split("/api/proxy/")[1],
|
url: PROXY_RELAY_URL + hashProxyPath(req.url.split("/api/proxy/")[1]),
|
||||||
headers: {
|
headers: {
|
||||||
"OData-MaxVersion": "4.0",
|
"OData-MaxVersion": "4.0",
|
||||||
"OData-Version": "4.0",
|
"OData-Version": "4.0",
|
||||||
@@ -71,7 +88,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
|
|
||||||
var config = {
|
var config = {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
url: PROXY_RELAY_URL + req.query.route[0],
|
url: PROXY_RELAY_URL + hashProxyPath(req.query.route[0]),
|
||||||
headers: {
|
headers: {
|
||||||
"OData-MaxVersion": "4.0",
|
"OData-MaxVersion": "4.0",
|
||||||
"OData-Version": "4.0",
|
"OData-Version": "4.0",
|
||||||
@@ -85,7 +102,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
|
|
||||||
var configDocument = {
|
var configDocument = {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
url: PROXY_RELAY_URL + req.url.split("/api/proxy/")[1],
|
url: PROXY_RELAY_URL + hashProxyPath(req.url.split("/api/proxy/")[1]),
|
||||||
headers: {
|
headers: {
|
||||||
"OData-MaxVersion": "4.0",
|
"OData-MaxVersion": "4.0",
|
||||||
"OData-Version": "4.0",
|
"OData-Version": "4.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user