sotrage account calls security hardening

This commit is contained in:
2023-02-03 17:01:59 +00:00
parent a2ee8c58a6
commit 31362e4446
6 changed files with 109 additions and 46 deletions
@@ -19,13 +19,15 @@ ApiProxy.get(async (req, res) => {
// console.log(hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await createCaseCompleteMessage(containerName, tempCaseRef).then((data) => {
return res.status(200).json(data);
});
// } else {
// return res.status(400).json();
// }
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await createCaseCompleteMessage(containerName, tempCaseRef).then(
(data) => {
return res.status(200).json(data);
}
);
} else {
return res.status(400).json();
}
});
export const config = {
@@ -0,0 +1,60 @@
import {
hashAPIPath,
getToken,
azureHeaders,
consoleLogger,
} from "../../../actions";
import {
getBlobs,
createCaseCompleteMessage,
} from "../../../actions/azurestorage";
import axios from "axios";
import nextConnect from "next-connect";
import middleware from "../middleware/middleware";
const ApiProxy = nextConnect();
ApiProxy.use(middleware);
ApiProxy.get(async (req, res) => {
var containerName = req.query.container;
var tempCaseRef = req.query.tempcaseref;
console.log("/////Create Case Message:\n", tempCaseRef, "\n//////////////");
// console.log(hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
var token = await getToken();
var queryUrl =
"/api/file/createappealcompletemessageproxy_api?container=" +
containerID +
"&tempcaseref=" +
caseReference;
var config = {
method: "get",
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
};
return axios(config)
.then((res) => {
return res.data;
})
.then(({ data }) => {
res.status(200).json(data);
})
.catch((err) => {
console.log(consoleLogger(err));
res.status(400).json(err);
});
});
export const config = {
api: {
bodyParser: false,
},
};
export default ApiProxy;
+7 -7
View File
@@ -21,13 +21,13 @@ ApiProxy.get(async (req, res) => {
// console.log(hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await getBlobs(containerName, casefolderID).then((data) => {
return res.status(200).json({ files: data });
});
// } else {
// return res.status(400).json();
// }
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await getBlobs(containerName, casefolderID).then((data) => {
return res.status(200).json({ files: data });
});
} else {
return res.status(400).json();
}
});
export const config = {
+18 -14
View File
@@ -5,6 +5,7 @@ import {
import _ from "lodash";
import nextConnect from "next-connect";
import middleware from "../middleware/middleware";
import { hashAPIPath } from "../../../actions";
const ApiProxy = nextConnect();
ApiProxy.use(middleware);
@@ -20,22 +21,25 @@ ApiProxy.get(async (req, res) => {
"&casefolderID=" +
casefolderID;
// console.log(hashAPIPath(checkquerypath), checkHash);
//console.log(hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
const blobObj = await getProgressBlobs(containerName, casefolderID)
.then((data) => {
console.log("ertyuikjhgfg", data.path);
return downloadProgressFile(containerName, data.path, casefolderID);
})
.then((data) => {
return res.status(200).json(data);
});
// } else {
// return res.status(400).json();
// }
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
const blobObj = await getProgressBlobs(containerName, casefolderID)
.then((data) => {
console.log("Progress blob path:", data.path);
return downloadProgressFile(
containerName,
data.path,
casefolderID
);
})
.then((data) => {
return res.status(200).json(data);
});
} else {
return res.status(400).json();
}
});
export const config = {
+12 -15
View File
@@ -18,24 +18,21 @@ ApiProxy.get(async (req, res) => {
var checkHash = req.query.hash;
var checkquerypath = "/api/file/setupcontainer?ident=" + containerName;
console.log(req.query);
console.log(checkquerypath.length);
console.log(hashAPIPath(checkquerypath));
// console.log(checkquerypath, hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await createContainer(containerName)
.then((data) => {
return res.status(200).json({ data: "success" });
})
.catch((err) => {
console.log(consoleLogger(err));
res.status(400).json(err);
});
// } else {
// return res.status(400).json();
// }
if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await createContainer(containerName)
.then((data) => {
return res.status(200).json({ data: "success" });
})
.catch((err) => {
console.log(consoleLogger(err));
res.status(400).json(err);
});
} else {
return res.status(400).json();
}
});
export const config = {
+3 -3
View File
@@ -16,8 +16,8 @@ import {
consoleLogger,
getCase,
getPortalLogin,
createContainerProxy,
} from "../../actions";
import { createContainer } from "../../actions/azurestorage";
import Breadcrumbs from "../../components/breadcrumbs";
import CookieBanner from "../../components/cookieBanner";
import Footer from "../../components/footer";
@@ -180,10 +180,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
]);
loggedInUser = loggedInUser.value[0].contactid;
console.log("nextAuth Session:", thisSession);
//console.log("nextAuth Session:", thisSession);
}
//Create Storage container for logged in user
await createContainer(thisSession.user.id);
await createContainerProxy(thisSession.user.id);
const [
accountDetails,