Skip to content

Add exec-based credential support for OCI registry authentication - #1864

Open
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:feat/1699-registry-oidc
Open

Add exec-based credential support for OCI registry authentication#1864
dennismdejong wants to merge 1 commit into
hashicorp:mainfrom
dennismdejong:feat/1699-registry-oidc

Conversation

@dennismdejong

Copy link
Copy Markdown

Description

Adds a password_exec block to the registry configuration that allows obtaining OCI registry credentials by executing an external command. This enables OIDC/OAuth2 token-based authentication for private registries without requiring long-lived credentials.

Background

Users authenticating to OCI registries (e.g., ACR, ECR, GCR) with OIDC/OAuth2 tokens currently have no way to use short-lived credentials with the Helm provider. This adds exec-based credential support similar to what already exists for Kubernetes authentication.

Configuration

provider "helm" {
  registry {
    url      = "oci://example.azurecr.io/helm"
    username = "00000000-0000-0000-0000-000000000000"
    password_exec {
      command = "az"
      args    = ["acr", "login", "--name", "example", "--expose-token"]
    }
  }
}

Implementation

  • Added password_exec nested attribute to the registry schema with command, args, and env fields
  • Added executeRegistryExec function that runs the command and parses the output
  • Supports JSON output parsing for common token field names (accessToken, token, access_token, status.token) with raw stdout fallback
  • password field is now Optional instead of Required; either password or password_exec must be set

Fixes #1699

Adds a password_exec block to the registry configuration that allows
obtaining OCI registry credentials by executing an external command.
This enables OIDC/OAuth2 token-based authentication for private
registries (e.g., az acr login, kubelogin).

The exec block supports:
- command: the executable to run
- args: list of arguments
- env: additional environment variables

The output is parsed for common token field names (accessToken, token,
access_token) or nested status.token, with raw stdout as fallback.

Fixes hashicorp#1699
@dennismdejong
dennismdejong requested review from a team, iam404 and rigalGit as code owners July 28, 2026 05:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Private Registry Login with OIDC/OAuth2

1 participant