Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved comments on /App/FeatureSet/Identity/API/StatusPageSSO.ts #1734

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions App/FeatureSet/Identity/API/StatusPageSSO.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import StatusPagePrivateUser from "Common/Models/DatabaseModels/StatusPagePrivat
import StatusPageSSO from "Common/Models/DatabaseModels/StatusPageSso";
import xml2js from "xml2js";

// Initialize Express router.
const router: ExpressRouter = Express.getRouter();

// Define a GET route for SSO in a status page context.
router.get(
"/status-page-sso/:statusPageId/:statusPageSsoId",
async (
Expand All @@ -37,6 +39,7 @@ router.get(
next: NextFunction,
): Promise<void> => {
try {
// Check if statusPageId parameter is present.
if (!req.params["statusPageId"]) {
return Response.sendErrorResponse(
req,
Expand All @@ -45,6 +48,7 @@ router.get(
);
}

// Check if statusPageSsoId parameter is present.
if (!req.params["statusPageSsoId"]) {
return Response.sendErrorResponse(
req,
Expand All @@ -53,14 +57,16 @@ router.get(
);
}

// Create ObjectID instance from statusPageId parameter.
const statusPageId: ObjectID = new ObjectID(req.params["statusPageId"]);

// Find SSO record in the database with specific query parameters.
const statusPageSSO: StatusPageSSO | null =
await StatusPageSsoService.findOneBy({
query: {
statusPageId: statusPageId,
_id: req.params["statusPageSsoId"],
isEnabled: true,
statusPageId: statusPageId, // Ensure that statusPageId matches.
_id: req.params["statusPageSsoId"], // Ensure SSO ID matches.
isEnabled: true, // Ensure the SSO is enabled.
},
select: {
signOnURL: true,
Expand Down Expand Up @@ -235,6 +241,7 @@ router.post(
if (statusPageSSO.issuerURL.toString() !== issuerUrl) {
return Response.sendErrorResponse(
req,

res,
new BadRequestException("Issuer URL does not match"),
);
Expand Down Expand Up @@ -285,6 +292,7 @@ router.post(
res,
CookieUtil.getUserTokenKey(alreadySavedUser.statusPageId!),
token,

{
httpOnly: true,
maxAge: OneUptimeDate.getMillisecondsInDays(new PositiveNumber(30)),
Expand Down
Loading