Skip to content

A collection of example code snippets demonstrating the various ways to use the HashiCorp Vault client libraries.

License

Notifications You must be signed in to change notification settings

hashicorp/vault-examples

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Vault Examples

A collection of copy-pastable code example snippets demonstrating the various ways to use the Vault client libraries for various languages to authenticate and retrieve secrets.

Currently Supported Languages

How To Use

Find the relevant directory for the concept you're interested in learning about, then find the file for your language of choice. You can use the example code as a reference or paste it into your application and tweak as needed. Each concept's directory also contains a readme explaining some of the specific terminology and operational setup.

This repo is not intended to be "run" as a standalone application.

For an out-of-the-box runnable sample app, please see our Hello-Vault repos.

Hello-Vault:

Client Applications

For complete, runnable client application examples that demonstrate real-world Vault integration patterns, see the Client Applications directory.

These examples include:

  • Complete applications in multiple languages (C, C++, Java, Python, Spring Boot, Tomcat)
  • Script examples using Vault Proxy
  • Real-world patterns for authentication, token renewal, and secret management
  • Multiple secret engine support (KV v2, Database Dynamic/Static, SSH, AWS)

Each example includes:

  • Full source code
  • Build and run instructions
  • Configuration examples
  • Detailed documentation

See the Client Applications README for more details.

MCP Examples

Identity-Aware Remote MCP Examples (Agent Protection)

For examples demonstrating Vault integration with Model Context Protocol (MCP) servers for identity-aware credential management, see the MCP Examples directory.

The identity-aware remote example demonstrates:

  • User-specific credential separation using Vault Policy Templating
  • JWT-based authentication with Keycloak integration
  • Remote MCP servers retrieving user-specific credentials from Vault
  • Multiple secret engine support (KV v2, Database Dynamic Secrets)
  • Authentication flow tracing and credential debugging

See the MCP Remote Vault Demo README and Quick Start Guide for more details.

How To Contribute

If you would like to submit a code example to this repo, please create a file containing one function (or a grouping of several related functions) in the appropriate directory.

About

A collection of example code snippets demonstrating the various ways to use the HashiCorp Vault client libraries.

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6