Skip to content

Support private repositories in remote sources - #10

Merged
MrPunyapal merged 5 commits into
mainfrom
feat/private-source-auth
Aug 22, 2026
Merged

Support private repositories in remote sources#10
MrPunyapal merged 5 commits into
mainfrom
feat/private-source-auth

Conversation

@MrPunyapal

Copy link
Copy Markdown
Owner

What

Remote sources can now authenticate to private Git repositories.

  • New SourceCredentials resolver. Manifest entries accept an optional token key and an optional username key (default x-access-token).
  • Token values in the form ${ENV_VAR} resolve from the environment at sync time. A variable that is not set produces a clear configuration error naming the variable and the target.
  • Without a token key, fallbacks apply: DOCSMITH_TOKEN works for any host, then GITHUB_TOKEN or GH_TOKEN but only when the repository host is github.com, so a GitHub Actions token is never sent to third-party hosts.
  • SourceSynchronizer passes resolved credentials to git-reader 0.2 through withCredentials().
  • When a repository cannot be found and no credentials were resolved, the error now suggests that the repository may be private and how to provide a token.

Why

docsmith.sources.php currently only supports public repositories, which blocks syncing internal packages. Authentication belongs at the transport layer, so git-reader 0.2 gained HTTP basic auth and this change wires manifest configuration into it without docsmith knowing any transport details.

Notes for review

  • Requires mrpunyapal/git-reader 0.2.0 (released).
  • md/remote-sources.md documentation updates are intentionally not part of this branch yet and will follow after review.
  • The token test suite covers env references, missing variables, literal passthrough, fallback priority, the github.com host guard, and username defaults.

pint, phpstan, and pest pass (81 tests, 296 assertions).

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e44eaf2c-0e0f-4712-ba71-7d80ba48c881

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@MrPunyapal
MrPunyapal marked this pull request as ready for review August 22, 2026 12:34
Add environment-based credential resolution when fetching remote Git
sources:

- New Docsmith\RemoteSources\SourceCredentials resolves a per-source
  token: explicit 'token' => '\' references (missing variables
  throw InvalidSourcesConfiguration naming the variable and target),
  literal tokens, or automatic fallbacks — DOCSMITH_TOKEN for any HTTPS
  host, GITHUB_TOKEN/GH_TOKEN only ever for github.com. Fallbacks are
  never attached to plain-HTTP repositories.
- DocumentationSource accepts optional 'token' and 'username' manifest
  keys (default username: x-access-token).
- SourceSynchronizer attaches resolved credentials via
  RemoteRepository::withCredentials() and appends a private-repository
  hint to RepositoryNotFoundException failures raised without
  credentials.
- Bump mrpunyapal/git-reader to ^0.2; tests run against the currently
  pinned release through a conditional compatibility shim.
@MrPunyapal
MrPunyapal force-pushed the feat/private-source-auth branch from 87577b7 to 946a428 Compare August 22, 2026 16:18
@MrPunyapal
MrPunyapal merged commit 8285743 into main Aug 22, 2026
6 checks passed
@MrPunyapal
MrPunyapal deleted the feat/private-source-auth branch August 25, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant