fix(github): repair GitHub App registration and installation auth (#2511)

Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
This commit is contained in:
Nazar
2026-08-12 13:13:05 +03:00
committed by GitHub
parent a63cbf3d85
commit f82d841955
23 changed files with 259 additions and 95 deletions
@@ -13,7 +13,7 @@ const preparation: PrepareGitHubAppImportResponse = {
install_callback_url: "https://kandev.example/install/callback",
personal_callback_url: "https://kandev.example/personal/callback",
webhook_url: "https://kandev.example/webhook",
setup_url: "https://kandev.example/install/callback",
setup_url: "",
permissions: { contents: "write" },
events: ["installation"],
expires_at: "2026-07-22T00:00:00Z",
@@ -12,7 +12,7 @@ const preparation: PrepareGitHubAppImportResponse = {
install_callback_url: "https://kandev.example/install/callback",
personal_callback_url: "https://kandev.example/personal/callback",
webhook_url: "https://kandev.example/webhook",
setup_url: "https://kandev.example/install/callback",
setup_url: "",
permissions: { contents: "write" },
events: ["installation"],
expires_at: "2026-07-22T00:00:00Z",
@@ -27,8 +27,17 @@ describe("GitHubAppImportGuide", () => {
/>,
);
expect(screen.getByText("Homepage URL")).toBeTruthy();
expect(screen.getByText("User authorization callback URL")).toBeTruthy();
expect(screen.getByText("Setup URL")).toBeTruthy();
expect(screen.getByText("User authorization callback URL 1")).toBeTruthy();
expect(screen.getByText("User authorization callback URL 2")).toBeTruthy();
expect(
screen
.getAllByText(/^https:\/\/kandev\.example\/(?:install|personal)\/callback$/)
.map((element) => element.textContent),
).toEqual([
"https://kandev.example/install/callback",
"https://kandev.example/personal/callback",
]);
expect(screen.queryByText("Setup URL")).toBeNull();
expect(screen.getByText("Webhook URL")).toBeTruthy();
expect(screen.getByText(/application\/json/)).toBeTruthy();
expect(screen.getByText(/SSL verification enabled/)).toBeTruthy();
@@ -10,13 +10,13 @@ import { Trans, useTranslation } from "react-i18next";
import { formatDateTime } from "@/lib/i18n/formats";
// These are the verbatim field names on GitHub's own "Register a new GitHub App"
// form, which is English-only. The guide tells the user which field to paste each
// value into, so translating them would break that mapping — they are references
// to another product's UI, not our copy.
// form, which is English-only. The numeric suffixes preserve the order GitHub
// uses for OAuth during installation; they are references to another product's
// UI, not our copy.
const urlLabels: [keyof PrepareGitHubAppImportResponse, string][] = [
["public_base_url", "Homepage URL"],
["personal_callback_url", "User authorization callback URL"],
["setup_url", "Setup URL"],
["install_callback_url", "User authorization callback URL 1"],
["personal_callback_url", "User authorization callback URL 2"],
["webhook_url", "Webhook URL"],
];
@@ -8,6 +8,7 @@ import {
validateImportSecrets,
validateRegistrationBasics,
} from "./github-app-onboarding-model";
import { githubAppEvents } from "./github-app-policy-dialog";
describe("GitHub App onboarding model", () => {
it("requires a public HTTPS origin", () => {
@@ -64,4 +65,8 @@ describe("GitHub App onboarding model", () => {
submit.mockRestore();
form?.remove();
});
it("lists only configurable GitHub App webhook subscriptions", () => {
expect(githubAppEvents).toEqual(["push", "check_run"]);
});
});
@@ -25,11 +25,7 @@ export const githubAppPermissions: Record<string, "read" | "write"> = {
workflows: "write",
};
export const githubAppEvents = [
"installation",
"installation_repositories",
"github_app_authorization",
];
export const githubAppEvents = ["push", "check_run"];
function title(value: string) {
return value.replaceAll("_", " ").replace(/\b\w/g, (letter) => letter.toUpperCase());