Spring Cloud Karmahostage provide Spring Cloud common interface immplementations that consume Karmhostage services. The main objective of this project is to facilitate the integration of Karmahostage functionality in Spring Cloud and Spring Boot applications.
Starters are convenient dependency descriptors you can include in your application. Include a starter to get the dependencies and Spring Boot auto-configuration for a feature set.
Starter | Features |
---|---|
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-karmahostage</artifactId> </dependency> |
All Spring Cloud Features |
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-secrets</artifactId> </dependency> |
Load Secrets from Karmahostage |
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-encrypted-properties</artifactId> </dependency> |
Inject Encrypted Properties from Karmahostage |
The most common approach to configuring your Spring Boot application is to create an application.properties or application.yaml or an application-profile.properties or application-profile.yaml file that contains key-value pairs that provide customization values to your application or Spring Boot starters. You can override these properties by specifying system properties or environment variables.
Karmahostage has the notion of Secrets for storing sensitive data such as passwords, OAuth tokens, and so on. This project provides integration with Secrets to make secrets accessible by Spring Boot applications. You can explicitly enable or disable This feature by setting the spring.cloud.karmahostage.secrets.enabled property.
When enabled, the SecretsPropertySource looks up Karmahostage for Secrets from the following sources:
- Named after the application (as defined by spring.application.name)
- Looking at the existing configuration defined under spring.cloud.karmahostage.secrets
Note: As for every integration with karmahostage, you'll need an API key. Visit Karmahostage to register for an API key.
You'll need to set the API key using the spring.cloud.karmahostage.api-key property.
By default, if no paths have been defined (See 3.2), the application will look at the application name. It will try to search for a secret with the name of your application as the key.
You can override the default behaviour by providing spring.cloud.karmahostage.secrets.paths.
Example:
spring.cloud.karmahostage.secrets.paths=database-username,database-password
Injecting encrypted values works out of the box.
application.properties
spring.cloud.karmahostage.apiKey=${API_KEY}
application.secret=vault:v1:lRLLIR2WxmOZzzqNC+BY+WuukGZaxt1pPsp9UKduTc7z/jKj7bN6YZZMI2pESA==
Injecting values can simply be done by annotation a field with @EncryptedValue. Surrounding the value with "${}" will load the encrypted value from your environment (such as application.properties), otherwise it will try to decrypt the literal value.
@EncryptedValue("${application.secret}")
private String application;
Note: As for every integration with karmahostage, you'll need an API key. Visit Karmahostage to register for an API key.