Skip to content

Commit d5e6a8d

Browse files
Merge pull request eugenp#5159 from psevestre/master
[BAEL-2166] & [BAEL-455] Code
2 parents d2d6f2f + a84c742 commit d5e6a8d

23 files changed

Lines changed: 448 additions & 1 deletion

File tree

‎spring-cloud/pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<module>spring-cloud-contract</module>
3434
<module>spring-cloud-kubernetes</module>
3535
<module>spring-cloud-archaius</module>
36+
<module>spring-cloud-vault</module>
3637
</modules>
3738

3839
<build>
Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
4+
### STS ###
5+
.apt_generated
6+
.classpath
7+
.factorypath
8+
.project
9+
.settings
10+
.springBeans
11+
.sts4-cache
12+
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
18+
19+
### NetBeans ###
20+
/nbproject/private/
21+
/build/
22+
/nbbuild/
23+
/dist/
24+
/nbdist/
25+
/.nb-gradle/
26+
27+
## Extra
28+
/vault-data/
29+
*.log
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--
2+
-- Sample schema for testing vault database secrets
3+
--
4+
create schema fakebank;
5+
use fakebank;
6+
create table account(
7+
id decimal(16,0),
8+
name varchar(30),
9+
branch_id decimal(16,0),
10+
customer_id decimal(16,0),
11+
primary key (id));
12+
13+
--
14+
-- MySQL user that will be used by Vault to create other users on demand
15+
--
16+
create user 'fakebank-admin'@'%' identified by 'Sup&rSecre7!'
17+
grant all privileges on fakebank.* to 'fakebank-admin'@'%' with grant option;
18+
grant create user on *.* to 'fakebank-admin' with grant option;
19+
20+
flush privileges;
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<groupId>org.baeldung.spring.cloud</groupId>
7+
<artifactId>spring-cloud-vault</artifactId>
8+
<packaging>jar</packaging>
9+
10+
<name>spring-cloud-vault</name>
11+
<description>Demo project for Spring Boot</description>
12+
13+
<parent>
14+
<groupId>com.baeldung</groupId>
15+
<artifactId>parent-boot-2</artifactId>
16+
<version>0.0.1-SNAPSHOT</version>
17+
<relativePath>../../parent-boot-2</relativePath>
18+
</parent>
19+
20+
<!-- <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId>
21+
<version>2.0.4.RELEASE</version> <relativePath/> </parent> -->
22+
23+
<properties>
24+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
25+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
26+
<java.version>1.8</java.version>
27+
<spring-cloud.version>Finchley.SR1</spring-cloud.version>
28+
</properties>
29+
30+
<dependencies>
31+
32+
33+
34+
35+
<dependency>
36+
<groupId>org.springframework.cloud</groupId>
37+
<artifactId>spring-cloud-starter-vault-config</artifactId>
38+
</dependency>
39+
40+
<dependency>
41+
<groupId>org.springframework.cloud</groupId>
42+
<artifactId>spring-cloud-vault-config-databases</artifactId>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>org.springframework.boot</groupId>
47+
<artifactId>spring-boot-starter-test</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
51+
52+
53+
<dependency>
54+
<groupId>mysql</groupId>
55+
<artifactId>mysql-connector-java</artifactId>
56+
</dependency>
57+
58+
59+
<dependency>
60+
<groupId>org.springframework.boot</groupId>
61+
<artifactId>spring-boot-starter-jdbc</artifactId>
62+
</dependency>
63+
</dependencies>
64+
65+
<dependencyManagement>
66+
<dependencies>
67+
<dependency>
68+
<groupId>org.springframework.cloud</groupId>
69+
<artifactId>spring-cloud-dependencies</artifactId>
70+
<version>${spring-cloud.version}</version>
71+
<type>pom</type>
72+
<scope>import</scope>
73+
</dependency>
74+
</dependencies>
75+
</dependencyManagement>
76+
77+
<build>
78+
<plugins>
79+
<plugin>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-maven-plugin</artifactId>
82+
</plugin>
83+
</plugins>
84+
</build>
85+
86+
87+
</project>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
path "secret/fakebank" {
2+
capabilities = ["read"]
3+
allowed_parameters = {
4+
"api_key" = []
5+
}
6+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package org.baeldung.spring.cloud.vaultsample;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class VaultSampleApplication {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(VaultSampleApplication.class, args);
11+
}
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
spring:
2+
application:
3+
name: fakebank
4+
5+
datasource:
6+
url: jdbc:mysql://localhost:3306/fakebank
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
spring:
2+
cloud:
3+
vault:
4+
uri: https://localhost:8200
5+
connection-timeout: 5000
6+
read-timeout: 15000
7+
config:
8+
order: -10
9+
10+
ssl:
11+
trust-store: classpath:/vault.jks
12+
trust-store-password: changeit
13+
14+
generic:
15+
enabled: true
16+
application-name: fakebank
17+
18+
kv:
19+
enabled: false
20+
backend: kv
21+
application-name: fakebank
22+
23+
database:
24+
enabled: true
25+
role: fakebank-accounts-rw
26+
# backend: database
27+
# username-property: spring.datasource.username
28+
# password-property: spring.datasource.password
29+
30+
31+
32+
33+
34+
35+
36+
37+
833 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)