function getAuthPaths()

in src/msha/auth/index.ts [7:64]


function getAuthPaths(isCustomAuth: boolean): Path[] {
  const paths: Path[] = [];

  if (isCustomAuth) {
    const supportedAuthsRegex = SUPPORTED_CUSTOM_AUTH_PROVIDERS.join("|");

    paths.push({
      method: "GET",
      // only match for providers with custom auth support implemented (github, google, aad, facebook, twitter)
      route: new RegExp(`^/\\.auth/login/(?<provider>${supportedAuthsRegex})/callback(\\?.*)?$`, "i"),
      function: "auth-login-provider-callback",
    });
    paths.push({
      method: "GET",
      // only match for providers with custom auth support implemented (github, google, aad, facebook, twitter)
      route: new RegExp(`^/\\.auth/login/(?<provider>${supportedAuthsRegex})(\\?.*)?$`, "i"),
      function: "auth-login-provider-custom",
    });
    paths.push({
      method: "GET",
      // For providers with custom auth support not implemented, revert to old behavior
      route: /^\/\.auth\/login\/(?<provider>twitter|[a-z]+)(\?.*)?$/i,
      function: "auth-login-provider",
    });
    paths.push({
      method: "POST",
      route: /^\/\.auth\/complete(\?.*)?$/i,
      function: "auth-complete",
    });
  } else {
    paths.push({
      method: "GET",
      route: /^\/\.auth\/login\/(?<provider>github|twitter|google|facebook|[a-z0-9]+)(\?.*)?$/i,
      function: "auth-login-provider",
    });
  }

  paths.push(
    {
      method: "GET",
      route: /^\/\.auth\/me(\?.*)?$/i,
      function: "auth-me",
    },
    {
      method: "GET",
      route: /^\/\.auth\/logout(\?.*)?$/i,
      function: "auth-logout",
    },
    {
      method: "GET",
      route: /^\/\.auth\/purge\/(?<provider>aad|github|twitter|google|facebook|[a-z0-9]+)(\?.*)?$/i,
      // locally, all purge requests are processed as logout requests
      function: "auth-logout",
    },
  );

  return paths;
}