You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried using idp.loginRequestParser to parse context data, but it threw an error saying the allowCreate field is invalid and must be set to true. So, I went to the SP settings, set allowCreate to true, and tried creating a new SP login request, but then it threw this error : [Nest] 16677 - 11/04/2024, 6:30:05 PM ERROR [ExceptionsHandler] string.replace is not a function
this is my code :
SP config
getSP(uid: string): ServiceProviderInstance{constconfig: ServiceProviderSettings=this.getSPConfig(uid);constsp: ServiceProviderInstance=ServiceProvider(config);returnsp;}getSPConfig(uid: string): ServiceProviderSettings{constspLoginURL=`http://localhost:3000/saml/sp/authenticate/${uid}/`;constconfig: ServiceProviderSettings={// Basic Service Provider Configuration// Unique identifier for the Service ProviderentityID: 'SPExampleEntityID',// Optional: Allows IdP to create NameIDs dynamicallyallowCreate: true,// Assertion Consumer Service endpointsassertionConsumerService: [{Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',Location: spLoginURL,},{Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Artifact',Location: spLoginURL,},{Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',Location: spLoginURL,// Sets the default binding for SSO responses// isDefault: true,},{Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST-SimpleSign',Location: spLoginURL,},],// Single Logout Service endpointssingleLogoutService: [{Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect',Location: `http://localhost:3000/saml/sp/logout/${uid}/`,},{Binding: 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST',Location: `http://localhost:3000/saml/sp/logout/${uid}/`,},],// Security settings for signing and encryptionauthnRequestsSigned: true,// Specifies if the SP signs AuthnRequestswantAssertionsSigned: true,// Indicates if the SP expects signed assertions// Certificates and Keys for Signing and EncryptionsigningCert: readFileSync(join(SP_KEY_PATH,'cert.cer')).toString('utf8'),privateKey: readFileSync(join(SP_KEY_PATH,'privkey.pem')).toString('utf8'),privateKeyPass: 'privateKeyPass',// Passphrase for the private keyisAssertionEncrypted: true,// Specifies if assertions must be encryptedencPrivateKey: readFileSync(join(SP_KEY_PATH,'encryptKey.pem')).toString('utf8'),encPrivateKeyPass: 'encPrivateKeyPass',// Supported NameID formats for assertionsnameIDFormat: ['urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress','urn:oasis:names:tc:SAML:2.0:nameid-format:persistent','urn:oasis:names:tc:SAML:2.0:nameid-format:transient',],// Signature configurationssignatureConfig: {// XML namespace prefix for signaturesprefix: 'ds',location: {reference:
"/*[local-name(.)='AuthnRequest']/*[local-name(.)='Issuer']",// Specifies location of the signature within XMLaction: 'after',},},// Algorithm settings for encryption and signing// Signing algorithmrequestSignatureAlgorithm:
'http://www.w3.org/2001/04/xmldsig-more#rsa-sha256',};returnconfig;}
Main SP service :
asyncspLogin(res: Response){// Get the IDP and SP instancesconstidp=this.idpService.getIDP('uid');constsp=this.spService.getSP('uid');// The binding valid values: 'BindingType.Post', 'BindingType.Redirect'// Set binding// @todo: Binding will be set from the IDP/SP configsconstbinding=BindingType.Post;// Generate SAMLRequestconst{ context }=awaitthis.spService.generateSAMLRequest(idp,sp,binding);// Build SAMLRequestconstresponse=awaitthis.spService.buildSAMLRequest(idp,binding,context);// Send SAMLRequest to the IDP, based on the binding it will be a redirect or post requestawaitthis.spService.sendSAMLRequest(res,binding,response);}
[Nest] 16677 - 11/04/2024, 6:30:05 PM ERROR [ExceptionsHandler] string.replace is not a function
TypeError: string.replace is not a function
at escape (/home/shy/Desktop/IDmelon/feder/node_modules/xml-escape/index.js:11:17)
at <anonymous> (/home/shy/Desktop/IDmelon/feder/node_modules/samlify/src/libsaml.ts:245:42)
at String.replace (<anonymous>)
at <anonymous> (/home/shy/Desktop/IDmelon/feder/node_modules/samlify/src/libsaml.ts:268:25)
at Array.forEach (<anonymous>)
at Object.replaceTagsByValue (/home/shy/Desktop/IDmelon/feder/node_modules/samlify/src/libsaml.ts:267:30)
at Object.base64LoginRequest (/home/shy/Desktop/IDmelon/feder/node_modules/samlify/src/binding-post.ts:36:32)
at ServiceProvider.ServiceProvider.createLoginRequest (/home/shy/Desktop/IDmelon/feder/node_modules/samlify/src/entity-sp.ts:74:31)
at SAMLSPUtilsService.generateSAMLRequest (/home/shy/Desktop/IDmelon/feder/src/saml/utils/sp.service.ts:110:32)
at SAMLSPService.spLogin (/home/shy/Desktop/IDmelon/feder/src/saml/sp/sp.service.ts:25:46)
How I fixed it :
just downgrade from 2.8.11 to 2.8.10
The text was updated successfully, but these errors were encountered:
I tried using idp.loginRequestParser to parse context data, but it threw an error saying the allowCreate field is invalid and must be set to true. So, I went to the SP settings, set allowCreate to true, and tried creating a new SP login request, but then it threw this error :
[Nest] 16677 - 11/04/2024, 6:30:05 PM ERROR [ExceptionsHandler] string.replace is not a function
this is my code :
How I fixed it :
just downgrade from 2.8.11 to 2.8.10
The text was updated successfully, but these errors were encountered: