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), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await createCaseCompleteMessage(containerName, tempCaseRef).then((data) => { await createCaseCompleteMessage(containerName, tempCaseRef).then(
(data) => {
return res.status(200).json(data); return res.status(200).json(data);
}); }
// } else { );
// return res.status(400).json(); } else {
// } return res.status(400).json();
}
}); });
export const config = { 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;
+4 -4
View File
@@ -21,13 +21,13 @@ ApiProxy.get(async (req, res) => {
// console.log(hashAPIPath(checkquerypath), checkHash); // console.log(hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await getBlobs(containerName, casefolderID).then((data) => { await getBlobs(containerName, casefolderID).then((data) => {
return res.status(200).json({ files: data }); return res.status(200).json({ files: data });
}); });
// } else { } else {
// return res.status(400).json(); return res.status(400).json();
// } }
}); });
export const config = { export const config = {
+11 -7
View File
@@ -5,6 +5,7 @@ import {
import _ from "lodash"; import _ from "lodash";
import nextConnect from "next-connect"; import nextConnect from "next-connect";
import middleware from "../middleware/middleware"; import middleware from "../middleware/middleware";
import { hashAPIPath } from "../../../actions";
const ApiProxy = nextConnect(); const ApiProxy = nextConnect();
ApiProxy.use(middleware); ApiProxy.use(middleware);
@@ -23,19 +24,22 @@ ApiProxy.get(async (req, res) => {
//console.log(hashAPIPath(checkquerypath), checkHash); //console.log(hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
const blobObj = await getProgressBlobs(containerName, casefolderID) const blobObj = await getProgressBlobs(containerName, casefolderID)
.then((data) => { .then((data) => {
console.log("ertyuikjhgfg", data.path); console.log("Progress blob path:", data.path);
return downloadProgressFile(containerName, data.path, casefolderID); return downloadProgressFile(
containerName,
data.path,
casefolderID
);
}) })
.then((data) => { .then((data) => {
return res.status(200).json(data); return res.status(200).json(data);
}); });
} else {
// } else { return res.status(400).json();
// return res.status(400).json(); }
// }
}); });
export const config = { export const config = {
+4 -7
View File
@@ -18,13 +18,10 @@ ApiProxy.get(async (req, res) => {
var checkHash = req.query.hash; var checkHash = req.query.hash;
var checkquerypath = "/api/file/setupcontainer?ident=" + containerName; 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(checkquerypath, hashAPIPath(checkquerypath), checkHash);
// console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash); // console.log(hashAPIPath(checkquerypath) == "&hash=" + checkHash);
//if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) { if (hashAPIPath(checkquerypath) == "&hash=" + checkHash) {
await createContainer(containerName) await createContainer(containerName)
.then((data) => { .then((data) => {
return res.status(200).json({ data: "success" }); return res.status(200).json({ data: "success" });
@@ -33,9 +30,9 @@ ApiProxy.get(async (req, res) => {
console.log(consoleLogger(err)); console.log(consoleLogger(err));
res.status(400).json(err); res.status(400).json(err);
}); });
// } else { } else {
// return res.status(400).json(); return res.status(400).json();
// } }
}); });
export const config = { export const config = {
+3 -3
View File
@@ -16,8 +16,8 @@ import {
consoleLogger, consoleLogger,
getCase, getCase,
getPortalLogin, getPortalLogin,
createContainerProxy,
} from "../../actions"; } from "../../actions";
import { createContainer } from "../../actions/azurestorage";
import Breadcrumbs from "../../components/breadcrumbs"; import Breadcrumbs from "../../components/breadcrumbs";
import CookieBanner from "../../components/cookieBanner"; import CookieBanner from "../../components/cookieBanner";
import Footer from "../../components/footer"; import Footer from "../../components/footer";
@@ -180,10 +180,10 @@ export const getServerSideProps = wrapper.getServerSideProps(
]); ]);
loggedInUser = loggedInUser.value[0].contactid; loggedInUser = loggedInUser.value[0].contactid;
console.log("nextAuth Session:", thisSession); //console.log("nextAuth Session:", thisSession);
} }
//Create Storage container for logged in user //Create Storage container for logged in user
await createContainer(thisSession.user.id); await createContainerProxy(thisSession.user.id);
const [ const [
accountDetails, accountDetails,