Skip to content

[Bug]: GitHub Enterprise host is ignored — auth resolution and sync are hardcoded to github.com #597

Description

@steven-terrana

Preflight

  • I searched existing issues and this isn't a duplicate
  • I'm on the latest version (or I've noted my version below)

What happened?

I have gh logged into two hosts: github.com (personal) and a GitHub Enterprise Server instance. When working with OpenKnowledge, ok uses my public github.com identity even when the workspace's git remote points at the enterprise host. I expected ok to resolve credentials/identity for the host the repo actually lives on, and I couldn't find any config key or env var to change the default host.

Digging into the source, the --host flag on the ok auth subcommands is host-aware, but several core paths are hardcoded to github.com:

  • packages/cli/src/auth/resolve-auth.ts:42resolveAuth calls detectGh() with no host, so gh auth token returns the default (github.com) token and Tier A wins even when the repo's remote is a GHES host.
  • packages/server/src/sync-engine.ts:68SYNC_GH_TOKEN_HOST = 'github.com'; the gh token relayed into every sync git subprocess (OK_GH_TOKEN/OK_GH_TOKEN_HOST) is always the github.com one.
  • packages/server/src/sync-engine.ts:865,876 — the push-permission probe passes host: 'github.com' unconditionally.
  • packages/server/src/share/git-context.ts:168-191parseGitHubOriginUrl only matches github.com remotes; enterprise remotes classify as non-github, downgrading the push-permission check to unknown.
  • packages/app/src/lib/transports/auth-query-transport.ts:25 — the app UI always queries auth status/repos for github.com, so it displays the public profile regardless of the workspace's remote.

Suggested direction (happy to open a PR):

  1. Thread the host parsed from the workspace's origin remote into resolveAuth/detectGh instead of defaulting to github.com.
  2. Derive SYNC_GH_TOKEN_HOST and the push-permission probe host from the repo's origin host.
  3. Widen parseGitHubOriginUrl to recognize GHES hostnames.

Steps to reproduce

  1. gh auth login on both github.com and a GitHub Enterprise Server host.
  2. Open (or sync) an OpenKnowledge workspace whose git origin points at the enterprise host.
  3. Observe that auth/identity (sync token relay, push-permission check, profile shown in the app) resolves to the github.com account instead of the enterprise one.

Platform

macOS (Apple Silicon)

How did you install OpenKnowledge?

CLI (npm / npx)

Version

0.28.2

Logs, errors, or screenshots

$ gh auth status
github.<enterprise-host>
  ✓ Logged in to github.<enterprise-host> account <enterprise-user> (keyring)
github.com
  ✓ Logged in to github.com account <public-user> (keyring)

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions