Merged PR 617: added oauth authentication removed Shared Access Signature
Related work items: #6715
This commit is contained in:
@@ -5,6 +5,11 @@ RELAYPATH = "dev-pedw-hc"
|
|||||||
SASKEY = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y="
|
SASKEY = "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y="
|
||||||
SASKEYNAME = "devpedwnspolicy"
|
SASKEYNAME = "devpedwnspolicy"
|
||||||
|
|
||||||
|
ACCESS_TOKEN_ENDPOINT = https://login.microsoftonline.com/
|
||||||
|
TENANT = a8d860de-d5e1-45af-8376-d93f02e6b502
|
||||||
|
CLIENT_ID = e082def0-3453-461f-9a5e-f4ab127dc015
|
||||||
|
CLIENT_SECRET = qW.7Q~TSr3sZmLEnJQJPXEdOckb_yo2t1yJmY
|
||||||
|
GRANT_TYPE = "client_credentials"
|
||||||
|
|
||||||
PORT= "3000"
|
PORT= "3000"
|
||||||
DEFAULT_DOMAIN = "localhost"
|
DEFAULT_DOMAIN = "localhost"
|
||||||
|
|||||||
+61
-74
@@ -14,8 +14,12 @@ if (process.browser) {
|
|||||||
}
|
}
|
||||||
const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY;
|
const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY;
|
||||||
|
|
||||||
|
const cache = {};
|
||||||
const API_PATH = "/api/data/v8.2/";
|
const API_PATH = "/api/data/v8.2/";
|
||||||
|
|
||||||
|
const accessTokenEndpoint = process.env.ACCESS_TOKEN_ENDPOINT;
|
||||||
|
const tenantId = process.env.TENANT;
|
||||||
|
|
||||||
//const WEBAPI_URL = "https://devcrm2016.llcdt.gov.wales/DVPINS" + API_PATH;
|
//const WEBAPI_URL = "https://devcrm2016.llcdt.gov.wales/DVPINS" + API_PATH;
|
||||||
|
|
||||||
const WEBAPI_URL =
|
const WEBAPI_URL =
|
||||||
@@ -26,56 +30,49 @@ const agent = new https.Agent({
|
|||||||
rejectUnauthorized: false,
|
rejectUnauthorized: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getSASToken = () => {
|
export const getToken = () => {
|
||||||
var m_ResourceURI =
|
if (cache.tokenResponse) {
|
||||||
process.env.RELAYURI || "dev-pedw-ns.servicebus.windows.net";
|
console.log("from cache", tokenResponse);
|
||||||
var m_Path = process.env.RELAYPATH || "dev-pedw-hc";
|
return cache.tokenResponse;
|
||||||
var m_SasKey =
|
} else {
|
||||||
process.env.SASKEY || "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=";
|
return axios
|
||||||
var m_SasKeyName = process.env.SASKEYNAME || "devpedwnspolicy";
|
.post(
|
||||||
|
`${accessTokenEndpoint}${tenantId}/oauth2/v2.0/token`,
|
||||||
var encodedResourceUri = encodeURIComponent(
|
tokenBody,
|
||||||
"https://" + m_ResourceURI + "/" + m_Path + "/"
|
tokenConfig
|
||||||
);
|
)
|
||||||
|
.then((res) => res.data)
|
||||||
var t0 = new Date(1970, 1, 1, 0, 0, 0, 0);
|
.then((data) => {
|
||||||
var t1 = new Date();
|
cache.tokenResponse = data;
|
||||||
var expireInSeconds =
|
return data;
|
||||||
+(31 * 24 * 3600) + 3600 + (((t1.getTime() - t0.getTime()) / 1000) | 0);
|
})
|
||||||
|
.catch((error) => {
|
||||||
//the line below is a hack that converts to UTF8
|
console.log("error :", error.response);
|
||||||
var plainSignature = JSON.parse(
|
// return error;
|
||||||
JSON.stringify(encodedResourceUri + "\n" + expireInSeconds)
|
});
|
||||||
);
|
}
|
||||||
|
|
||||||
var hash = CryptoJS.HmacSHA256(plainSignature, m_SasKey);
|
|
||||||
var base64HashValue = CryptoJS.enc.Base64.stringify(hash);
|
|
||||||
|
|
||||||
var token =
|
|
||||||
"SharedAccessSignature sr=" +
|
|
||||||
encodedResourceUri +
|
|
||||||
"&sig=" +
|
|
||||||
encodeURIComponent(base64HashValue) +
|
|
||||||
"&se=" +
|
|
||||||
expireInSeconds +
|
|
||||||
"&skn=" +
|
|
||||||
m_SasKeyName;
|
|
||||||
|
|
||||||
// console.log("///////////////////////");
|
|
||||||
// console.log(
|
|
||||||
// "encodedURI:" + "https://" + m_ResourceURI + "/" + m_Path + "/"
|
|
||||||
// );
|
|
||||||
// console.log("WEBAPI_URL: " + WEBAPI_URL);
|
|
||||||
// console.log("m_ResourceURI: " + m_ResourceURI);
|
|
||||||
// console.log("m_Path: " + m_Path);
|
|
||||||
// console.log("m_SasKey: " + m_SasKey);
|
|
||||||
// console.log("m_SasKeyName: " + m_SasKeyName);
|
|
||||||
// console.log("token: " + token);
|
|
||||||
// console.log("///////////////////////");
|
|
||||||
return token;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const azureHeaders = (SASToken) => {
|
const tokenBody =
|
||||||
|
"grant_type=" +
|
||||||
|
process.env.GRANT_TYPE +
|
||||||
|
"&client_id=" +
|
||||||
|
process.env.CLIENT_ID +
|
||||||
|
"&client_secret=" +
|
||||||
|
process.env.CLIENT_SECRET +
|
||||||
|
"&scope=" +
|
||||||
|
"https://" +
|
||||||
|
process.env.RELAYURI +
|
||||||
|
"/.default";
|
||||||
|
|
||||||
|
const tokenConfig = {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
|
"Cache-Control": "no-cache",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const azureHeaders = (access_token) => {
|
||||||
return {
|
return {
|
||||||
headers: {
|
headers: {
|
||||||
"OData-MaxVersion": "4.0",
|
"OData-MaxVersion": "4.0",
|
||||||
@@ -83,12 +80,12 @@ const azureHeaders = (SASToken) => {
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"ServiceBusAuthorization": SASToken,
|
"Authorization": "Bearer " + access_token,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const azureHeadersPaged = (SASToken) => {
|
const azureHeadersPaged = (access_token) => {
|
||||||
return {
|
return {
|
||||||
headers: {
|
headers: {
|
||||||
"OData-MaxVersion": "4.0",
|
"OData-MaxVersion": "4.0",
|
||||||
@@ -97,7 +94,7 @@ const azureHeadersPaged = (SASToken) => {
|
|||||||
"Prefer":
|
"Prefer":
|
||||||
'odata.include-annotations="*",return=representation, odata.maxpagesize=10',
|
'odata.include-annotations="*",return=representation, odata.maxpagesize=10',
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"ServiceBusAuthorization": SASToken,
|
"Authorization": "Bearer " + access_token,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
@@ -126,7 +123,6 @@ export const getBasicSearch = (token, searchString) => {
|
|||||||
"') or contains(ticketnumber, '" +
|
"') or contains(ticketnumber, '" +
|
||||||
searchString +
|
searchString +
|
||||||
"')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
|
"')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
|
||||||
|
|
||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||||
@@ -188,7 +184,7 @@ export const getBasicDNSSearch = (token, searchString) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getBasicDNSSearchPaged = (pageNumber) => {
|
export const getBasicDNSSearchPaged = (pageNumber) => {
|
||||||
var token = getSASToken();
|
var token = getToken();
|
||||||
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
|
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
|
||||||
@@ -257,7 +253,7 @@ export const getAdvancedSearch = (token, searchString) => {
|
|||||||
|
|
||||||
export const getAdvancedSearchPaged = (searchString, pageNumber) => {
|
export const getAdvancedSearchPaged = (searchString, pageNumber) => {
|
||||||
//console.log(searchString);
|
//console.log(searchString);
|
||||||
var token = getSASToken();
|
var token = getToken();
|
||||||
|
|
||||||
var queryString = "";
|
var queryString = "";
|
||||||
|
|
||||||
@@ -393,7 +389,7 @@ export const getSearchDocumentHistory = (token, documentID) => {
|
|||||||
|
|
||||||
export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
|
export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
|
||||||
console.log(incidentID);
|
console.log(incidentID);
|
||||||
var token = getSASToken();
|
var token = getToken();
|
||||||
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
|
"/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
|
||||||
@@ -413,7 +409,7 @@ export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
|
export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
|
||||||
var token = getSASToken();
|
var token = getToken();
|
||||||
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
|
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
|
||||||
@@ -430,8 +426,6 @@ export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getSearchDocumentDetails1 = (incidentID) => {
|
export const getSearchDocumentDetails1 = (incidentID) => {
|
||||||
//console.log(incidentID);
|
|
||||||
var token = getSASToken();
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
||||||
incidentID +
|
incidentID +
|
||||||
@@ -445,8 +439,6 @@ export const getSearchDocumentDetails1 = (incidentID) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getSearchDocumentDetails1Paged = (incidentID, pageNumber) => {
|
export const getSearchDocumentDetails1Paged = (incidentID, pageNumber) => {
|
||||||
//console.log(incidentID);
|
|
||||||
var token = getSASToken();
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
|
||||||
incidentID +
|
incidentID +
|
||||||
@@ -463,8 +455,6 @@ export const getSearchDocumentDetails1Paged = (incidentID, pageNumber) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getSearchDocumentHistory1 = (documentID) => {
|
export const getSearchDocumentHistory1 = (documentID) => {
|
||||||
//console.log(documentID);
|
|
||||||
var token = getSASToken();
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
|
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
|
||||||
documentID;
|
documentID;
|
||||||
@@ -479,8 +469,6 @@ export const getSearchDocumentHistory1 = (documentID) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getSearchDocumentHistory1Paged = (documentID, pageNumber) => {
|
export const getSearchDocumentHistory1Paged = (documentID, pageNumber) => {
|
||||||
//console.log(documentID);
|
|
||||||
var token = getSASToken();
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
|
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
|
||||||
documentID +
|
documentID +
|
||||||
@@ -514,7 +502,7 @@ export const getBasicDNSSearchDetails = (token, appealType, caseReference) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getBasicDNSSearchDetailsPaged = (caseReference) => {
|
export const getBasicDNSSearchDetailsPaged = (caseReference) => {
|
||||||
var token = getSASToken();
|
var token = getToken();
|
||||||
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/proxy/pinswg_dnses?$filter=pinswg_name eq '" +
|
"/api/proxy/pinswg_dnses?$filter=pinswg_name eq '" +
|
||||||
@@ -665,7 +653,7 @@ export const getAppealID = (
|
|||||||
return axios
|
return axios
|
||||||
.get(
|
.get(
|
||||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||||
azureHeaders(getSASToken())
|
azureHeaders(getToken())
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
var appealID = res.data.value[0][primaryAttribute];
|
var appealID = res.data.value[0][primaryAttribute];
|
||||||
@@ -756,7 +744,7 @@ export const updateCase = async (
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"ServiceBusAuthorization": getSASToken(),
|
"Authorization": getToken(),
|
||||||
},
|
},
|
||||||
data: data,
|
data: data,
|
||||||
};
|
};
|
||||||
@@ -826,7 +814,7 @@ export const deleteMyRepresentations = (myRepresentationsID) => {
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"ServiceBusAuthorization": getSASToken(),
|
"Authorization": getToken(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// console.log(config);
|
// console.log(config);
|
||||||
@@ -905,7 +893,7 @@ export const createWatchedCases = (formValues) => {
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"ServiceBusAuthorization": getSASToken(),
|
"Authorization": getToken(),
|
||||||
},
|
},
|
||||||
data: data,
|
data: data,
|
||||||
};
|
};
|
||||||
@@ -931,7 +919,7 @@ export const deleteWatchedCases = (watchedCaseID) => {
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"ServiceBusAuthorization": getSASToken(),
|
"Authorization": getToken(),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
// console.log(config);
|
// console.log(config);
|
||||||
@@ -990,7 +978,6 @@ export const getPortalModuleDetailsProxy = (
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getEmailAccountCheck = (emailAddress) => {
|
export const getEmailAccountCheck = (emailAddress) => {
|
||||||
let token = getSASToken();
|
|
||||||
var queryUrl =
|
var queryUrl =
|
||||||
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
|
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
|
||||||
emailAddress +
|
emailAddress +
|
||||||
@@ -1015,7 +1002,7 @@ export const createAccount = (formValues) => {
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"ServiceBusAuthorization": getSASToken(),
|
"Authorization": getToken(),
|
||||||
},
|
},
|
||||||
data: data,
|
data: data,
|
||||||
};
|
};
|
||||||
@@ -1042,7 +1029,7 @@ export const updateAccount = (contactId, updateBody) => {
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"ServiceBusAuthorization": getSASToken(),
|
"Authorization": getToken(),
|
||||||
},
|
},
|
||||||
data: data,
|
data: data,
|
||||||
};
|
};
|
||||||
@@ -1070,7 +1057,7 @@ export const updatePassword = (contactId, newpassword) => {
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"ServiceBusAuthorization": getSASToken(),
|
"Authorization": getToken(),
|
||||||
},
|
},
|
||||||
data: data,
|
data: data,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
getSearchDocumentHistory1,
|
getSearchDocumentHistory1,
|
||||||
getSearchDocumentHistory1Paged,
|
getSearchDocumentHistory1Paged,
|
||||||
getSearchDocumentDetails1Paged,
|
getSearchDocumentDetails1Paged,
|
||||||
getSASToken,
|
getToken,
|
||||||
} from "../../actions";
|
} from "../../actions";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ let Login = (props) => {
|
|||||||
let now = new Date();
|
let now = new Date();
|
||||||
let expDate = new Date(now);
|
let expDate = new Date(now);
|
||||||
|
|
||||||
expDate.setDate(now.getDate() + 0.41);
|
expDate.setDate(now.getDate() + 1);
|
||||||
|
|
||||||
getLogin(values.loginUserID, values.loginUserPassword).then((data) => {
|
getLogin(values.loginUserID, values.loginUserPassword).then((data) => {
|
||||||
data.value.length != 0
|
data.value.length != 0
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { setCurrentReference } from "../../store/currentView/action";
|
|||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { parseCookies } from "nookies";
|
import { parseCookies } from "nookies";
|
||||||
import {
|
import {
|
||||||
getSASToken,
|
getToken,
|
||||||
getWatchedCasesProxy,
|
getWatchedCasesProxy,
|
||||||
getPortalModuleDetailsProxy,
|
getPortalModuleDetailsProxy,
|
||||||
deleteWatchedCases,
|
deleteWatchedCases,
|
||||||
@@ -37,7 +37,7 @@ const TopThree = (props) => {
|
|||||||
let showTopThreeArr = showTopThree.value;
|
let showTopThreeArr = showTopThree.value;
|
||||||
|
|
||||||
const deleteItem = (caseID, topThreeType) => {
|
const deleteItem = (caseID, topThreeType) => {
|
||||||
let token = getSASToken();
|
let token = getToken();
|
||||||
let cookies = parseCookies();
|
let cookies = parseCookies();
|
||||||
topThreeType == "watchedCases" &&
|
topThreeType == "watchedCases" &&
|
||||||
deleteWatchedCases(caseID)
|
deleteWatchedCases(caseID)
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
createWatchedCases,
|
createWatchedCases,
|
||||||
getSASToken,
|
getToken,
|
||||||
getWatchedCasesProxy,
|
getWatchedCasesProxy,
|
||||||
getPortalModuleDetailsProxy,
|
getPortalModuleDetailsProxy,
|
||||||
deleteWatchedCases,
|
deleteWatchedCases,
|
||||||
@@ -77,7 +77,7 @@ const SearchResults = (props) => {
|
|||||||
const cookies = parseCookies();
|
const cookies = parseCookies();
|
||||||
|
|
||||||
const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
|
const selectWatchedCase = (loggedInUser, incidentID, appealType) => {
|
||||||
let token = getSASToken();
|
let token = getToken();
|
||||||
|
|
||||||
let updateBody = {
|
let updateBody = {
|
||||||
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
|
"pinswg_WatchedCase@odata.bind": "/incidents(" + incidentID + ")",
|
||||||
@@ -109,7 +109,7 @@ const SearchResults = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const deleteItem = (caseID, topThreeType) => {
|
const deleteItem = (caseID, topThreeType) => {
|
||||||
let token = getSASToken();
|
let token = getToken();
|
||||||
let cookies = parseCookies();
|
let cookies = parseCookies();
|
||||||
topThreeType == "watchedCases" &&
|
topThreeType == "watchedCases" &&
|
||||||
deleteWatchedCases(caseID)
|
deleteWatchedCases(caseID)
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"axios": "^0.21.1",
|
"axios": "^0.21.1",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
"cookie-cutter": "^0.2.0",
|
"cookie-cutter": "^0.2.0",
|
||||||
|
"cookies": "^0.8.0",
|
||||||
"crypto-js": "^4.1.1",
|
"crypto-js": "^4.1.1",
|
||||||
"date-fns": "^2.25.0",
|
"date-fns": "^2.25.0",
|
||||||
"dom": "^0.0.3",
|
"dom": "^0.0.3",
|
||||||
|
|||||||
@@ -13,6 +13,8 @@ class MyDocument extends Document {
|
|||||||
let hasBasicAuth =
|
let hasBasicAuth =
|
||||||
typeof process.env.BASIC_AUTH_CREDENTIALS != "undefined";
|
typeof process.env.BASIC_AUTH_CREDENTIALS != "undefined";
|
||||||
|
|
||||||
|
console.log(hasBasicAuth);
|
||||||
|
|
||||||
if (ctx.req && ctx.res) {
|
if (ctx.req && ctx.res) {
|
||||||
hasBasicAuth &&
|
hasBasicAuth &&
|
||||||
(await basicAuthMiddleware(ctx.req, ctx.res, {
|
(await basicAuthMiddleware(ctx.req, ctx.res, {
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
getLPA,
|
getLPA,
|
||||||
updateCase,
|
updateCase,
|
||||||
createCase,
|
createCase,
|
||||||
getSASToken,
|
getToken,
|
||||||
} from "../actions";
|
} from "../actions";
|
||||||
import { setLPA } from "../store/lpa/action";
|
import { setLPA } from "../store/lpa/action";
|
||||||
|
|
||||||
@@ -139,7 +139,8 @@ const Home = (props) => {
|
|||||||
export const getServerSideProps = wrapper.getServerSideProps(
|
export const getServerSideProps = wrapper.getServerSideProps(
|
||||||
(store) =>
|
(store) =>
|
||||||
async ({ query, req, res }) => {
|
async ({ query, req, res }) => {
|
||||||
const token = await getSASToken();
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
|
|
||||||
const [appealTypeData, lpaData] = await Promise.all([
|
const [appealTypeData, lpaData] = await Promise.all([
|
||||||
await getAppealsTypes(token),
|
await getAppealsTypes(token),
|
||||||
|
|||||||
@@ -22,11 +22,7 @@ import {
|
|||||||
setSearchDetails,
|
setSearchDetails,
|
||||||
getSearchResultsObj,
|
getSearchResultsObj,
|
||||||
} from "../store/searchOutput/action";
|
} from "../store/searchOutput/action";
|
||||||
import {
|
import { getAdvancedSearch, getBasicSearchDetails, getToken } from "../actions";
|
||||||
getAdvancedSearch,
|
|
||||||
getBasicSearchDetails,
|
|
||||||
getSASToken,
|
|
||||||
} from "../actions";
|
|
||||||
|
|
||||||
const Home = (props) => {
|
const Home = (props) => {
|
||||||
const { footerLinks, pages } = props;
|
const { footerLinks, pages } = props;
|
||||||
@@ -127,7 +123,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
console.log("query-", query);
|
console.log("query-", query);
|
||||||
//console.log("search array:", Object.entries(query));
|
//console.log("search array:", Object.entries(query));
|
||||||
|
|
||||||
const token = await getSASToken();
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
|
|
||||||
const searchResultsObj = await getAdvancedSearch(token, query);
|
const searchResultsObj = await getAdvancedSearch(token, query);
|
||||||
const searchDetailsObj = await getSearchDetails(
|
const searchDetailsObj = await getSearchDetails(
|
||||||
|
|||||||
@@ -11,42 +11,43 @@ const PROXY_RELAY_URL =
|
|||||||
(process.env.RELAYPATH || "dev-pedw-hc") +
|
(process.env.RELAYPATH || "dev-pedw-hc") +
|
||||||
"/";
|
"/";
|
||||||
|
|
||||||
const getSASToken = () => {
|
const accessTokenEndpoint = process.env.ACCESS_TOKEN_ENDPOINT;
|
||||||
var m_ResourceURI =
|
const tenantId = process.env.TENANT;
|
||||||
process.env.RELAYURI || "dev-pedw-ns.servicebus.windows.net";
|
|
||||||
var m_Path = process.env.RELAYPATH || "dev-pedw-hc";
|
|
||||||
var m_SasKey =
|
|
||||||
process.env.SASKEY || "Ml0Y/S/nfRcmIrHFRkO4jNm2J3iH52TSxPiak7+E1+Y=";
|
|
||||||
var m_SasKeyName = process.env.SASKEYNAME || "devpedwnspolicy";
|
|
||||||
|
|
||||||
var encodedResourceUri = encodeURIComponent(
|
const tokenBody =
|
||||||
"https://" + m_ResourceURI + "/" + m_Path + "/"
|
"grant_type=" +
|
||||||
);
|
process.env.GRANT_TYPE +
|
||||||
|
"&client_id=" +
|
||||||
|
process.env.CLIENT_ID +
|
||||||
|
"&client_secret=" +
|
||||||
|
process.env.CLIENT_SECRET +
|
||||||
|
"&scope=" +
|
||||||
|
"https://" +
|
||||||
|
process.env.RELAYURI +
|
||||||
|
"/.default";
|
||||||
|
|
||||||
var t0 = new Date(1970, 1, 1, 0, 0, 0, 0);
|
const tokenConfig = {
|
||||||
var t1 = new Date();
|
headers: {
|
||||||
var expireInSeconds =
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
+(31 * 24 * 3600) + 3600 + (((t1.getTime() - t0.getTime()) / 1000) | 0);
|
"Cache-Control": "no-cache",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
//the line below is a hack that converts to UTF8
|
export const getToken = () => {
|
||||||
var plainSignature = JSON.parse(
|
return axios
|
||||||
JSON.stringify(encodedResourceUri + "\n" + expireInSeconds)
|
.post(
|
||||||
);
|
`${accessTokenEndpoint}${tenantId}/oauth2/v2.0/token`,
|
||||||
|
tokenBody,
|
||||||
var hash = CryptoJS.HmacSHA256(plainSignature, m_SasKey);
|
tokenConfig
|
||||||
var base64HashValue = CryptoJS.enc.Base64.stringify(hash);
|
)
|
||||||
|
.then((res) => res.data)
|
||||||
var token =
|
.then((data) => {
|
||||||
"SharedAccessSignature sr=" +
|
return data;
|
||||||
encodedResourceUri +
|
})
|
||||||
"&sig=" +
|
.catch((error) => {
|
||||||
encodeURIComponent(base64HashValue) +
|
console.log("error :", error.response);
|
||||||
"&se=" +
|
// return error;
|
||||||
expireInSeconds +
|
});
|
||||||
"&skn=" +
|
|
||||||
m_SasKeyName;
|
|
||||||
|
|
||||||
return token;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function checkProxyPath(queryPath) {
|
function checkProxyPath(queryPath) {
|
||||||
@@ -70,7 +71,9 @@ function checkProxyPath(queryPath) {
|
|||||||
|
|
||||||
export default async function ApiProxy(req, res) {
|
export default async function ApiProxy(req, res) {
|
||||||
var data = JSON.stringify(req.body);
|
var data = JSON.stringify(req.body);
|
||||||
const SASToken = getSASToken();
|
var accessToken = await getToken();
|
||||||
|
accessToken = accessToken.access_token;
|
||||||
|
|
||||||
const isDocument = req.url.indexOf("/documents/download") > -1;
|
const isDocument = req.url.indexOf("/documents/download") > -1;
|
||||||
|
|
||||||
let hashCheckPath = isDocument
|
let hashCheckPath = isDocument
|
||||||
@@ -95,7 +98,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer":
|
"Prefer":
|
||||||
'odata.include-annotations="*",return=representation,odata.maxpagesize=10',
|
'odata.include-annotations="*",return=representation,odata.maxpagesize=10',
|
||||||
"Authorization": SASToken,
|
"Authorization": "Bearer " + accessToken,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -112,7 +115,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
"OData-Version": "4.0",
|
"OData-Version": "4.0",
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Authorization": SASToken,
|
"Authorization": "Bearer " + accessToken,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
data: data,
|
data: data,
|
||||||
@@ -130,7 +133,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
"OData-Version": "4.0",
|
"OData-Version": "4.0",
|
||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Prefer": 'odata.include-annotations="*",return=representation',
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
||||||
"Authorization": SASToken,
|
"Authorization": "Bearer " + accessToken,
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
},
|
},
|
||||||
responseType: "arraybuffer",
|
responseType: "arraybuffer",
|
||||||
@@ -168,7 +171,7 @@ export default async function ApiProxy(req, res) {
|
|||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.log("proxy response error", error);
|
console.log("proxy response error", error);
|
||||||
// res.json(error);
|
//res.json(error);
|
||||||
res.status(405).end();
|
res.status(405).end();
|
||||||
return resolve();
|
return resolve();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -24,11 +24,7 @@ import {
|
|||||||
setSearchDetails,
|
setSearchDetails,
|
||||||
getSearchResultsObj,
|
getSearchResultsObj,
|
||||||
} from "../store/searchOutput/action";
|
} from "../store/searchOutput/action";
|
||||||
import {
|
import { getBasicDNSSearch, getBasicSearchDetails, getToken } from "../actions";
|
||||||
getBasicDNSSearch,
|
|
||||||
getBasicSearchDetails,
|
|
||||||
getSASToken,
|
|
||||||
} from "../actions";
|
|
||||||
|
|
||||||
const Home = (props) => {
|
const Home = (props) => {
|
||||||
const { footerLinks, pages } = props;
|
const { footerLinks, pages } = props;
|
||||||
@@ -127,7 +123,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
async ({ query, req, res }) => {
|
async ({ query, req, res }) => {
|
||||||
console.log("query-", query);
|
console.log("query-", query);
|
||||||
|
|
||||||
const token = await getSASToken();
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
|
|
||||||
let searchResultsObj = await getBasicDNSSearch(token);
|
let searchResultsObj = await getBasicDNSSearch(token);
|
||||||
searchResultsObj =
|
searchResultsObj =
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
getLPA,
|
getLPA,
|
||||||
updateCase,
|
updateCase,
|
||||||
createCase,
|
createCase,
|
||||||
getSASToken,
|
getToken,
|
||||||
} from "../../actions";
|
} from "../../actions";
|
||||||
import { setLPA } from "../../store/lpa/action";
|
import { setLPA } from "../../store/lpa/action";
|
||||||
|
|
||||||
@@ -77,7 +77,8 @@ const Home = (props) => {
|
|||||||
export const getServerSideProps = wrapper.getServerSideProps(
|
export const getServerSideProps = wrapper.getServerSideProps(
|
||||||
(store) =>
|
(store) =>
|
||||||
async ({ query, req, res }) => {
|
async ({ query, req, res }) => {
|
||||||
const token = await getSASToken();
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
|
|
||||||
const [appealTypeData, lpaData] = await Promise.all([
|
const [appealTypeData, lpaData] = await Promise.all([
|
||||||
await getAppealsTypes(token),
|
await getAppealsTypes(token),
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
setSearchResults,
|
setSearchResults,
|
||||||
setSearchDetails,
|
setSearchDetails,
|
||||||
} from "../../store/searchOutput/action";
|
} from "../../store/searchOutput/action";
|
||||||
import { getAdvancedSearch, getSASToken } from "../../actions";
|
import { getAdvancedSearch, getToken } from "../../actions";
|
||||||
|
|
||||||
const Home = (props) => {
|
const Home = (props) => {
|
||||||
const { footerLinks, pages } = props;
|
const { footerLinks, pages } = props;
|
||||||
@@ -62,7 +62,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
console.log("query-", query);
|
console.log("query-", query);
|
||||||
//console.log("search array:", Object.entries(query));
|
//console.log("search array:", Object.entries(query));
|
||||||
|
|
||||||
const token = await getSASToken();
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
|
|
||||||
const searchResultsObj = await getAdvancedSearch(token, query);
|
const searchResultsObj = await getAdvancedSearch(token, query);
|
||||||
const searchDetailsObj = await getSearchDetails(
|
const searchDetailsObj = await getSearchDetails(
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import {
|
|||||||
setAwaitingSubmissionDetails,
|
setAwaitingSubmissionDetails,
|
||||||
} from "../../store/awaitingSubmission/action";
|
} from "../../store/awaitingSubmission/action";
|
||||||
import {
|
import {
|
||||||
getSASToken,
|
getToken,
|
||||||
getPersonalAccount,
|
getPersonalAccount,
|
||||||
getMyCases,
|
getMyCases,
|
||||||
getMyRepresentations,
|
getMyRepresentations,
|
||||||
@@ -152,7 +152,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
|
|
||||||
const { cookies } = req;
|
const { cookies } = req;
|
||||||
|
|
||||||
const token = await getSASToken();
|
console.log("the cookoies", cookies);
|
||||||
|
|
||||||
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
|
|
||||||
let loggedInUser = cookies.pinsUser;
|
let loggedInUser = cookies.pinsUser;
|
||||||
|
|
||||||
@@ -171,6 +174,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
//const cookiesMaker = nookies.get(ctx)
|
//const cookiesMaker = nookies.get(ctx)
|
||||||
|
console.log(accountDetails);
|
||||||
const [
|
const [
|
||||||
myCasesDetails,
|
myCasesDetails,
|
||||||
myRepresentationsDetails,
|
myRepresentationsDetails,
|
||||||
@@ -199,7 +203,7 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const getDetails = (token, resultsObj, detailsType) => {
|
const getDetails = (token, resultsObj, detailsType) => {
|
||||||
//console.log(resultsObj);
|
console.log(resultsObj);
|
||||||
let detailsArr = [];
|
let detailsArr = [];
|
||||||
resultsObj = resultsObj.value;
|
resultsObj = resultsObj.value;
|
||||||
const detailsObj = resultsObj.map((searchDetail, index) => {
|
const detailsObj = resultsObj.map((searchDetail, index) => {
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import {
|
|||||||
getSearchDocumentHistory,
|
getSearchDocumentHistory,
|
||||||
getWatchedCases,
|
getWatchedCases,
|
||||||
getPortalModuleDetails,
|
getPortalModuleDetails,
|
||||||
getSASToken,
|
getToken,
|
||||||
} from "../../actions";
|
} from "../../actions";
|
||||||
|
|
||||||
const Home = (props) => {
|
const Home = (props) => {
|
||||||
@@ -82,7 +82,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
|
|
||||||
const { cookies } = req;
|
const { cookies } = req;
|
||||||
|
|
||||||
const token = await getSASToken();
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
|
|
||||||
let loggedInUser = cookies.pinsUser;
|
let loggedInUser = cookies.pinsUser;
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ import {
|
|||||||
} from "../../store/appealType/action";
|
} from "../../store/appealType/action";
|
||||||
import { setForm, getFormObj } from "../../store/formData/action";
|
import { setForm, getFormObj } from "../../store/formData/action";
|
||||||
import {
|
import {
|
||||||
getSASToken,
|
getToken,
|
||||||
getFormData,
|
getFormData,
|
||||||
getAppealsTypes,
|
getAppealsTypes,
|
||||||
getMandatoryFields,
|
getMandatoryFields,
|
||||||
@@ -331,7 +331,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
console.log("the query", query);
|
console.log("the query", query);
|
||||||
let loggedInUser = cookies.pinsUser;
|
let loggedInUser = cookies.pinsUser;
|
||||||
|
|
||||||
const token = await getSASToken();
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
const [
|
const [
|
||||||
caseReferenceData,
|
caseReferenceData,
|
||||||
appealTypeData,
|
appealTypeData,
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import {
|
|||||||
getLPA,
|
getLPA,
|
||||||
updateCase,
|
updateCase,
|
||||||
createCase,
|
createCase,
|
||||||
getSASToken,
|
getToken,
|
||||||
} from "../../actions";
|
} from "../../actions";
|
||||||
import { setLPA } from "../../store/lpa/action";
|
import { setLPA } from "../../store/lpa/action";
|
||||||
|
|
||||||
@@ -150,7 +150,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
|
|
||||||
let loggedInUser = cookies.pinsUser;
|
let loggedInUser = cookies.pinsUser;
|
||||||
|
|
||||||
const token = await getSASToken();
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
|
|
||||||
const [appealTypeData, lpaData, caseData] = await Promise.all([
|
const [appealTypeData, lpaData, caseData] = await Promise.all([
|
||||||
await getAppealsTypes(token),
|
await getAppealsTypes(token),
|
||||||
|
|||||||
@@ -42,7 +42,8 @@ const Home = (props) => {
|
|||||||
|
|
||||||
// export const getServerSideProps = wrapper.getServerSideProps(
|
// export const getServerSideProps = wrapper.getServerSideProps(
|
||||||
// async ({ locale, store, req, res }) => {
|
// async ({ locale, store, req, res }) => {
|
||||||
// const token = await getToken();
|
// let token = await getToken()
|
||||||
|
token = token.access_token;
|
||||||
// let accessToken = token.access_token;
|
// let accessToken = token.access_token;
|
||||||
|
|
||||||
// const apiRoot = process.browser ? window.API_ROOT : process.env.API_ROOT;
|
// const apiRoot = process.browser ? window.API_ROOT : process.env.API_ROOT;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import {
|
|||||||
setSearchDetails,
|
setSearchDetails,
|
||||||
getSearchResultsObj,
|
getSearchResultsObj,
|
||||||
} from "../store/searchOutput/action";
|
} from "../store/searchOutput/action";
|
||||||
import { getBasicSearch, getBasicSearchDetails, getSASToken } from "../actions";
|
import { getBasicSearch, getBasicSearchDetails, getToken } from "../actions";
|
||||||
import { getSearchDetails } from "../components/utils";
|
import { getSearchDetails } from "../components/utils";
|
||||||
|
|
||||||
const Home = (props) => {
|
const Home = (props) => {
|
||||||
@@ -121,7 +121,8 @@ export const getServerSideProps = wrapper.getServerSideProps(
|
|||||||
async ({ query, req, res }) => {
|
async ({ query, req, res }) => {
|
||||||
console.log("query-", query);
|
console.log("query-", query);
|
||||||
|
|
||||||
const token = await getSASToken();
|
let token = await getToken();
|
||||||
|
token = token.access_token;
|
||||||
|
|
||||||
let searchResultsObj = await getBasicSearch(token, query.q);
|
let searchResultsObj = await getBasicSearch(token, query.q);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user