mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-23 19:16:37 +01:00
Added redis authentication with username (#3201)
This commit is contained in:
parent
f896ed723d
commit
848fc353d4
@ -262,6 +262,7 @@ broadcast-received-log-entries: true
|
||||
redis:
|
||||
enabled: false
|
||||
address: localhost
|
||||
username: ''
|
||||
password: ''
|
||||
|
||||
# Settings for RabbitMQ.
|
||||
|
@ -260,6 +260,7 @@ broadcast-received-log-entries: false
|
||||
redis:
|
||||
enabled: false
|
||||
address: localhost
|
||||
username: ''
|
||||
password: ''
|
||||
|
||||
# Settings for RabbitMQ.
|
||||
|
@ -632,6 +632,11 @@ public final class ConfigKeys {
|
||||
*/
|
||||
public static final ConfigKey<String> REDIS_ADDRESS = notReloadable(stringKey("redis.address", null));
|
||||
|
||||
/**
|
||||
* The username to connect with, or an empty string if it should use default
|
||||
*/
|
||||
public static final ConfigKey<String> REDIS_USERNAME = notReloadable(stringKey("redis.username", ""));
|
||||
|
||||
/**
|
||||
* The password in use by the redis server, or an empty string if there is no password
|
||||
*/
|
||||
|
@ -140,13 +140,17 @@ public class MessagingFactory<P extends LuckPermsPlugin> {
|
||||
|
||||
LuckPermsConfiguration config = getPlugin().getConfiguration();
|
||||
String address = config.get(ConfigKeys.REDIS_ADDRESS);
|
||||
String username = config.get(ConfigKeys.REDIS_USERNAME);
|
||||
String password = config.get(ConfigKeys.REDIS_PASSWORD);
|
||||
if (password.isEmpty()) {
|
||||
password = null;
|
||||
}
|
||||
if (username.isEmpty()) {
|
||||
username = null;
|
||||
}
|
||||
boolean ssl = config.get(ConfigKeys.REDIS_SSL);
|
||||
|
||||
redis.init(address, password, ssl);
|
||||
redis.init(address, username, password, ssl);
|
||||
return redis;
|
||||
}
|
||||
}
|
||||
|
@ -56,12 +56,16 @@ public class RedisMessenger implements Messenger {
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public void init(String address, String password, boolean ssl) {
|
||||
public void init(String address, String username, String password, boolean ssl) {
|
||||
String[] addressSplit = address.split(":");
|
||||
String host = addressSplit[0];
|
||||
int port = addressSplit.length > 1 ? Integer.parseInt(addressSplit[1]) : Protocol.DEFAULT_PORT;
|
||||
|
||||
this.jedisPool = new JedisPool(new JedisPoolConfig(), host, port, Protocol.DEFAULT_TIMEOUT, password, ssl);
|
||||
if (username == null) {
|
||||
this.jedisPool = new JedisPool(new JedisPoolConfig(), host, port, Protocol.DEFAULT_TIMEOUT, password, ssl);
|
||||
} else {
|
||||
this.jedisPool = new JedisPool(new JedisPoolConfig(), host, port, Protocol.DEFAULT_TIMEOUT, username, password, ssl);
|
||||
}
|
||||
|
||||
this.sub = new Subscription();
|
||||
this.plugin.getBootstrap().getScheduler().executeAsync(this.sub);
|
||||
|
@ -265,6 +265,7 @@ broadcast-received-log-entries = true
|
||||
redis {
|
||||
enabled = false
|
||||
address = "localhost"
|
||||
username = ""
|
||||
password = ""
|
||||
}
|
||||
|
||||
|
@ -257,6 +257,7 @@ broadcast-received-log-entries: true
|
||||
redis:
|
||||
enabled: false
|
||||
address: localhost
|
||||
username: ''
|
||||
password: ''
|
||||
|
||||
# Settings for RabbitMQ.
|
||||
|
@ -265,6 +265,7 @@ broadcast-received-log-entries = true
|
||||
redis {
|
||||
enabled = false
|
||||
address = "localhost"
|
||||
username = ""
|
||||
password = ""
|
||||
}
|
||||
|
||||
|
@ -251,6 +251,7 @@ broadcast-received-log-entries: false
|
||||
redis:
|
||||
enabled: false
|
||||
address: localhost
|
||||
username: ''
|
||||
password: ''
|
||||
|
||||
# Settings for RabbitMQ.
|
||||
|
Loading…
Reference in New Issue
Block a user