Bugfix Issue 813 GitHub OAuth Install Config - sebiboga/testlink-upgraded GitHub Wiki
Bugfix: Issue #813 — GitHub connect button always reports "OAuth not configured" on a fresh install
Summary
On a fresh TestLink 2.0.1 install the GitHub connect button on the Issue
Trackers screen (gui/templates/issuetracker/issuetrackerView.html) always
alerted:
GitHub OAuth is not configured (missing oauth_client_id/oauth_client_secret)
The GitHub issue/BTS integration was unreachable out of the box: the required OAuth credentials were never collected anywhere and no local config file was produced by the installer.

Root Cause
api/issuetracker/index.php:151-171—gh_oauth_config()is the single source of truth for GitHub OAuth credentials for the Issue Tracker. It returnsnullwhenevercfg/oauth_github_local.inc.phpis missing, not loadable, or holds empty/CHANGE_*placeholder values.api/issuetracker/index.php:255-260(GET /oauth/start) and:279-284(/oauth/callback) short-circuit to HTTP 503 with the "not configured" message whenevergh_oauth_config()is null.gui/templates/issuetracker/issuetrackerView.html:263-281—githubOAuthStart()alert()s the server message on the error path.- The config file was never produced: the 1.9.20-era installer
(
install/installDbInput.php/install/installNewDB.php) had no GitHub OAuth fields and never wrotecfg/oauth_github_local.inc.php. So every fresh install ran with null config and the button hard-failed.
Blast radius: the affected code is confined to the GitHub-OAuth paths of
api/issuetracker/index.php and its only modernized client
(gui/templates/issuetracker/issuetrackerView.html). The login-page OAuth
subsystem (login.php, api/auth/index.php, lib/functions/oauth_api.php)
reads the same $tlCfg->OAuthServers map for authentication providers but is
independent: an absent local config file changes nothing there.
Fix
Issue #813 was implemented by commit b767d45c0 (feat(install): collect GitHub OAuth credentials at install time and generate local config, already on the default
branch). No backend change was needed — gh_oauth_config() already reads
cfg/oauth_github_local.inc.php:
- Installer form (
install/installDbInput.php:215-242, gated on new installs$_SESSION['isNew']): optional "GitHub OAuth" section with an enable checkbox,oauth_client_idandoauth_client_secretfields, plus a hint showing the required Authorization callback URL (/api/issuetracker/index.php/oauth/callback). - Config generation (
install/installNewDB.php:679-713,write_oauth_github_config(), invoked at:570): copies the POSTed values through$_SESSION(installNewDB.php:46-53), validates them (rejectsCHANGE_*placeholders, skips silently when disabled/empty), and writescfg/oauth_github_local.inc.phpwith mode 0600. - Documentation (
cfg/oauth_github_local.inc.php.example): documents the manual path (copy tocfg/oauth_github_local.inc.php, replace placeholders) and where to create the OAuth App. - Because the local file is gitignored (
.gitignore:54), secrets can never be committed.
Verification (measured)
Reproduced on http://localhost:8082 (admin session, fresh DB import):
- Pre-config:
GET /api/issuetracker/index.php/oauth/start→ HTTP 503{"status":"error","message":"GitHub OAuth is not configured (missing oauth_client_id/oauth_client_secret)"}; clicking GitHub alerts the same. - Post-config (config file in the exact format
write_oauth_github_config()emits):GET /oauth/start→ HTTP 200{"status":"ok","url":"https://github.com/login/oauth/authorize?client_id=…"}and the UI button opens a real GitHub authorize popup (no alert).

- Generated-file format validated standalone:
php -lclean; loads into$tlCfg->OAuthServers['github']exactly asgh_oauth_config()expects; file mode 600. - Event Viewer: no new Error/Warning rows from the flow.
When credentials are genuinely missing the button still warns — that is the intended behaviour after the fix.
Commits: b767d45c0 (fix, default branch). Regression suite:
tmp/TLU_Test_Cases.md Suite 818 (12/12 PASS).