Skip to content

feat: add Docker credential helper for Cloudsmith registries#277

Open
cloudsmith-iduffy wants to merge 2 commits intoiduffy/credential-provider-chainfrom
iduffy/credential-helper-base
Open

feat: add Docker credential helper for Cloudsmith registries#277
cloudsmith-iduffy wants to merge 2 commits intoiduffy/credential-provider-chainfrom
iduffy/credential-helper-base

Conversation

@cloudsmith-iduffy
Copy link
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 and others added 2 commits March 25, 2026 12:19
Add a GitHub Actions workflow that builds and publishes pre-release
packages to Cloudsmith for manual testing on a per-PR basis.

Trigger by either:
  - Adding the 'pre-release' label to a PR
  - Commenting '/pre-release' on a PR (collaborators only)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@cloudsmith-iduffy cloudsmith-iduffy force-pushed the iduffy/credential-helper-base branch from 21fe5cf to d2cd0d1 Compare March 25, 2026 12:20

return domains

except Exception as exc: # pylint: disable=broad-exception-caught
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: don't ignore this, except for the specific errors only

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
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 ?

Comment on lines +8 to +38
from ..common import is_cloudsmith_domain


def get_credentials(server_url, credential=None, session=None, api_host=None):
"""
Get credentials for a Cloudsmith Docker registry.

Verifies the URL is a Cloudsmith registry (including custom domains)
and returns credentials if available.

Args:
server_url: The Docker registry server URL
credential: Pre-resolved CredentialResult from the provider chain
session: Pre-configured requests.Session with proxy/SSL settings
api_host: Cloudsmith API host URL

Returns:
dict: Credentials with 'Username' and 'Secret' keys, or None
"""
if not credential or not credential.api_key:
return None

if not is_cloudsmith_domain(
server_url,
session=session,
api_key=credential.api_key,
api_host=api_host,
):
return None

return {"Username": "token", "Secret": credential.api_key}
Copy link
Contributor

Choose a reason for hiding this comment

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

question: why are these in the init.py we try to only use this file for exposing the module's imports.


click.echo(json.dumps(credentials))

except Exception as e: # pylint: disable=broad-exception-caught
Copy link
Contributor

Choose a reason for hiding this comment

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

issue: don't ignore this, except for the specific errors only

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.

2 participants