diff --git a/src/main/java/org/swisspush/reststorage/DefaultRedisProvider.java b/src/main/java/org/swisspush/reststorage/DefaultRedisProvider.java index 31fb882..c097e40 100644 --- a/src/main/java/org/swisspush/reststorage/DefaultRedisProvider.java +++ b/src/main/java/org/swisspush/reststorage/DefaultRedisProvider.java @@ -84,8 +84,9 @@ private String createConnectString() { StringBuilder connectionStringBuilder = new StringBuilder(); connectionStringBuilder.append(configuration.isRedisEnableTls() ? "rediss://" : "redis://"); String redisUser = configuration.getRedisUser(); - if (StringUtils.isNotEmpty(redisUser)) { - connectionStringBuilder.append(configuration.getRedisUser()).append(":").append(configuration.getRedisAuth()).append("@"); + String redisPassword = configuration.getRedisPassword(); + if (StringUtils.isNotEmpty(redisUser) && StringUtils.isNotEmpty(redisPassword)) { + connectionStringBuilder.append(configuration.getRedisUser()).append(":").append(redisPassword).append("@"); } connectionStringBuilder.append(configuration.getRedisHost()).append(":").append(configuration.getRedisPort()); return connectionStringBuilder.toString(); diff --git a/src/main/java/org/swisspush/reststorage/util/ModuleConfiguration.java b/src/main/java/org/swisspush/reststorage/util/ModuleConfiguration.java index edae053..e6f5f62 100644 --- a/src/main/java/org/swisspush/reststorage/util/ModuleConfiguration.java +++ b/src/main/java/org/swisspush/reststorage/util/ModuleConfiguration.java @@ -1,7 +1,6 @@ package org.swisspush.reststorage.util; import io.vertx.core.json.JsonObject; -import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +32,12 @@ public enum StorageType { private String redisHost = "localhost"; private int redisPort = 6379; private boolean redisEnableTls; + /** + * @deprecated Instance authentication is considered as legacy. With Redis from 6.x on the ACL authentication method should be used. + */ + @Deprecated(since = "3.0.17") private String redisAuth = null; + private String redisPassword = null; private String redisUser = null; private String expirablePrefix = "rest-storage:expirable"; private String resourcesPrefix = "rest-storage:resources"; @@ -121,11 +125,17 @@ public ModuleConfiguration redisEnableTls(boolean redisEnableTls) { return this; } + @Deprecated(since = "3.0.17") public ModuleConfiguration redisAuth(String redisAuth) { this.redisAuth = redisAuth; return this; } + public ModuleConfiguration redisPassword(String redisPassword) { + this.redisPassword = redisPassword; + return this; + } + public ModuleConfiguration redisUser(String redisUser) { this.redisUser = redisUser; return this; @@ -257,6 +267,10 @@ public String getRedisAuth() { return redisAuth; } + public String getRedisPassword() { + return redisPassword; + } + public String getRedisUser() { return redisUser; } diff --git a/src/test/java/org/swisspush/reststorage/util/ModuleConfigurationTest.java b/src/test/java/org/swisspush/reststorage/util/ModuleConfigurationTest.java index cc2ab00..5f3a0c8 100644 --- a/src/test/java/org/swisspush/reststorage/util/ModuleConfigurationTest.java +++ b/src/test/java/org/swisspush/reststorage/util/ModuleConfigurationTest.java @@ -129,6 +129,8 @@ public void testGetDefaultAsJsonObject(TestContext testContext){ testContext.assertEquals(json.getInteger("redisPort"), 6379); testContext.assertEquals(json.getInteger("maxRedisWaitingHandlers"), 2048); testContext.assertNull(json.getString("redisAuth")); + testContext.assertNull(json.getString("redisPassword")); + testContext.assertNull(json.getString("redisUser")); testContext.assertEquals(json.getString("expirablePrefix"), "rest-storage:expirable"); testContext.assertEquals(json.getString("resourcesPrefix"), "rest-storage:resources"); testContext.assertEquals(json.getString("collectionsPrefix"), "rest-storage:collections");