Skip to content

feat: add Docker credential helper for Cloudsmith registries#277

Open
cloudsmith-iduffy wants to merge 5 commits into
masterfrom
iduffy/credential-helper-base
Open

feat: add Docker credential helper for Cloudsmith registries#277
cloudsmith-iduffy wants to merge 5 commits into
masterfrom
iduffy/credential-helper-base

Conversation

@cloudsmith-iduffy
Copy link
Copy Markdown
Contributor

@cloudsmith-iduffy cloudsmith-iduffy commented Mar 14, 2026

Description

Implement the Docker credential helper protocol so Docker can automatically authenticate with Cloudsmith registries (including custom domains) without manual docker login.

Key changes:

  • Add cloudsmith credential-helper docker CLI command
  • Add docker-credential-cloudsmith wrapper binary (entry point)
  • Add custom domain discovery via Cloudsmith API with filesystem caching

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Refactoring
  • Other (please describe)

Additional Notes

Manually tested with:

  • Cloudsmith cli configured with CLOUDSMITH_API_KEY
  • Cloudsmith cli configured with CLOUDSMITH_API_KEY and CLOUDSMITH_ORG and a custom domain

@cloudsmith-iduffy cloudsmith-iduffy requested a review from a team as a code owner March 14, 2026 00:37
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch from 31f616c to 58327a3 Compare March 14, 2026 13:42
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-provider-chain branch 2 times, most recently from 8b57884 to 0b0445c Compare March 14, 2026 14:06
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch from 58327a3 to 910a2cd Compare March 14, 2026 14:09
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-provider-chain branch from 0b0445c to 987c32f Compare March 14, 2026 14:10
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch from 910a2cd to 23ab3ad Compare March 14, 2026 14:12
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-provider-chain branch 2 times, most recently from 65d8c53 to 646c50a Compare March 14, 2026 14:23
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch from 23ab3ad to 0e03731 Compare March 14, 2026 14:24
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-provider-chain branch from 646c50a to 5c2b23d Compare March 14, 2026 14:26
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch 2 times, most recently from 641bec5 to 5540a76 Compare March 14, 2026 14:39
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-provider-chain branch from 6e1792c to 8862812 Compare March 14, 2026 14:43
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch from 5540a76 to 2aad86a Compare March 14, 2026 14:45
@cloudsmith-iduffy cloudsmith-iduffy marked this pull request as draft March 14, 2026 14:49
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-provider-chain branch 2 times, most recently from 368db92 to a60887d Compare March 15, 2026 10:34
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch 2 times, most recently from 4e72204 to 21fe5cf Compare March 15, 2026 21:43
@cloudsmith-iduffy cloudsmith-iduffy marked this pull request as ready for review March 15, 2026 22:24
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-provider-chain branch from 1cef871 to b4b2583 Compare March 25, 2026 12:13
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch from 21fe5cf to d2cd0d1 Compare March 25, 2026 12:20
Comment thread cloudsmith_cli/credential_helpers/custom_domains.py Outdated
Comment thread setup.py
Comment on lines +68 to 72
"console_scripts": [
"cloudsmith=cloudsmith_cli.cli.commands.main:main",
"docker-credential-cloudsmith=cloudsmith_cli.credential_helpers.docker.wrapper:main",
]
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: Have you tested this with the pyz ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't work with pyz, pyz just gives a single binary. It is good you call this out though, we will have a documentation task to have the user create their own wrapper to cloudsmith credential-helper docker

Comment thread cloudsmith_cli/credential_helpers/docker/__init__.py Outdated
Comment thread cloudsmith_cli/cli/commands/credential_helper/docker.py Outdated
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-provider-chain branch from 74f874c to f30e428 Compare March 31, 2026 16:18
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch from d2cd0d1 to 05fd479 Compare March 31, 2026 21:35
Base automatically changed from iduffy/credential-provider-chain to master May 20, 2026 09:49
@BartoszBlizniak
Copy link
Copy Markdown
Member

@copilot resolve the merge conflicts in this pull request

Copilot AI review requested due to automatic review settings May 27, 2026 16:30
@cloudsmith-iduffy cloudsmith-iduffy review requested due to automatic review settings May 27, 2026 16:30
Copy link
Copy Markdown
Contributor

Copilot AI commented May 27, 2026

@copilot resolve the merge conflicts in this pull request

Merge conflicts are resolved in commit 5a7ce30 (merged origin/master into this branch and resolved all conflicted files).

Comment thread cloudsmith_cli/credential_helpers/common.py Fixed
…ring sanitization'

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 27, 2026 16:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class Docker credential helper support to the Cloudsmith CLI so Docker can automatically fetch credentials for Cloudsmith registries (including custom domains), without requiring a manual docker login.

Changes:

  • Adds a new cloudsmith credential-helper docker command that implements Docker’s credential helper “get” flow.
  • Adds a docker-credential-cloudsmith console-script wrapper entry point for Docker to invoke.
  • Introduces custom-domain discovery via Cloudsmith API with a filesystem cache to recognize Cloudsmith-hosted registries beyond *.cloudsmith.io.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
setup.py Registers docker-credential-cloudsmith as a console_script entry point.
cloudsmith_cli/credential_helpers/docker/wrapper.py Implements the Docker-invoked wrapper that delegates to the CLI subcommand.
cloudsmith_cli/credential_helpers/docker/credentials.py Core logic to return Docker credential JSON for Cloudsmith registries.
cloudsmith_cli/credential_helpers/docker/init.py Exposes Docker helper credential retrieval function.
cloudsmith_cli/credential_helpers/custom_domains.py Fetches and caches org custom domains from the Cloudsmith API.
cloudsmith_cli/credential_helpers/common.py Adds shared hostname extraction and Cloudsmith domain detection.
cloudsmith_cli/credential_helpers/init.py Introduces the credential_helpers package.
cloudsmith_cli/cli/commands/credential_helper/docker.py Adds the CLI command implementing Docker helper protocol “get”.
cloudsmith_cli/cli/commands/credential_helper/init.py Defines the credential-helper command group and registers subcommands.
cloudsmith_cli/cli/commands/init.py Ensures the new command group is imported/registered with the CLI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +151 to +160
if session is None:
session = requests.Session()

if api_key:
session.headers["Authorization"] = f"Bearer {api_key}"

host = api_host or "https://api.cloudsmith.io"
url = f"{host}/orgs/{org}/custom-domains/"

response = session.get(url, timeout=10)
Comment on lines +187 to +189
for item in data:
if isinstance(item, dict) and "host" in item:
domains.append(item["host"])
Reads a Docker registry server URL from stdin and returns credentials in JSON format.
This command implements the 'get' operation of the Docker credential helper protocol.

Only provides credentials for Cloudsmith Docker registries (docker.cloudsmith.io).
Comment on lines +18 to +21
@click.command()
@common_api_auth_options
@resolve_credentials
def docker(opts):
import logging
import time
from pathlib import Path
from typing import List, Optional
@@ -0,0 +1,199 @@
"""
@@ -0,0 +1,86 @@
"""
@@ -0,0 +1,6 @@
"""
@@ -0,0 +1,80 @@
"""
@@ -0,0 +1,31 @@
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

6 participants