Repository navigation
Conversation
Lorena-J
left a comment
There was a problem hiding this comment.
The built-in GitHub configuration makes connecting from the Mac app much simpler. I’d request one change before merging. Please scope native browser opening to local launches so users on self-hosted instances behind a reverse proxy can still open GitHub from their own browser. The web build and targeted GitHub Go tests passed. Live GitHub authorization in the Mac app still needs a manual check.
| if id := cmp.Or(os.Getenv("REFRACT_GITHUB_CLIENT_ID"), opts.githubClientID); id != "" { | ||
| ra.github = &github.Client{HTTP: outbound, ClientID: id, Web: "https://github.com", API: "https://api.github.com"} | ||
| } | ||
| if onThisComputer(ln.Addr()) { |
There was a problem hiding this comment.
The documented Caddy and nginx setups also proxy to a loopback listener. In that setup, clicking Connect GitHub can launch the browser on the server and return opened: true, so the user has to open GitHub manually from the link in Settings. Could we enable the native browser opener only when Refract is started with refract local, including from the Mac app?
Stacked on #139 (it reuses that PR's loopback check and browser opener). Retarget to
mainonce #139 merges.In the Mac app, Connect GitHub said "GitHub sign-in is not set up on this server (REFRACT_GITHUB_CLIENT_ID)": nobody can set that variable for the app.
Changes
refract local, and so the Mac app, uses Refract's own GitHub OAuth App (Ov23liYnkF9XAiPRni54, owned by Use-Refract, device flow, public client id, no secret) whenREFRACT_GITHUB_CLIENT_IDis not set. Servers are unchanged: they still need their own app, or they show the existing "not set up" message.POST /api/github/deviceopens GitHub's device page in the browser itself and answersopened. This is the same reason as in Sign in with ChatGPT from Settings when Refract runs on this computer #139: WKWebView drops awindow.openmade after a request. The page callswindow.openonly when the server didn't open it. The server opens the address only if it is on the configured GitHub web origin, because it comes from GitHub's answer and the opener would follow any scheme.onThisComputer(addr)is shared by both features.Checks
go test ./cmd/refract/ ./internal/github/andgo vetpass. A new test covers opening GitHub's page, refusing a non-GitHub address, no opener on a server elsewhere, and a failed open.tscpasses and the i18n test passes.make macbuilds. Still to check by hand in the app: Settings → Integrations → Connect opens GitHub, and the code completes the connection.