{"id":14972920,"url":"https://github.com/spring-projects/spring-vault","last_synced_at":"2025-04-29T18:48:42.855Z","repository":{"id":11156935,"uuid":"68180853","full_name":"spring-projects/spring-vault","owner":"spring-projects","description":"Provides familiar Spring abstractions for HashiCorp Vault","archived":false,"fork":false,"pushed_at":"2025-04-25T10:16:47.000Z","size":5882,"stargazers_count":286,"open_issues_count":12,"forks_count":189,"subscribers_count":18,"default_branch":"main","last_synced_at":"2025-04-25T10:33:35.527Z","etag":null,"topics":["encryption","framework","java","secrets","security","spring","vault"],"latest_commit_sha":null,"homepage":"https://spring.io/projects/spring-vault","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spring-projects.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":"CONTRIBUTING.adoc","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.adoc","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-14T06:48:10.000Z","updated_at":"2025-04-25T10:16:51.000Z","dependencies_parsed_at":"2023-09-22T20:56:01.922Z","dependency_job_id":"ed3179cf-bb42-434c-be69-78d2e5f9f287","html_url":"https://github.com/spring-projects/spring-vault","commit_stats":{"total_commits":878,"total_committers":68,"mean_commits":"12.911764705882353","dds":"0.38838268792710706","last_synced_commit":"1cdaa492dfe3c835e90698af6f1d5d8cb7f4a6e3"},"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-vault","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-vault/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-vault/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spring-projects%2Fspring-vault/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spring-projects","download_url":"https://codeload.github.com/spring-projects/spring-vault/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251563575,"owners_count":21609754,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["encryption","framework","java","secrets","security","spring","vault"],"created_at":"2024-09-24T13:47:45.494Z","updated_at":"2025-04-29T18:48:42.822Z","avatar_url":"https://github.com/spring-projects.png","language":"Java","readme":"= Spring Vault\n\nSpring Vault provides client-side support for accessing, storing and revoking secrets.\nWith https://www.vaultproject.io[HashiCorp's Vault] you have a central place to manage external secret data for applications across all environments.\nVault can manage static and dynamic secrets such as application data, username/password for remote applications/resources and provide credentials for external services such as MySQL, PostgreSQL, Apache Cassandra, Consul, AWS and more.\n\n== Getting Help\n\nFor a comprehensive treatment of all the Spring Vault features, please refer to:\n\n* the https://docs.spring.io/spring-vault/reference/[User Guide]\n* the https://docs.spring.io/spring-vault/docs/current/api/[JavaDocs] have extensive comments in them as well.\n* the home page of https://projects.spring.io/spring-vault[Spring Vault] contains links to articles and other resources.\n* for more detailed questions, use https://stackoverflow.com/questions/tagged/spring-vault[Spring Vault on Stackoverflow].\n\n== Features\n\nSpecifically for Spring applications:\n\n* JavaConfig for Vault Client\n* Retrieve secrets from Vault and initialize Spring Environment with remote property sources\n* Obtain https://docs.spring.io/spring-vault/reference/vault/client-support.html#vault.client-ssl[secrets] secured with SSL\n* https://docs.spring.io/spring-vault/reference/vault/authentication.html#vault.authentication.token[Token],\nhttps://docs.spring.io/spring-vault/reference/vault/authentication.html#vault.authentication.appid[AppId],\nhttps://docs.spring.io/spring-vault/reference/vault/authentication.html#vault.authentication.approle[AppRole],\nhttps://docs.spring.io/spring-vault/reference/vault/authentication.html#vault.authentication.clientcert[Client Certificate],\nhttps://docs.spring.io/spring-vault/reference/vault/authentication.html#vault.authentication.cubbyhole[Cubbyhole], and\nhttps://docs.spring.io/spring-vault/reference/vault/authentication.html#vault.authentication.awsec2[AWS-EC2] authentication\n* Bootstrap application context: a parent context for the main application that can be trained to do anything\n\nSpring Boot users can benefit from https://github.com/spring-cloud/spring-cloud-vault-config[Spring Cloud Vault Config], an optimized integration with Vault to provide encrypted Vault properties inside Spring Boot applications.\nhttps://github.com/spring-cloud/spring-cloud-vault-config[Spring Cloud Vault] can also generate credentials for various services like MySQL, PostgreSQL, MongoDB and much more.\n\n== Quick Start\n\n=== Maven configuration\n\nAdd the Maven dependency:\n\n====\n[source,xml]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.springframework.vault\u003c/groupId\u003e\n  \u003cartifactId\u003espring-vault-core\u003c/artifactId\u003e\n  \u003cversion\u003e${version}\u003c/version\u003e\n\u003c/dependency\u003e\n----\n====\n\nIf you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.\n\n====\n[source,xml]\n----\n\u003cdependency\u003e\n  \u003cgroupId\u003eorg.springframework.vault\u003c/groupId\u003e\n  \u003cartifactId\u003espring-vault\u003c/artifactId\u003e\n  \u003cversion\u003e${version}-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n\n\u003crepository\u003e\n  \u003cid\u003espring-snapshot\u003c/id\u003e\n  \u003cname\u003eSpring Snapshot Repository\u003c/name\u003e\n  \u003curl\u003ehttps://repo.spring.io/snapshot\u003c/url\u003e\n\u003c/repository\u003e\n----\n====\n\n=== Vault Setup\n\n*Prerequisites*\n\nTo get started with Vault and this guide you need a *NIX-like operating systems that provides:\n\n* `curl`, `openssl` and `unzip`\n* at least Java 8 and a properly configured `JAVA_HOME` environment variable\n\n[NOTE]\n--\nIf you use Windows Subsystem for Linux (WSL) you have to share `JAVA_HOME` between WSL and Windows. Call following command in PowerShell:\n----\n$ setx WSLENV \"JAVA_HOME/p\"\n----\n--\n\n*Install Vault*\n\n----\n$ src/test/bash/install_vault.sh\n----\n\n*Create SSL certificates for Vault*\n\n----\n$ src/test/bash/create_certificates.sh\n----\n\nNOTE: `create_certificates.sh` creates certificates in `work/ca` and a JKS truststore `work/keystore.jsk`.\nIf you want to run Spring Vault using this quickstart guide you need to configure the truststore to `file:work/keystore.jks`.\n\n*Start Vault server*\n\n----\n$ src/test/bash/local_run_vault.sh\n----\n\nVault is started listening on `0.0.0.0:8200` using the `inmem` storage and\n`https`.\nVault is sealed and not initialized when starting up so you need to initialize it first.\n\n----\n$ cd vault\n$ export VAULT_ADDR=\"https://localhost:8200\"\n$ export VAULT_SKIP_VERIFY=true # Don't do this for production\n$ ./vault operator init\n----\n\nYou should see something like:\n\n----\nKey 1: 7149c6a2e16b8833f6eb1e76df03e47f6113a3288b3093faf5033d44f0e70fe701\nKey 2: 901c534c7988c18c20435a85213c683bdcf0efcd82e38e2893779f152978c18c02\nKey 3: 03ff3948575b1165a20c20ee7c3e6edf04f4cdbe0e82dbff5be49c63f98bc03a03\nKey 4: 216ae5cc3ddaf93ceb8e1d15bb9fc3176653f5b738f5f3d1ee00cd7dccbe926e04\nKey 5: b2898fc8130929d569c1677ee69dc5f3be57d7c4b494a6062693ce0b1c4d93d805\nInitial Root Token: 19aefa97-cccc-bbbb-aaaa-225940e63d76\n\nVault initialized with 5 keys and a key threshold of 3. Please\nsecurely distribute the above keys. When the Vault is re-sealed,\nrestarted, or stopped, you must provide at least 3 of these keys\nto unseal it again.\n\nVault does not store the master key. Without at least 3 keys,\nyour Vault will remain permanently sealed.\n----\n\nVault will initialize and return a set of unsealing keys and the root token.\nPick 3 keys and unseal Vault.\n\n----\n$ ./vault operator unseal (Key 1)\n$ ./vault operator unseal (Key 2)\n$ ./vault operator unseal (Key 3)\n----\n\nVault is now initialized and unsealed.\n\n=== Using VaultTemplate\n\nThe class VaultTemplate, located in the package org.springframework.vault.core, is the central class of the Spring’s Vault support providing a rich feature set to interact with Vault.\nThe template offers convenience operations to read, write and delete data in Vault and provides a mapping between your domain objects and Vault data.\n\nYou can have Spring initializing Spring Vault by providing a JavaConfig:\n\n====\n[source,java]\n----\n@Configuration\npublic class AppConfig extends AbstractVaultConfiguration {\n\n    /**\n     * Specify an endpoint for connecting to Vault.\n     */\n    @Override\n    public VaultEndpoint vaultEndpoint() {\n        return new VaultEndpoint();\n    }\n\n    /**\n     * Configure a client authentication.\n     * Please consider a more secure authentication method\n     * for production use.\n     */\n    @Override\n    public ClientAuthentication clientAuthentication() {\n        return new TokenAuthentication(\"…\");\n    }\n}\n----\n====\n\nand then use `VaultTemplate` through its interface `VaultOperations`:\n\n====\n[source,java]\n----\npublic class MyApp {\n\n    @Autowired VaultOperations vaultOperations;\n\n    public void useVault() {\n\n        Secrets secrets = new Secrets();\n        secrets.username = \"hello\";\n        secrets.password = \"world\";\n\n        vaultOperations.write(\"secret/myapp\", secrets);\n\n        VaultResponseSupport\u003cSecrets\u003e response = vaultOperations.read(\"secret/myapp\", Secrets.class);\n        System.out.println(response.getData().getUsername());\n\n        vaultOperations.delete(\"secret/myapp\");\n    }\n}\n----\n====\n\n=== @VaultPropertySource\n\n`@VaultPropertySource` provides a convenient and declarative mechanism for adding a `PropertySource` to Spring’s `Environment`.\n\nTo be used in conjunction with @Configuration classes.\nExample usage\n\nGiven a Vault path `secret/my-application` containing the configuration data pair `database.password=mysecretpassword`, the following `@Configuration`\nclass uses `@VaultPropertySource` to contribute `secret/my-application` to the `Environment`'s set of `PropertySources`.\n\n====\n[source,java]\n----\n@Configuration\n@VaultPropertySource(\"secret/my-application\")\npublic class AppConfig {\n\n    @Autowired Environment env;\n\n    @Bean\n    public TestBean testBean() {\n        TestBean testBean = new TestBean();\n        testBean.setPassword(env.getProperty(\"database.password\"));\n        return testBean;\n    }\n}\n----\n====\n\n== Building\n\n==== Build requirements for Vault\n\nSpring Vault requires SSL certificates and a running Vault instance listening on `localhost:8200`.\nCertificates and the Vault setup are scripted, the scripts are located in `src/test/bash`.\n\nThe following scripts need to be run prior to building the project for the tests to pass.\n\n    $ ./src/test/bash/install_vault.sh\n    $ ./src/test/bash/create_certificates.sh\n    $ ./src/test/bash/env.sh\n    $ ./src/test/bash/local_run_vault.sh\n\nAlternatively you can run\n\n----\n$ ./src/test/bash/start.sh\n----\n\nChanges to the documentation should be made to the adocs found under `src/main/asciidoc/`\n\n=== Basic Compile and Test\n\nTo build the source you will need to install JDK 1.6.\n\nSpring Vault uses Maven for most build-related activities, and you should be able to get off the ground quite quickly by cloning the project you are interested in and typing\n\n----\n$ ./mvnw install\n----\n\nNOTE: You can also install Maven (\u003e=3.3.3) yourself and run the `mvn` command in place of `./mvnw` in the examples below.\nIf you do that you also might need to add `-P spring` if your local Maven settings do not contain repository declarations for spring pre-release artifacts.\n\nNOTE: Be aware that you might need to increase the amount of memory available to Maven by setting a `MAVEN_OPTS` environment variable with a value like `-Xmx512m -XX:MaxPermSize=128m`.\nWe try to cover this in the `.mvn` configuration, so if you find you have to do it to make a build succeed, please raise a ticket to get the settings added to source control.\n\nFor hints on how to build the project look in `.travis.yml` if there is one.\nThere should be a \"script\" and maybe \"install\" command.\nAlso look at the \"services\" section to see if any services need to be running locally (e.g. mongo or rabbit).\nIgnore the git-related bits that you might find in \"before_install\" since they're related to setting git credentials and you already have those.\n\nNOTE: If all else fails, build with the command from `.travis.yml` (usually\n`./mvnw install`).\n\n=== Documentation\n\nThe module has a \"distribute\" profile, and if you switch that on it will try to build asciidoc sources from\n`src/main/asciidoc`.\n\n=== Working with the code\n\nIf you don't have an IDE preference we would recommend that you use\nhttps://www.springsource.com/developer/sts[Spring Tools Suite] or\nhttps://eclipse.org[Eclipse] when working with the code.\nWe use the\nhttps://eclipse.org/m2e/[m2eclipe] eclipse plugin for maven support.\nOther IDEs and tools should also work without issue as long as they use Maven 3.3.3 or better.\n\n==== Importing into eclipse with m2eclipse\n\nWe recommend the https://eclipse.org/m2e/[m2eclipe] eclipse plugin when working with eclipse.\nIf you don't already have m2eclipse installed it is available from the \"eclipse marketplace\".\n\nNOTE: Older versions of m2e do not support Maven 3.3, so once the projects are imported into Eclipse you will also need to tell m2eclipse to use the right profile for the projects.If you see many different errors related to the POMs in the projects, check that you have an up to date installation.\nIf you can't upgrade m2e, add the \"spring\" profile to your `settings.xml`.\nAlternatively you can copy the repository settings from the \"spring\" profile of the parent pom into your `settings.xml`.\n\n==== Importing into eclipse without m2eclipse\n\nIf you prefer not to use m2eclipse you can generate eclipse project metadata using the following command:\n\n[indent=0]\n----\n\t$ ./mvnw eclipse:eclipse\n----\n\nThe generated eclipse projects can be imported by selecting `import existing projects`\nfrom the `file` menu.\n\n==== Importing into IntelliJ\n\nIn IntelliJ, choose `File --\u003e Open` and select the `pom.xml` it will automatically detect it is a Maven project and starts downloading all necessary dependencies.\n\n==== Formatting code (Spring Java Format)\n\nThe project uses https://github.com/spring-io/spring-javaformat[Spring Java Format] through the `spring-javaformat-maven-plugin`.\nYou can run `./mvnw spring-javaformat:apply` to reformat code.\nFollow the instructions for https://github.com/spring-io/spring-javaformat#eclipse[Eclipse] or https://github.com/spring-io/spring-javaformat#intellij-idea[IntelliJ] to install a plugin to enable formatting in your favorite IDE.\n\n\n== Contributing\n\nSpring Vault is released under the non-restrictive Apache 2.0 license, and follows a very standard GitHub development process, using GitHub tracker for issues and merging pull requests into `main`.\nIf you want to contribute even something trivial please do not hesitate, but follow the guidelines below.\n\n== Developer Certificate of Origin (DCO)\n\nAll commits must include a __Signed-off-by__ trailer at the end of each commit message to indicate that the contributor agrees to the Developer Certificate of Origin.\nFor additional details, please refer to the blog post https://spring.io/blog/2025/01/06/hello-dco-goodbye-cla-simplifying-contributions-to-spring[Hello DCO, Goodbye CLA: Simplifying Contributions to Spring].\n\n=== Code of Conduct\n\nThis project adheres to the Contributor Covenant https://github.com/spring-projects/.github/blob/3d965e94708a0014f0f9a2ab05bfc5eb6efef7e4/CODE_OF_CONDUCT.md[code of\nconduct].\nBy participating, you are expected to uphold this code.\nPlease report unacceptable behavior to spring-code-of-conduct@pivotal.io.\n\n=== Code Conventions and Housekeeping\n\nNone of these is essential for a pull request, but they will all help.\nThey can also be added after the original pull request but before a merge.\n\n* Spring Vault uses the Spring JavaFormat conventions.\nFormatting is applied when running the build through `$ ./mvnw compile`\nIDE plugins are available from https://github.com/spring-io/spring-javaformat.\n* Make sure all new `.java` files to have a Javadoc class comment with at least an\n`@author` tag identifying you, and preferably at least a paragraph on what the class is for.\n* Add the ASF license header comment to all new `.java` files (copy from existing files in the project)\n* Add yourself as an `@author` to the .java files that you modify substantially (more than cosmetic changes).\n* Please include unit tests.\n* If no-one else is using your branch, please rebase it against the current `main` (or other target branch in the main project).\n* When writing a commit message please follow https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html[these conventions], if you are fixing an existing issue please add `Fixes gh-XXXX` at the end of the commit message (where XXXX is the issue number).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-projects%2Fspring-vault","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspring-projects%2Fspring-vault","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspring-projects%2Fspring-vault/lists"}