Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions vault/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jsonpath-starter</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-jackson-starter</artifactId>
</dependency>

<!-- db driver -->
<dependency>
Expand Down
6 changes: 4 additions & 2 deletions vault/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ Run HashiCorp Vault

docker run --cap-add=IPC_LOCK -e 'VAULT_DEV_ROOT_TOKEN_ID=myroot' -e 'VAULT_DEV_LISTEN_ADDRESS=0.0.0.0:8200' -p 8200:8200 hashicorp/vault:1.16.1`

Go to `http://localhost:8200/ui/vault/secrets/secret/kv/list` login with method Token and token `myroot` and create the following secrets:
Go to `http://localhost:8200/ui/vault/secrets/secret/kv/list` login with method Token and token `myroot` and create the following secret:

* a secret named `myDatabase`
* a secret named `database`
* a secret data `myPassword` with value `mysecretpassword`
* a secret data `myUsername` with value `postgres`
* a secret data `myJdbcURL` with value `jdbc:postgresql://localhost:5432/postgres`

image::img/secret-database.png[]

NOTE: the screenshot above shows the secret named `myDatabase` from an earlier version of this example; name the secret `database` as described above so it matches the path used in `cars-datasource.yaml`.

Run the database container

docker run -p 5432:5432 --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword postgres
Expand Down
2 changes: 1 addition & 1 deletion vault/src/main/resources/camel/cars-api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
get:
- path: cars
to: direct:get
produces: text/plain
produces: application/json
post:
- path: cars
to: direct:create
Expand Down
6 changes: 3 additions & 3 deletions vault/src/main/resources/camel/cars-datasource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
type: org.springframework.jdbc.datasource.DriverManagerDataSource
properties:
driverClassName: 'org.postgresql.Driver'
url: '{{hashicorp:secret:database/myJdbcURL}}'
username: '{{hashicorp:secret:database/myUsername}}'
password: '{{hashicorp:secret:database/myPassword}}'
url: '{{hashicorp:secret:database#myJdbcURL}}'
username: '{{hashicorp:secret:database#myUsername}}'
password: '{{hashicorp:secret:database#myPassword}}'
3 changes: 3 additions & 0 deletions vault/src/main/resources/camel/cars-routes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@
uri: jdbc
parameters:
dataSourceName: datasource
- marshal:
json:
library: Jackson
Loading