Skip to content

Commit

Permalink
Added logging with more info on user requests
Browse files Browse the repository at this point in the history
  • Loading branch information
nitrosx committed Mar 20, 2024
1 parent d73a0f4 commit 740a687
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
15 changes: 9 additions & 6 deletions CI/ESS/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
version: "3"
services:
node:
build: .
restart: always
image: docker pull ghcr.io/scicatproject/zip-service:alpha.1
restart: no
ports:
- "3012:3012"
volumes:
- /nfs/groups/beamlines/:/nfs/groups/beamlines
- /users/detector/experiments/:/users/detector/experiments
- /mnt/groupdata/guide_optimizations/:/mnt/groupdata/guide_optimizations
- /tmp/zip-service:/home/node/app/files #location of the zipped files
- /ess/sims/config/zip-service/config.json:/home/node/app/config.json
- /tmp/zip-service:/home/node/app/files
- /users/detector/experiments/:/users/detector/experiments:ro
- /nfs/groups/beamlines/:/nfs/groups/beamlines:ro
- /mnt/groupdata/guide_optimizations/:/mnt/groupdata/guide_optimizations:ro
- /ess/data:/ess/data:ro

6 changes: 5 additions & 1 deletion src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,12 @@ export const hasFileAccess = (
};
}
let jwtDecoded: Global.JWT;
const jwtToken = req.body.jwt || req.cookies.jwt || req.query.jwt;
console.log("jwt token : ", jwtToken);
console.log("jwt secret : ", jwtSecret);
try {
jwtDecoded = jwtLib.verify(
req.body.jwt || req.cookies.jwt || req.query.jwt,
jwtToken,
jwtSecret
) as Global.JWT;
} catch (e) {
Expand All @@ -40,6 +43,7 @@ export const hasFileAccess = (
directory,
fileNames,
};
console.log("Auth request : ", authRequest);
if (!authRequest.directory) {
return {
hasAccess: false,
Expand Down
7 changes: 7 additions & 0 deletions src/routes/zip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,17 @@ export const router = express.Router();
* Request zipping of files. Require directory:string and files:string[] in the request body
*/
router.post("/", (req, res) => {
console.log("Request body : ", req.body);
const { hasAccess, statusCode, error, directory, fileNames } = hasFileAccess(
req,
req.body.directory,
req.body.files
);
console.log("Has access : ", hasAccess);
console.log("Status code : ", statusCode);
console.log("Error : ", error);
console.log("Directory : ", directory);
console.log("File names : ", fileNames);
if (!hasAccess) {
return res.render("error", { statusCode, error });
}
Expand All @@ -26,6 +32,7 @@ router.post("/", (req, res) => {
"_" +
new Date().getTime() +
".zip";
console.log("Zip file name : ", zipFileName);
req.session.zipData = initSession(directory, fileNames, zipFileName);
res.render("zipping", { total: fileNames.length, zipFileName });
if (!fs.existsSync(config.zipDir)) {
Expand Down

0 comments on commit 740a687

Please sign in to comment.