added hardening on documents link
This commit is contained in:
@@ -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(() => {
|
||||
|
||||
Reference in New Issue
Block a user