Skip to content

Add credential_hosts source param to scope HTTP(S) credentials - #483

Open
hiddingtrojans wants to merge 2 commits into
concourse:masterfrom
hiddingtrojans:credential-hosts
Open

Add credential_hosts source param to scope HTTP(S) credentials#483
hiddingtrojans wants to merge 2 commits into
concourse:masterfrom
hiddingtrojans:credential-hosts

Conversation

@hiddingtrojans

Copy link
Copy Markdown

This implements the opt-in host-list option from #482, with a regression test and README docs.

Refs #482.

What

New optional source param credential_hosts: a list of hostnames the
HTTP(S) username/password may be sent to.

When set, the credentials are written to .netrc as machine-scoped
entries for the listed hosts (the same mechanism submodule_credentials
already uses) instead of the default entry, which matches every host.
When omitted, the default entry is written exactly as before, so
existing pipelines are unaffected.

Why

With the default entry, the main repo credentials are sent to whatever
host a submodule URL points at (#482). Scoping to explicit hosts keeps
same-host submodules working; cross-host submodules authenticate via
submodule_credentials as documented.

Test

it_scopes_credentials_to_credential_hosts in test/check.sh covers:

  • one machine-scoped entry per listed host
  • no default entry is written
  • .netrc is still cleared between requests

Notes

Hosts are matched by hostname, as netrc does (no protocol). Documented in
the source config table next to username/password.

Refs concourse#482. When set, username/password are written to .netrc as
machine-scoped entries for the listed hosts instead of the default
entry, which matches every host and so sends the credentials to any
host a submodule URL points at. Omitting the param keeps the previous
behavior. Uses the same machine-scoping mechanism submodule_credentials
already uses.

Signed-off-by: hiddingtrojans <107155157+hiddingtrojans@users.noreply.github.com>
@linux-foundation-easycla

linux-foundation-easycla Bot commented Aug 21, 2026

Copy link
Copy Markdown

CLA Signed
The committers listed above are authorized under a signed CLA.

  • ✅ login: hiddingtrojans / name: hiddingtrojans (2a7b9f4)

A bare string (credential_hosts: "host1") previously failed the jq
iteration, and because 'local' masks the exit code the function fell
through to writing the default netrc entry - silently unscoping the
credentials the user meant to restrict. Accept a string (single or
space-separated, matching the ignore_paths convention) as well as a
list.

Signed-off-by: hiddingtrojans <107155157+hiddingtrojans@users.noreply.github.com>
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