function enableSaml(config) {
  if (config.samlAuthConfigured()) {
    appLog.info('Enabling SAML authentication strategy.');

    const samlEnforcedRole =
      config.get('samlEnforcedRole') === 'true' ||
      config.get('samlEnforcedRole') === true;

    /**
     * @type string
     */
    const samlAdminGroup = config.get('samlAdminGroup');

    /**
     * It is best to keep this 'editor' and use claims to manage admin role for SQLPAD.
     * @type string
     */
    const samlDefaultRole = config.get('samlDefaultRole');

    // FIX: https://github.com/node-saml/passport-saml/blob/v3.1.2/src/node-saml/types.ts#L101
    let samlAuthContext = config.get('samlAuthContext');
    if (samlAuthContext && !Array.isArray(samlAuthContext)) {
      samlAuthContext = [samlAuthContext];
    }

    passport.use(
      'saml',
      new SamlStrategy(
        {
          passReqToCallback: true,
          path: '/login/callback',
          entryPoint: config.get('samlEntryPoint'),
          issuer: config.get('samlIssuer'),
          callbackUrl: config.get('samlCallbackUrl'),
          cert: config.get('samlCert'),
          authnContext: samlAuthContext,
          identifierFormat: null,
        },
        async function (req, p, done) {
          const email = p[CLAIMS.emailaddress];
          // If email is not provided - no auth
          if (!email) {
            return done(null, false);
          }

          const name = getSamlName(p);

          const { models, webhooks } = req;

          let user = await models.users.findOneByEmail(email);

          /** @type string */
          const samlAssignedRole = getSamlRole(
            p,
            samlAdminGroup,
            samlDefaultRole
          );

          if (user) {
            if (user.disabled) {
              return done(null, false);
            }
            if (samlEnforcedRole && user.role !== samlAssignedRole) {
              appLog.debug(
                `User '${email}' role changed to '${samlAssignedRole}' based on SAML attributes`
              );
              user = await models.users.update(user.id, {
                name,
                role: samlAssignedRole,
                signupAt: new Date(),
              });
            }
            return done(null, user);
          }

          // If auto sign up is turned on create user
          if (config.get('samlAutoSignUp')) {
            appLog.debug(
              `User '${email}' created with role '${samlAssignedRole}' based on SAML attributes`
            );
            const newUser = await models.users.create({
              name,
              email,
              role: samlAssignedRole,
              signupAt: new Date(),
            });
            webhooks.userCreated(newUser);
            return done(null, newUser);
          }

          return done(null, false);
        }
      )
    );
  }
}
Adds passport SAML strategy if SAML is configured
@param {object} config