Skip to content

Commit 0a3fc25

Browse files
fix(oauth): preserve GHEC tenant domains in OAuth endpoints
For ghe.com (GHEC), keep the full tenant domain (mycompany.ghe.com) instead of incorrectly stripping to base domain (ghe.com). Only strip api. prefix for api.github.com → github.com.
1 parent 6ea3eec commit 0a3fc25

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

internal/oauth/oauth.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -518,13 +518,10 @@ func getOAuthEndpoints(host string) (authURL, tokenURL, deviceAuthURL string) {
518518
hostname = hostname[:idx]
519519
}
520520

521-
// For github.com or ghe.com (GHEC), use the main domain
522-
if strings.HasSuffix(hostname, "github.com") || strings.HasSuffix(hostname, "ghe.com") {
523-
// Extract base domain (e.g., github.com from api.github.com)
524-
parts := strings.Split(hostname, ".")
525-
if len(parts) >= 2 {
526-
hostname = parts[len(parts)-2] + "." + parts[len(parts)-1]
527-
}
521+
// For github.com, strip api. subdomain (api.github.com → github.com)
522+
// For ghe.com (GHEC), keep the full tenant domain (mycompany.ghe.com stays as-is)
523+
if hostname == "api.github.com" {
524+
hostname = "github.com"
528525
}
529526

530527
authURL = fmt.Sprintf("%s://%s/login/oauth/authorize", scheme, hostname)

0 commit comments

Comments
 (0)