Skip to content

Commit d159036

Browse files
author
Michal Kucera
committed
Update README.md file
- Add `Spring Cloud Vault Integration` section - Update `Build` section with an alternative build command in case of `no such file or directory` error while creating Redis connection in Vault
1 parent 0e1e2b7 commit d159036

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ The plugin supports the generation of static and dynamic user roles and root cre
1212

1313
To build this package for any platform you will need to clone this repository and cd into the repo directory and `go build -o redis-database-plugin ./cmd/redis-database-plugin/`. To test `go test` will execute a set of basic tests against against the docker.io/redis:latest redis database image. To test against different redis images, for example 5.0-buster, set the `REDIS_VERSION=5.0-buster` environment variable. If you want to run the tests against a local redis installation or an already running redis container, set the environment variable `REDIS_HOST` before executing. **Note** the tests assume that the redis database instance has a default user with the following ACL settings `user default on nopass ~* +@all`. If not you will need to align the Administrator username and password with the pre-set values in the `redis_test.go` file. Set VAULT_ACC to execute all of the tests. A subset of tests can be run using the command `go test -run TestDriver/Init` for example.
1414

15+
**Please note:** In case of the following errors, while creating Redis connection in Vault, please build this plugin with `CGO_ENABLED=0 go build -ldflags='-extldflags=-static' -o redis-database-plugin ./cmd/redis-database-plugin/` command. More details on this error can be found [here](https://github.com/fhitchen/vault-plugin-database-redis/issues/1#issuecomment-1078415041)
16+
````bash
17+
Error writing data to database/config/my-redis: Error making API request.
18+
19+
URL: PUT http://127.0.0.1:8200/v1/database/config/my-redis
20+
Code: 400. Errors:
21+
22+
* error creating database object: invalid database version: 2 errors occurred:
23+
* fork/exec /config/plugin/redis-database-plugin: no such file or directory
24+
* fork/exec /config/plugin/redis-database-plugin: no such file or directory
25+
````
26+
1527
## Installation
1628

1729
The Vault plugin system is documented on the [Vault documentation site](https://www.vaultproject.io/docs/internals/plugins.html).
@@ -130,6 +142,33 @@ ttl 3m59s
130142
username vault-edu
131143
```
132144

145+
## Spring Cloud Vault Integration
146+
147+
> Tested on [spring-cloud-vault:3.1.0](https://docs.spring.io/spring-cloud-vault/docs/3.1.0/reference/html)
148+
149+
In order to enable integration with `Spring Cloud Vault` and therefore supply dynamically-generated Redis credentials to Spring applications, we can use `org.springframework.cloud:spring-cloud-vault-config-databases` with [Multiple Databases](https://docs.spring.io/spring-cloud-vault/docs/3.1.0/reference/html/#vault.config.backends.databases) configuration approach.
150+
151+
Sample `application.yml` configuration (not-related sections are omitted):
152+
153+
```yaml
154+
spring:
155+
cloud:
156+
vault:
157+
host: 127.0.0.1
158+
port: 8200
159+
authentication: TOKEN
160+
token: ${VAULT_TOKEN}
161+
databases:
162+
redis:
163+
enabled: true
164+
role: my-redis-role
165+
backend: database
166+
username-property: spring.redis.username
167+
password-property: spring.redis.password
168+
config:
169+
import: vault://
170+
```
171+
133172
## Developing
134173

135174
You can run `make dev` in the root of the repo to start up a development vault server and automatically register a local build of the plugin. You will need to have a built `vault` binary available in your `$PATH` to do so.

0 commit comments

Comments
 (0)