Files
onixbyte-bom/property-guard-spring-boot-starter/README.md
T

38 lines
893 B
Markdown
Raw Normal View History

2023-09-09 20:44:30 +08:00
# Property Guard
2025-02-15 12:23:22 +08:00
`property-guard-spring-boot-starter` is a utility that can help you protect secret values in Spring Boot configurations.
2023-09-09 20:44:30 +08:00
2025-02-15 12:23:22 +08:00
## Example usage
2023-09-09 20:44:30 +08:00
2025-02-15 12:23:22 +08:00
### 1. Implementation this module
2023-09-09 20:44:30 +08:00
2025-02-15 12:23:22 +08:00
```kotlin
dependencies {
implementation(platform("com.onixbyte:devkit-bom:$devKitVersion"))
implementation("com.onixbyte:devkit-utils")
implementation("com.onixbyte:property-guard-spring-boot-starter")
2023-09-09 20:44:30 +08:00
}
```
2025-02-15 12:23:22 +08:00
### 2. Generate a secret
2023-09-09 20:44:30 +08:00
2025-02-15 12:23:22 +08:00
Use the following codes to get a random secret.
2023-09-09 20:44:30 +08:00
2025-02-15 12:23:22 +08:00
```java
@SpringBootTest
class SpringBootApplicationTest {
@Test
void contextLoads() {
System.out.println(AesUtil.generateRandomSecret()); // Output: a 16-char long secret
2023-09-09 20:44:30 +08:00
}
}
```
2025-02-15 12:23:22 +08:00
Or you can write a 16-char long secret by yourself.
2023-09-09 20:44:30 +08:00
2025-02-15 12:23:22 +08:00
### 3. Encrypt your secret properties and place them into your configuration file
2023-09-09 20:44:30 +08:00
2025-02-15 12:23:22 +08:00
### 4. Run application with parameter `--pg.key=$your_secret`
2023-09-09 20:44:30 +08:00