Remove unused Forge GitHub create and OAuth integration - #15812
Conversation
There was a problem hiding this comment.
Pull request overview
This PR strengthens the Grails Forge GitHub OAuth flow by persisting the OAuth state in a path-scoped HttpOnly cookie and validating it on callback endpoints before proceeding, including support for multiple outstanding states.
Changes:
- Add state generation, persistence, validation, and consumption via a path-scoped OAuth state cookie.
- Enforce state validation for both normal and error callbacks, rejecting missing/mismatched state before exchanging OAuth codes.
- Add a new Spock spec covering redirect/callback state cookie behavior, including multiple outstanding flows.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| grails-forge/grails-forge-api/src/test/groovy/org/grails/forge/api/create/github/GitHubOAuthStateSpec.groovy | Adds test coverage for OAuth state cookie issuance, validation, and consumption across redirect/callback scenarios. |
| grails-forge/grails-forge-api/src/main/java/org/grails/forge/api/create/github/GitHubRedirectService.java | Introduces cookie construction/expiry/consumption helpers and wires state into the GitHub authorize URL. |
| grails-forge/grails-forge-api/src/main/java/org/grails/forge/api/create/github/GitHubCreateController.java | Applies state validation and cookie mutation rules to the create endpoint and the OAuth error callback endpoint. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| throw e; | ||
| } else { | ||
| return HttpResponse.temporaryRedirect(redirectService.constructGrailsForgeErrorRedirectUrl(e.getMessage())); | ||
| return consumeOAuthStateCookie(HttpResponse.temporaryRedirect(redirectService.constructGrailsForgeErrorRedirectUrl(e.getMessage())), requestInfo, state); |
| if (!hasValidOAuthState(state)) { | ||
| return rejectInvalidOAuthState(redirectService.getLauncherURI()); | ||
| } | ||
| redirect = redirectService.constructGrailsForgeErrorRedirectUrl(errorDescription); |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 8.0.x #15812 +/- ##
==================================================
- Coverage 52.3514% 52.3431% -0.0083%
+ Complexity 18299 18296 -3
==================================================
Files 2036 2036
Lines 96347 96347
Branches 16829 16829
==================================================
- Hits 50439 50431 -8
- Misses 38485 38492 +7
- Partials 7423 7424 +1 🚀 New features to boost your workflow:
|
|
Didn't we remove the ui part of create in github? Why not just remove the function completely |
jdaugherty
left a comment
There was a problem hiding this comment.
It's my understanding we removed the ability to deploy to a github repo. We should remove the functionality rather than maintain it.
|
Worth clarifying the current state, because "we removed the ability to deploy to a github repo" is only half-true in this repo - and the half that's left is the risky one. What was removed is the UI: the "Create in GitHub" action lives in the separate
And critically, the So we currently ship live, reachable OAuth endpoints with an unhardened
I'm happy either way. If the decision is to retire, I'll convert this into the backend-removal PR instead. But if any of those |
|
@jamesfredley right, we didn't remove in forge backend, but why are we maintaining instead of removing it? |
|
This was removed from the UI a long time ago and just needs to be removed from the server side. It is not used. |
The start.grails.org UI removed Push to GitHub (grails-forge-ui#61). Delete the unused server-side create/OAuth/push stack, related config, JGit dependency, native-image metadata, and deployment secrets so the API no longer accepts GitHub OAuth create flows. Keep generated-app GitHub Actions workflow features and the browser redirect URL used by the Forge UI. Also fix setRedirectUrl so GITHUB_REDIRECT_URL actually overrides the default, and purge retired OAuth env vars from Cloud Run on deploy. Assisted-by: Sisyphus:xai/grok-4.5
6db0745 to
bfa1f8e
Compare
|
Cleaning this up once and for all on both ends. Backend (this PR): remove the unused Forge GitHub create / OAuth / push stack that the API still exposed after the UI dropped the button. Frontend companion: apache/grails-forge-ui#159 scrubs the leftover Launch UI residue (github href helpers, OAuth callback routing, clone NextSteps, Together these match the UI change from grails-forge-ui#61 so neither side keeps a half-dead create-on-GitHub path. |
✅ All tests passed ✅🏷️ Commit: a1e526f Learn more about TestLens at testlens.app. |
borinquenkid
left a comment
There was a problem hiding this comment.
Verified all review feedback is addressed:
- jdaugherty's changes-requested (2026-07-09: "remove the functionality rather than maintain it") is resolved — the PR was rewritten (commit bfa1f8e, 2026-07-29) from OAuth-state hardening to full removal of the unused Forge GitHub create/OAuth/push backend, matching that request.
- Copilot's 3 inline comments all targeted code in
GitHubCreateController.javaandGitHubRedirectService.java, both of which are now fully deleted in the diff — the flagged issues no longer exist.
Approving; jdaugherty to re-review given the rewrite.
Summary
Rewrites this PR from OAuth-state hardening to full removal of the unused Forge server-side GitHub create / OAuth / push integration.
The start.grails.org UI removed "Push to GitHub" in grails-forge-ui#61 (2025-07). The server endpoints and OAuth app wiring were left behind. Maintaining them (including state validation) is unnecessary attack surface.
What was removed
GitHubCreateControllerand related create/OAuth/redirect services, DTOs, clients, and testsGitHubUtil(JGit push helper) and theorg.eclipse.jgitdependencyGrailsForgeConfiguration.GitHubConfigurationandapplication.ymlOAuth/API client configGITHUB_OAUTH_APP_*,GITHUB_USER_AGENT), with--remove-env-varsso existing services drop them on next deployWhat was kept
feature/github/workflows/**)GITHUB_REDIRECT_URL/grails.forge.redirect-urlfor browser redirect to the Forge UIAdditional fix
GrailsForgeConfiguration.setRedirectUrlpreviously self-assigned and ignored config; it now applies the provided URL (covered byGrailsForgeConfigurationSpec)Test plan
./gradlew :grails-forge-api:test :grails-forge-core:test :grails-forge-web-netty:compileJava(fromgrails-forge/)GrailsForgeConfigurationSpecfor redirect overrideFollow-ups (ops / UI)
getGitHubLink/ callback query handling) in grails-forge-ui