node-saml / passport-saml

SAML 2.0 authentication with Passport
MIT License
862 stars 473 forks source link

SLO Request Failed In Azure #929

Closed ehabAbdelMawla closed 2 months ago

ehabAbdelMawla commented 2 months ago

I have a MultiSamlStrategy implementation with saml factory

    GetSamlConfiguration(config, accountKey, clientRedirectUrl) {
        return {
            entryPoint: config.SamlEntryPointUrl,
            signatureAlgorithm: 'sha256' as SignatureAlgorithm,
            issuer: config.SamlIssuer,
            idpCert: config.SamlCertificate,
            callbackUrl: this.GetCallBackUrl(accountKey, clientRedirectUrl),
            wantAssertionsSigned: true,
            wantAuthnResponseSigned: false
        };
    }
    onModuleInit() {
        passport.use(
            new MultiSamlStrategy(
                {
                    passReqToCallback: true,
                    getSamlOptions: async (req: any, Done) => {
                        try {
                            const { accountKey, clientRedirectUrl } = req.query;
                            console.log('getSamlOptions', { accountKey, clientRedirectUrl });
                            const config = await this.GenericRepository.GetAccountSsoConfigByKey(accountKey);
                            if (!(config && config.SsoType == SsoTypes.SAML)) {
                                throw new SsoException(ErrorCodesEnum.SSO_CONFIGURATION_NOT_FOUND);
                            }
                            return Done(null, this.GetSamlConfiguration(config, accountKey, clientRedirectUrl));
                        } catch (error) {
                            return Done(new SsoException(ErrorCodesEnum.SSO_CONFIGURATION_NOT_FOUND), null);
                        }
                    }
                },
                function (Req, Profile, Done) {
                    return Done(null, {
                        email: Profile.nameID
                    });
                },
                null
            )
        );
    }

    logout(req: any, res: any) {
        (passport as any)._strategy('saml').logout(req, function (err, logoutUrl) {
            if (err) {
                console.log({ err });
                return res.status(500).send('Error during logout');
            }

            console.log({ logoutUrl });
            return res.redirect(logoutUrl);
        });
    }

but i get following error in Microsoft AADSTS7500525: There was an XML error in the SAML message at line 1, position 445. Verify that the XML content of the SAML messages conforms to the SAML protocol specifications.

ehabAbdelMawla commented 2 months ago

image