added hardening on documents link

This commit is contained in:
2021-11-16 19:12:03 +00:00
parent c6d4743f73
commit 831f0497c5
6 changed files with 101 additions and 160 deletions
+14 -14
View File
@@ -105,12 +105,9 @@ const DocumentDetails = (props) => {
>
<dd className="govuk-summary-list__value govuk-!-font-size-16 ">
<a
href={
"/api/proxy/documents/download/" +
encryptDocReference(
detailsObj.pinswg_isharedocumentreference
)
}
href={encryptDocReference(
detailsObj.pinswg_isharedocumentreference
)}
>
<span className="results-visually-hidden">
{t(
@@ -194,15 +191,18 @@ const DocumentDetails = (props) => {
);
};
const encryptDocReference = (documentRef) => {
var encrypted = encodeURIComponent(
CryptoJS.AES.encrypt(
documentRef,
process.env.NEXT_PUBLIC_ISHARESECRETPHRASE
)
);
const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY;
return encrypted;
const encryptDocReference = (documentRef) => {
var hashlink = CryptoJS.HmacSHA256(
"/api/proxy/documents/download/" + documentRef,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString();
return (
"/api/proxy/documents/download/" + documentRef + "&hash=" + hashlink
);
};
useEffect(() => {