Skip to content

Commit

Permalink
Fixed codeql issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbie-Microsoft committed Dec 31, 2024
1 parent e9b239c commit 1fa8c14
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 17 deletions.
4 changes: 1 addition & 3 deletions extensions/samples/msal-node-extensions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ PersistenceCreator
};

pca.acquireTokenByCode(tokenRequest).then((response) => {
console.log("\nResponse: \n", response);
res.sendStatus(200);
}).catch((error) => {
console.error(error.errorMessage);
res.status(500).send(error);
res.status(500).send(error.errorMessage);
});
});

Expand Down
1 change: 0 additions & 1 deletion samples/e2eTestUtils/jest-puppeteer-utils/serverUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ async function isServerUp(port, timeout) {
host: "localhost",
port: port,
family: 4,
rejectUnauthorized: false,
};

https
Expand Down
2 changes: 1 addition & 1 deletion samples/msal-browser-samples/HybridSample/routes/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ router.post('/server-redirect', (req, res) => {
})
.catch((error) => {
console.timeEnd(timeLabel);
res.status(500).send(error);
res.status(500).send(error.errorMessage);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export const auth = (options: AuthOptions): Router => {
);
}

res.locals.originalUrl = req.originalUrl;

next();
});

Expand All @@ -58,10 +60,7 @@ export const auth = (options: AuthOptions): Router => {
req.session.isAuthenticated = true;
req.session.account = tokenResponse?.account!; // account won't be null in this grant type

const { redirectTo } = JSON.parse(
Buffer.from(req.body.state, "base64").toString("utf8")
);
res.redirect(redirectTo); // redirect back to original route
res.redirect(res.locals.originalUrl); // redirect back to original route
} catch (error) {
next(error);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/msal-node-samples/auth-code-key-vault/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function msalApp(thumbprint, privateKey) {
cca.acquireTokenByCode(tokenRequest).then((response) => {
res.status(200).send('Congratulations! You have signed in successfully');
}).catch((error) => {
res.status(500).send(error);
res.status(500).send(error.errorMessage);
});
});

Expand Down
4 changes: 2 additions & 2 deletions samples/msal-node-samples/auth-code-pkce/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ app.get("/redirect", (req: RequestWithPKCE, res) => {
};

pca.acquireTokenByCode(tokenRequest)
.then((response) => {
.then(() => {
res.sendStatus(200);
})
.catch((error) => {
res.status(500).send(error);
res.status(500).send(error.errorMessage);
});
});

Expand Down
2 changes: 1 addition & 1 deletion samples/msal-node-samples/auth-code-with-certs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ app.post('/redirect', (req, res) => {
cca.acquireTokenByCode(tokenRequest).then((response) => {
res.status(200).send('Congratulations! You have signed in successfully');
}).catch((error) => {
res.status(500).send(error);
res.status(500).send(error.errorMessage);
});
});

Expand Down
2 changes: 1 addition & 1 deletion samples/msal-node-samples/auth-code/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ const getTokenAuthCode = function (scenarioConfig, clientApplication, port) {
console.log("Successfully acquired token using Authorization Code.");
res.sendStatus(200);
}).catch((error) => {
res.status(500).send(error);
res.status(500).send(error.errorMessage);
});
});

Expand Down
4 changes: 2 additions & 2 deletions samples/msal-node-samples/on-behalf-of/web-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const acquireTokenObo = (cca, webApiPort, clientId, authority, discoveryKeysEndp
res.status(200).send(graphResponse);
});
}).catch((error) => {
res.status(500).send(error);
res.status(500).send(error.errorMessage);
});
});

Expand All @@ -91,7 +91,7 @@ const acquireTokenObo = (cca, webApiPort, clientId, authority, discoveryKeysEndp
});
});
req.on("error", (error) => {
console.error(error);
console.error(error.errorMessage);
});
req.end();
}
Expand Down
2 changes: 1 addition & 1 deletion samples/msal-node-samples/on-behalf-of/web-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const acquireTokenByCode = (cca, webAppPort, webApiPort, redirectUri, webApiScop
res.status(200).send(oboResponse);
});
}).catch((error) => {
res.status(500).send(error);
res.status(500).send(error.errorMessage);
});
});

Expand Down

0 comments on commit 1fa8c14

Please sign in to comment.