Allow password (or any secret) to be set at run time after yaml config read
See original GitHub issueIs your feature request related to a problem? Please describe.
Add a “setPassword” method to org.redisson.config.Config;
Motivation:
I’d like to configure everything EXCEPT the password in .yaml.
But allow a programatic setting of just the password after the .yaml config loads.
This way I can pull that “secret” out of a “vault” ( hashicorp vault, azure key vault, amazon aws kms, etc)…and set it at run time.
Describe the solution you’d like
org.redisson.config.Config;
Since we do not have access to the “inner” objects
( private SentinelServersConfig sentinelServersConfig;
private MasterSlaveServersConfig masterSlaveServersConfig;
private SingleServerConfig singleServerConfig;
private ClusterServersConfig clusterServersConfig;
private ReplicatedServersConfig replicatedServersConfig;)
provide a method on
org.redisson.config.Config;
for “setPassword”
that will allow the setting of the inner object (if available) (or throw exception if not available)
OR
if you want to do it “functionally”…create an overload
public Config(Config oldConf, String newPassword) { }
Describe alternatives you’ve considered
No alternatives.
Below shows the idea:
` //import org.redisson.Redisson; //import org.redisson.api.RMapCache; //import org.redisson.api.RedissonClient; //import org.redisson.config.Config;
public static final String REDISSON_JCACHE_YAML = "/redisson-jcache.yaml";
Config config = null;
try {
// YAML configuration
URL redissonConfigUri = MyThing.class.getResource(REDISSON_JCACHE_YAML);
if (null == redissonConfigUri) {
throw new NullPointerException("My Message");
}
config = Config.fromYAML(redissonConfigUri);
if (null == config) {
throw new NullPointerException("My Other Message");
}
String myPassword = /* read from a vault here */;
config.setPassword(myPassword);
} catch (Exception ex) {
throw new RuntimeException("Yet Another Explicit Message", ex);
}
RedissonClient client = Redisson.create(config);
`
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Not sure if it helps you, but we had a similar requirement. (using encrypted password) I load the redis_cfg.yaml file into a string first, do the substitutions and then use: Config.fromYAML( configInString ); You can have something in the file like password: !MYPASSWORD! and replace !MYPASSWORD! in the code before calling Config.fromYAML
You have it:
So you can change password like this: