Skip to content

The open alternative to Salesforce, designed for AI.

SSO - Check if assertion is signed (#17837)

Thomas Trompette17786a329810
diff --git a/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts b/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts
index b104c280674..984245f1145 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/controllers/sso-auth.controller.ts
@@ -65,7 +65,7 @@ export class SSOAuthController {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
async generateMetadata(@Req() req: any): Promise<string | void> {
return generateServiceProviderMetadata({
- wantAssertionsSigned: false,
+ wantAssertionsSigned: true,
issuer: this.sSOService.buildIssuerURL({
id: req.params.identityProviderId,
type: IdentityProviderType.SAML,
diff --git a/packages/twenty-server/src/engine/core-modules/auth/strategies/saml.auth.strategy.ts b/packages/twenty-server/src/engine/core-modules/auth/strategies/saml.auth.strategy.ts
index 3f618dd6fcf..912710b27d4 100644
--- a/packages/twenty-server/src/engine/core-modules/auth/strategies/saml.auth.strategy.ts
+++ b/packages/twenty-server/src/engine/core-modules/auth/strategies/saml.auth.strategy.ts
@@ -47,14 +47,17 @@ export class SamlAuthStrategy extends PassportStrategy(
identityProvider &&
this.sSOService.isSAMLIdentityProvider(identityProvider)
) {
+ // IdP metadata XML typically has whitespace-formatted certificates
+ const sanitizedCertificate =
+ identityProvider.certificate.replace(/\s/g, '');
+
const config: SamlConfig = {
entryPoint: identityProvider.ssoURL,
issuer: this.sSOService.buildIssuerURL(identityProvider),
callbackUrl:
this.sSOService.buildCallbackUrl(identityProvider),
- idpCert: identityProvider.certificate,
- // TODO: Improve the feature by sign the response
- wantAssertionsSigned: false,
+ idpCert: sanitizedCertificate,
+ wantAssertionsSigned: true,
wantAuthnResponseSigned: false,
disableRequestedAuthnContext: true,
signatureAlgorithm: 'sha256',