Unable to login with SSO neither with username/password

After enabling SSO for testing I can’t log in. Neither with SSO or Username/password.

When using SSO I get an error:

string.replace is not a function
*string.replace is not a function*

When I click on email login I get: " SSO is enabled, please log in with SSO"

Is there any way to log in?

n8n-1  | Error: TypeError: string.replace is not a function
n8n-1  |     at ErrorReporter.defaultReport (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/errors/error-reporter.js:62:15)
n8n-1  |     at ErrorReporter.error (/usr/local/lib/node_modules/n8n/node_modules/n8n-core/dist/errors/error-reporter.js:194:18)
n8n-1  |     at reportError (/usr/local/lib/node_modules/n8n/dist/response-helper.js:104:54)
n8n-1  |     at /usr/local/lib/node_modules/n8n/dist/response-helper.js:116:17
n8n-1  |  {"file":"error-reporter.js","function":"defaultReport"}
n8n-1  | Error object received in defaultReport: TypeError: string.replace is not a function
n8n-1  |     at escape (/usr/local/lib/node_modules/n8n/node_modules/xml-escape/index.js:11:17)
n8n-1  |     at /usr/local/lib/node_modules/n8n/node_modules/samlify/build/src/libsaml.js:208:77
n8n-1  |     at String.replace (<anonymous>)
n8n-1  |     at /usr/local/lib/node_modules/n8n/node_modules/samlify/build/src/libsaml.js:228:33
n8n-1  |     at Array.forEach (<anonymous>)
n8n-1  |     at Object.replaceTagsByValue (/usr/local/lib/node_modules/n8n/node_modules/samlify/build/src/libsaml.js:227:36)
n8n-1  |     at Object.loginRequestRedirectURL (/usr/local/lib/node_modules/n8n/node_modules/samlify/build/src/binding-redirect.js:112:48)
n8n-1  |     at ServiceProvider.createLoginRequest (/usr/local/lib/node_modules/n8n/node_modules/samlify/build/src/entity-sp.js:86:51)
n8n-1  |     at SamlService.getRedirectLoginRequestUrl (/usr/local/lib/node_modules/n8n/dist/sso.ee/saml/saml.service.ee.js:176:33)
n8n-1  |     at SamlService.getLoginRequestUrl (/usr/local/lib/node_modules/n8n/dist/sso.ee/saml/saml.service.ee.js:169:31)
n8n-1  |     at processTicksAndRejections (node:internal/process/task_queues:95:5)
n8n-1  |     at SamlController.handleInitSSO (/usr/local/lib/node_modules/n8n/dist/sso.ee/saml/routes/saml.controller.ee.js:138:24)
n8n-1  |     at SamlController.initSsoGet (/usr/local/lib/node_modules/n8n/dist/sso.ee/saml/routes/saml.controller.ee.js:132:16)
n8n-1  |     at handler (/usr/local/lib/node_modules/n8n/dist/decorators/controller.registry.js:93:24)
n8n-1  |     at /usr/local/lib/node_modules/n8n/dist/response-helper.js:111:26

I found the issue is here:

var escape = module.exports = function escape(string, ignore) {
  var pattern;

  if (string === null || string === undefined) return;

  ignore = (ignore || '').replace(/[^&"<>\']/g, '');
  pattern = '([&"<>\'])'.replace(new RegExp('[' + ignore + ']', 'g'), '');
  // TODO bug here, string is an object
  return string.replace(new RegExp(pattern, 'g'), function(str, item) {
            return escape.map[item];
          })
}

var map = escape.map = {
    '>': '&gt;'
  , '<': '&lt;'
  , "'": '&apos;'
  , '"': '&quot;'
  , '&': '&amp;'
}

Hello, I hope you are well.

Check this solution below.

var escape = module.exports = function escape(string, ignore) {
var pattern;

if (string === null || string === undefined) return ‘’;
string = String(string); // Ensure string is a string

ignore = (ignore || ‘’).replace(/[^&“<>']/g, ‘’);
// Escape special characters in the regex
var escapedIgnore = ignore.replace(/[-{}()*+?.,\^$|#\s]/g, ‘\$&’);
pattern = '([&”<>'])‘.replace(new RegExp(’[’ + escapedIgnore + ‘]’, ‘g’), ‘’);

return string.replace(new RegExp(pattern, ‘g’), function(str, item) {
return escape.map[item];
});
};

var map = escape.map = {
‘>’: ‘>’,
‘<’: ‘<’,
“'”: ‘'’,
‘"’: ‘"’,
‘&’: ‘&’
};

@vladaman did you have any luck with a solution here? i’m having the same issue. i’m using the docker image for n8n v1.89.2

was hoping to stick to the image and not have to deal with internal packages

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.