Skip to content

Add OpenTofu registry handler#115

Open
diofeher wants to merge 2 commits into
dependabot:mainfrom
diofeher:opentofu/add-opentofu-registry-handler
Open

Add OpenTofu registry handler#115
diofeher wants to merge 2 commits into
dependabot:mainfrom
diofeher:opentofu/add-opentofu-registry-handler

Conversation

@diofeher
Copy link
Copy Markdown

@diofeher diofeher commented Apr 29, 2026

Summary

  • dependabot-core's OpenTofu ecosystem accepts credentials with type: opentofu_registry, but the proxy had no matching handler. Requests against private OpenTofu registries reached the upstream anonymously and failed authentication.
  • Adds OpenTofuRegistryHandler in internal/handlers/opentofu_registry.go modeled on the existing Terraform handler. The wire protocol is identical (Terraform Module Registry HTTP API), so the logic is the same — only the credential-type filter, log message, and OIDC label are renamed.
  • Registers the new handler in proxy.go after the Terraform handler.

dependabot-core's OpenTofu ecosystem accepts credentials with
type `opentofu_registry`, but the proxy had no matching handler
to credential-stuff requests. Without it, requests against private
OpenTofu registries reach the upstream anonymously and fail with
authentication errors.

Add an `OpenTofuRegistryHandler` modeled on the Terraform handler
(same wire protocol — Terraform Module Registry HTTP API), and
register it after the Terraform handler in the proxy chain.
Copy link
Copy Markdown

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 proxy support for Dependabot’s opentofu_registry credential type by introducing a dedicated OpenTofu registry handler (mirroring the existing Terraform registry handler) and wiring it into the proxy request pipeline, with accompanying tests to validate matching and precedence behavior.

Changes:

  • Added OpenTofuRegistryHandler to inject Authorization: Bearer <token> for OpenTofu registry requests, supporting both host-based and URL-prefix matching plus OIDC auth.
  • Registered the new handler in proxy.go immediately after the Terraform registry handler.
  • Added comprehensive unit tests covering host/url matching, path-boundary behavior, and credential filtering.
Show a summary per file
File Description
proxy.go Registers the OpenTofu registry request handler in the proxy chain.
internal/handlers/opentofu_registry.go Implements OpenTofu registry auth injection (static + OIDC), modeled on Terraform registry behavior.
internal/handlers/opentofu_registry_test.go Verifies authorization injection, URL/host matching, and path-boundary credential selection.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

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.

2 participants