Skip to content

visa2learn/spring-cloud-vault-db-cred-rotation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Boot Vault Demo

Install Postgres

Follow instructions For Ubuntu - https://www.postgresql.org/download/linux/ubuntu/ For Windows - https://www.postgresqltutorial.com/install-postgresql/

Setup admin user in Postgres

postgres=# create user admin password 'admin123';
CREATE ROLE
postgres=# ALTER USER admin WITH SUPERUSER;
postgres=# \q

Install Hashicorp Vault

helm repo add hashicorp https://helm.releases.hashicorp.com
helm install vault hashicorp/vault --set server.dev.enabled=true

Enable the database secrets engine

vault secrets enable database

Configure PostgreSQL secrets engine

vault write database/config/postgresql \
     plugin_name=postgresql-database-plugin \
     connection_url="postgresql://{{username}}:{{password}}@host.docker.internal:5432/postgres?sslmode=disable" \
     allowed_roles="*" \
     username="admin" \
     password="admin123"

Verify the configuration

vault write database/roles/myrole db_name=postgresql \
     creation_statements="CREATE ROLE \"{{name}}\" WITH LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}'; GRANT USAGE ON ALL SEQUENCES IN SCHEMA public TO \"{{name}}\"; GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO \"{{name}}\";" \
     default_ttl="30s" \
     max_ttl="1m"

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages