spring-cloud-dataflow icon indicating copy to clipboard operation
spring-cloud-dataflow copied to clipboard

How to pass a sensitive information When launching the task through RestCall

Open vishnuek opened this issue 1 year ago • 1 comments
trafficstars

Description: Trying to launch a task using Rest call (/tasks/executions - POST). The task is spring boot application and connecting other server, database. app needs many creds to run. While launching task through a rest call, How to pass the values?

Can we think about that we can set the creds for this task in scdf deployment yaml files as secrets? tested this and working for datasource.

Release versions: 2.10.0

vishnuek avatar Feb 08 '24 12:02 vishnuek

@vishnuek If you are using K8S it is best to manage those secrets yourself and your task app can use Spring Cloud Kubernetes to obtain the properties.

I suggest you create something like the following:


@ConfigurationProperties("myapp.second-database")
class NonDefaultDatabaseProperties {
    String url;
    String secretName;
    String secretNamespace;
    String driverClassName;
}

@Configuration
@Profile("k8s")
class NonDefaultDatabaseConfiguration {
    @Bean("secondDS")
    DataSource secondDS(NonDefaultDatabaseProperties databaseProperties, Fabric8SecretsPropertySourceLocator secretsLocator) {
        // use secretsLocator.getPropertySource to retrieve a SecretsPropertySource and then retrieve the  username and password
        // initialise the datasource using databaseProperties and the username and password.
    }
}

Use a k8s profile when deploying in Kubernetes and retrieve the 2nd database properties. When you want to use a profile named local then place the properties in application-local.properties in a config folder under the application location.

corneil avatar Feb 09 '24 14:02 corneil

Closing due to inactivity. If closed in error please let us know.

cppwfs avatar Jul 22 '24 14:07 cppwfs