mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 04:26:33 +00:00
feat(infisical-pg): wrapped saml get option in try catch
This commit is contained in:
@@ -34,32 +34,37 @@ export const registerSamlRouter = async (server: FastifyZodProvider) => {
|
|||||||
{
|
{
|
||||||
passReqToCallback: true,
|
passReqToCallback: true,
|
||||||
getSamlOptions: async (req, done) => {
|
getSamlOptions: async (req, done) => {
|
||||||
const { ssoIdentifier } = req.params;
|
try {
|
||||||
if (!ssoIdentifier) throw new BadRequestError({ message: "Missing sso identitier" });
|
const { ssoIdentifier } = req.params;
|
||||||
|
if (!ssoIdentifier) throw new BadRequestError({ message: "Missing sso identitier" });
|
||||||
|
|
||||||
const ssoConfig = await server.services.saml.getSaml({
|
const ssoConfig = await server.services.saml.getSaml({
|
||||||
type: "ssoId",
|
type: "ssoId",
|
||||||
id: ssoIdentifier
|
id: ssoIdentifier
|
||||||
});
|
});
|
||||||
if (!ssoConfig) throw new BadRequestError({ message: "SSO config not found" });
|
if (!ssoConfig) throw new BadRequestError({ message: "SSO config not found" });
|
||||||
|
|
||||||
const samlConfig: TSAMLConfig = {
|
const samlConfig: TSAMLConfig = {
|
||||||
callbackUrl: `${appCfg.SITE_URL}/api/v1/sso/saml2/${ssoIdentifier}`,
|
callbackUrl: `${appCfg.SITE_URL}/api/v1/sso/saml2/${ssoIdentifier}`,
|
||||||
entryPoint: ssoConfig.entryPoint,
|
entryPoint: ssoConfig.entryPoint,
|
||||||
issuer: ssoConfig.issuer,
|
issuer: ssoConfig.issuer,
|
||||||
cert: ssoConfig.cert,
|
cert: ssoConfig.cert,
|
||||||
audience: appCfg.SITE_URL || ""
|
audience: appCfg.SITE_URL || ""
|
||||||
};
|
};
|
||||||
if (ssoConfig.authProvider === SamlProviders.JUMPCLOUD_SAML) {
|
if (ssoConfig.authProvider === SamlProviders.JUMPCLOUD_SAML) {
|
||||||
samlConfig.wantAuthnResponseSigned = false;
|
samlConfig.wantAuthnResponseSigned = false;
|
||||||
}
|
|
||||||
if (ssoConfig.authProvider === SamlProviders.AZURE_SAML) {
|
|
||||||
if (req.body.RelayState && JSON.parse(req.body.RelayState).spIntiaited) {
|
|
||||||
samlConfig.audience = `spn:${ssoConfig.issuer}`;
|
|
||||||
}
|
}
|
||||||
|
if (ssoConfig.authProvider === SamlProviders.AZURE_SAML) {
|
||||||
|
if (req.body.RelayState && JSON.parse(req.body.RelayState).spIntiaited) {
|
||||||
|
samlConfig.audience = `spn:${ssoConfig.issuer}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(req as unknown as FastifyRequest).ssoConfig = ssoConfig;
|
||||||
|
done(null, samlConfig);
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error);
|
||||||
|
done(error as Error);
|
||||||
}
|
}
|
||||||
(req as unknown as FastifyRequest).ssoConfig = ssoConfig;
|
|
||||||
done(null, samlConfig);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async (req, profile, cb) => {
|
async (req, profile, cb) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user