Skip to content

fix: host-aware GitHub token resolution for multi-host environments #93

@erishforG

Description

@erishforG

Problem

PARSEC_GITHUB_TOKEN is a single env var — it can't distinguish between hosts. When working across github.com (personal) and GitHub Enterprise (work), the wrong token gets used → 401.

Solution

Add per-host token config in parsec config:

[github."github.com"]
token = "ghp_personal_xxx"

[github."github.daumkakao.com"]
token = "ghp_work_yyy"

Token resolution priority:

  1. config.github.<remote_host>.token — host-specific config
  2. PARSEC_GITHUB_TOKEN env var — explicit override
  3. GITHUB_TOKEN / GH_TOKEN — generic fallback
  4. gh auth token --hostname <host> — CLI fallback

Implementation

  • Parse remote URL to detect host (already done via GitHubRemote)
  • Pass host to resolve_github_token(host)
  • Add GithubHostConfig struct with token field
  • Add github: HashMap<String, GithubHostConfig> to ParsecConfig
  • Update config show to display configured hosts (mask tokens)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions