From 99a50cad7b6b365d77adafdd2b0d036d4607f23a Mon Sep 17 00:00:00 2001 From: tdurieux Date: Thu, 10 Sep 2026 18:20:56 +0200 Subject: [PATCH] feat: unify GitHub sign-in and connect OAuth for gists --- docs/github-app-setup.md | 19 ++++++--- public/asset-manifest.json | 2 +- public/i18n/locale-en.json | 2 +- public/partials/anonymize.htm | 6 +++ public/partials/signin.htm | 19 ++++++--- public/script/app.js | 31 ++++++++++++-- public/script/routes.js | 2 +- public/script/vendor.min.js | 42 +++++++++--------- src/server/routes/auth-utils.ts | 15 +++++++ src/server/routes/connection.ts | 43 +++++++++++++++++-- src/server/routes/github-app.ts | 15 +++++-- test/credential-migration.test.js | 2 +- test/frontend-regressions.test.js | 2 +- test/github-app.test.js | 66 +++++++++++++++++++++++++++-- test/production-regressions.test.js | 2 +- test/vue-ui.test.js | 36 +++++++++++++++- 16 files changed, 251 insertions(+), 53 deletions(-) diff --git a/docs/github-app-setup.md b/docs/github-app-setup.md index 5901a73..4512d78 100644 --- a/docs/github-app-setup.md +++ b/docs/github-app-setup.md @@ -77,10 +77,15 @@ Do not rerun plaintext cleanup just to enable the App. ## User flow -Sign in offers App and OAuth choices. Both resolve the same existing account by -its GitHub numeric user ID. A signed-in user cannot attach a different GitHub -identity. Legacy accounts without a verified GitHub ID require account recovery; -App login never automatically links by username or email. +Sign in offers one GitHub App button and resolves existing accounts by GitHub +numeric user ID. Signing in preserves existing OAuth credentials and resource +bindings. If the App is disabled, the button uses OAuth instead. + +An older account without a GitHub ID receives a one-time recovery prompt. The +user verifies the previous OAuth connection, then resumes App authorization. +Recovery is bound to the expected account and GitHub ID and expires after ten +minutes. A signed-in user cannot attach a different GitHub identity. App login +never automatically links by username or email. On the anonymization form, **Connect read-only GitHub access** starts user authorization and then repository installation. **Allow repository access on @@ -93,7 +98,11 @@ after approval** on the Connections page when approval is delayed. App-connected accounts default to the App for new repository/PR access. The explicit **Use existing OAuth access** choice handles repositories not yet available through the App. An App error never silently selects OAuth. Gists -continue using OAuth in this release. +continue using OAuth. An App-only user entering a gist URL is prompted to connect +OAuth, with the current repository permission scope explained. The form draft +is saved for 30 minutes and restored after authorization. Users with an existing +OAuth connection can use it immediately. OAuth remains available on the +Connections page, separate from sign-in. **GitHub connections** lists each resource's current connection. First check read-only access, then switch the resource. The switch validates the existing diff --git a/public/asset-manifest.json b/public/asset-manifest.json index c003a38..fb4b6ce 100644 --- a/public/asset-manifest.json +++ b/public/asset-manifest.json @@ -1,6 +1,6 @@ { "core.min.js": "core.c5bd53363a.min.js", - "vendor.min.js": "vendor.cc9fc42458.min.js", + "vendor.min.js": "vendor.3188bc70a6.min.js", "mermaid.min.js": "mermaid.f848a72d16.min.js", "all.min.css": "all.87fb103470.min.css", "markdown.min.js": "markdown.ad7b1d71c3.min.js", diff --git a/public/i18n/locale-en.json b/public/i18n/locale-en.json index 34cb77c..723c04b 100644 --- a/public/i18n/locale-en.json +++ b/public/i18n/locale-en.json @@ -130,7 +130,7 @@ "invalid_webhook_signature": "The webhook signature is invalid.", "webhook_processing_failed": "Webhook processing failed. Retry the delivery.", "github_app_authorization_cancelled": "GitHub authorization was cancelled.", - "github_account_link_required": "This username belongs to an existing account. Sign in with legacy GitHub OAuth to keep access to your existing anonymizations, then connect the read-only GitHub App from GitHub connections.", + "github_account_link_required": "Verify your existing account with your previous GitHub connection. Future sign-ins will use the GitHub App.", "github_app_refresh_busy": "GitHub credentials are being renewed. Please retry shortly.", "github_grant_revocation_failed": "Unable to revoke the GitHub grant. Please retry.", "another_login_required": "Connect and verify another sign-in method before disconnecting OAuth.", diff --git a/public/partials/anonymize.htm b/public/partials/anonymize.htm index 70a1727..2b6e772 100644 --- a/public/partials/anonymize.htm +++ b/public/partials/anonymize.htm @@ -24,6 +24,12 @@ Repository, pull request (…/pull/42) and gist (gist.github.com/…) URLs are all accepted. +