Skip to content

feat: implement Hashicorp Vault Kubernetes authentication support#1195

Open
vitali-zevako wants to merge 1 commit into
Consensys:masterfrom
vitali-zevako:feat/vault-k8s-auth
Open

feat: implement Hashicorp Vault Kubernetes authentication support#1195
vitali-zevako wants to merge 1 commit into
Consensys:masterfrom
vitali-zevako:feat/vault-k8s-auth

Conversation

@vitali-zevako
Copy link
Copy Markdown

@vitali-zevako vitali-zevako commented May 11, 2026

PR Description

This PR implements native Kubernetes Service Account authentication for Hashicorp Vault, allowing Web3Signer to authenticate with Vault without requiring a static token.

Key Changes

  • Added KUBERNETES as a valid authMethod in HashicorpSigningMetadata.
  • Implemented authenticateWithKubernetes in HashicorpConnection to exchange a K8s JWT for a Vault client token using the /v1/auth/kubernetes/login endpoint.
  • Added support for configurable kubernetesRole, kubernetesAuthPath (default: kubernetes), and kubernetesServiceAccountTokenPath (default: /var/run/secrets/kubernetes.io/serviceaccount/token).
  • Refactored AbstractArtifactSignerFactory to support dynamic token acquisition.
  • Maintained backward compatibility for existing static token authentication.
  • Added unit and integration tests.

Fixed Issue(s)

None.

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if updates are required.

Changelog

  • I thought about adding a changelog entry, and added one if I deemed necessary.

Testing

  • I thought about testing these changes in a realistic/non-local environment.

Note

Medium Risk
Changes Vault authentication and secret-loading paths for Hashicorp signers; misconfiguration could block key load, though TOKEN remains default and auth-path validation reduces path injection risk.

Overview
Adds HashiCorp Vault Kubernetes auth so Hashicorp signing metadata can obtain a Vault client token from the pod service-account JWT instead of a static token.

HashicorpSigningMetadata gains authMethod (TOKEN default, KUBERNETES), optional kubernetesRole, kubernetesAuthPath, and kubernetesServiceAccountTokenPath; token is no longer required at deserialization time and is validated when TOKEN is selected. AbstractArtifactSignerFactory exchanges the JWT via HashicorpConnection.authenticateWithKubernetes before secret reads, resolving relative token paths against the config directory.

The keystorage layer implements login (POST /v1/auth/<path>/login), JWT file read, response parsing, and auth-path hardening (reject . / .. / empty segments). Vault HTTP calls now restore interrupt status on InterruptedException. Coverage includes unit tests, YAML deserialization tests, and a MockServer integration test; the changelog records the feature.

Reviewed by Cursor Bugbot for commit 2379e51. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 11, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@vitali-zevako vitali-zevako force-pushed the feat/vault-k8s-auth branch from 818bc9c to b81fccb Compare May 11, 2026 09:48
@vitali-zevako
Copy link
Copy Markdown
Author

recheck

@vitali-zevako
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 11, 2026
@usmansaleem usmansaleem self-assigned this May 12, 2026
@vitali-zevako
Copy link
Copy Markdown
Author

@usmansaleem hi, is there any chance that this feature will be included in next releases or we have to fork? thank you

@usmansaleem
Copy link
Copy Markdown
Collaborator

@vitali-zevako Yes, its on my plate to review (was bogged down with some other tickets), planning to review/merge by end of next week at max. It will make part of next release.

@usmansaleem usmansaleem added the doc-change-required Indicates an issue or PR that requires doc to be updated label Jun 3, 2026
Copy link
Copy Markdown
Collaborator

@usmansaleem usmansaleem left a comment

Choose a reason for hiding this comment

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

A changelog entry under Features Added, something on the lines of:

### Features Added
- Support for Hashicorp Vault Kubernetes authentication [PR 1195](https://github.com/Consensys/web3signer/pull/1195)

Copy link
Copy Markdown
Collaborator

@usmansaleem usmansaleem left a comment

Choose a reason for hiding this comment

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

some suggestions, otherwise LGTM.

@usmansaleem
Copy link
Copy Markdown
Collaborator

Local testing document:
pr1195_vault_k8s_testing.md

@usmansaleem
Copy link
Copy Markdown
Collaborator

@vitali-zevako one of your commit has a different id (hence CLA failing). Easiest is to rebase and push as a single commit so that your commits are associated with a single account.

@vitali-zevako vitali-zevako force-pushed the feat/vault-k8s-auth branch from 897d429 to 7dfce08 Compare June 3, 2026 05:53
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit ee01471. Configure here.

@vitali-zevako vitali-zevako force-pushed the feat/vault-k8s-auth branch 2 times, most recently from 4b0855f to feca4ca Compare June 3, 2026 07:12
@vitali-zevako vitali-zevako force-pushed the feat/vault-k8s-auth branch from feca4ca to dc7193d Compare June 3, 2026 07:29
@vitali-zevako vitali-zevako requested a review from usmansaleem June 3, 2026 07:32
@vitali-zevako vitali-zevako force-pushed the feat/vault-k8s-auth branch from dc7193d to 2379e51 Compare June 3, 2026 07:46
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 3, 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-change-required Indicates an issue or PR that requires doc to be updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants