Add Google SSO

This commit is contained in:
Tuan Dang
2023-07-21 17:48:36 +07:00
parent 44108621b4
commit fd3cf70e13
12 changed files with 2026 additions and 1882 deletions
+25 -1
View File
@@ -18,6 +18,30 @@ import {
getSiteURL
} from "../../../config";
router.get(
"/redirect/google",
authLimiter,
passport.authenticate("google", {
scope: ["profile", "email"],
session: false,
})
);
router.get(
"/google",
passport.authenticate("google", {
failureRedirect: "/login/provider/error",
session: false
}),
async (req, res) => {
if (req.isUserCompleted) {
res.redirect(`${await getSiteURL()}/login/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
} else {
res.redirect(`${await getSiteURL()}/signup/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
}
}
);
router.get(
"/redirect/saml2/:ssoIdentifier",
authLimiter,
@@ -32,7 +56,7 @@ router.post("/saml2/:ssoIdentifier",
failureFlash: true,
session: false
}),
async (req, res) => {
async (req, res) => { // TODO: move this into controller
if (req.isUserCompleted) {
return res.redirect(`${await getSiteURL()}/login/sso?token=${encodeURIComponent(req.providerAuthToken)}`);
}
@@ -30,6 +30,7 @@ interface FeatureSet {
customRateLimits: boolean;
customAlerts: boolean;
auditLogs: boolean;
samlSSO: boolean;
status: "incomplete" | "incomplete_expired" | "trialing" | "active" | "past_due" | "canceled" | "unpaid" | null;
trial_end: number | null;
has_used_trial: boolean;
@@ -63,6 +64,7 @@ class EELicenseService {
customRateLimits: true,
customAlerts: true,
auditLogs: false,
samlSSO: false,
status: null,
trial_end: null,
has_used_trial: true