zeagord
zeagord

Reputation: 2365

Securing spring cloud config credentials using vault

I’m using spring-cloud-config-server with Git as a backend. I want to secure the git credentials of my private repository (username and password) to be served from the vault server.

I'm thinking to extend the GitCredentialsProviderFactory and create the credentials bean using createFor() with values from the vault. Is this a right approach or there are other recommended ways?

Upvotes: 3

Views: 569

Answers (1)

zeagord
zeagord

Reputation: 2365

Instead of using the GitCredentialsProviderFactory which I had thought of using. I used MultipleJGitEnvironmentProperties to create the GitPropert bean. And then supplied the credentials via the config values fetched from the vault.

@Bean MultipleJGitEnvironmentProperties createGitProps(){

        MultipleJGitEnvironmentProperties
                properties = new MultipleJGitEnvironmentProperties();
        properties.setUsername(username);
        properties.setUri(uri);
        properties.setSearchPaths(searchPath);
        properties.setPassword(password);
        properties.setCloneOnStart(true);
        return properties;
    }

Upvotes: 2

Related Questions