Authentication with requirepass and user/pass now working
This commit is contained in:
parent
84e3762fd3
commit
31cef8b0a6
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Graylog, Inc.
|
||||
* Copyright (C) 2024 johan@nosd.in
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the Server Side Public License, version 1,
|
||||
@ -36,15 +36,6 @@ import io.lettuce.core.RedisClient;
|
||||
import io.lettuce.core.RedisURI;
|
||||
import io.lettuce.core.api.StatefulRedisConnection;
|
||||
import io.lettuce.core.api.sync.RedisCommands;
|
||||
/*
|
||||
//To delete after clean
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import okhttp3.ResponseBody;
|
||||
//END To delete after clean
|
||||
*/
|
||||
import in.nosd.redis.dataadapters.AutoValue_RedisLookupDataAdapter_Config;
|
||||
import org.graylog2.plugin.lookup.LookupCachePurge;
|
||||
import org.graylog2.plugin.lookup.LookupDataAdapter;
|
||||
@ -89,18 +80,19 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
super(dto, metricRegistry);
|
||||
|
||||
this.config = (Config) dto.config();
|
||||
RedisURI redisUri = RedisURI.Builder.redis(this.config.redisHost(),this.config.redisPort())
|
||||
.withPort(this.config.redisPort())
|
||||
//.withAuthentication(this.config.redisUsername(), this.config.redisPassword())
|
||||
.withDatabase(this.config.redisDB())
|
||||
.build();
|
||||
RedisURI redisUri ;
|
||||
redisUri = RedisURI.Builder.redis(this.config.redisHost(),this.config.redisPort())
|
||||
.withPort(this.config.redisPort())
|
||||
.withDatabase(this.config.redisDB())
|
||||
.build();
|
||||
if (this.config.redisPassword() != null && this.config.redisPassword().length() > 0) {
|
||||
redisUri.setPassword(this.config.redisPassword());
|
||||
}
|
||||
if (this.config.redisUsername() != null && this.config.redisUsername().length() > 0) {
|
||||
redisUri.setUsername(this.config.redisUsername());
|
||||
}
|
||||
this.client = RedisClient.create(redisUri);
|
||||
/*this.client = RedisClient.create(RedisURI.Builder.redis(this.config.redisHost(),this.config.redisPort())
|
||||
.withPort(this.config.redisPort())
|
||||
.withAuthentication(this.config.redisUsername(), this.config.redisPassword())
|
||||
.withDatabase(this.config.redisDB())
|
||||
.build());
|
||||
*/
|
||||
|
||||
this.redisGetRequestTimer = metricRegistry.timer(MetricRegistry.name(getClass(), "redisGetRequestTime"));
|
||||
this.redisGetRequestErrors = metricRegistry.meter(MetricRegistry.name(getClass(), "redisGetRequestErrors"));
|
||||
this.redisSetRequestTimer = metricRegistry.timer(MetricRegistry.name(getClass(), "redisSetRequestTime"));
|
||||
@ -202,8 +194,8 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
.redisHost("127.0.0.1")
|
||||
.redisPort(6379)
|
||||
.redisDB(0)
|
||||
/*.redisUsername("")
|
||||
.redisPassword("")*/
|
||||
.redisUsername("")
|
||||
.redisPassword("")
|
||||
.build();
|
||||
|
||||
}
|
||||
@ -233,13 +225,13 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
@Min(0)
|
||||
public abstract int redisDB();
|
||||
|
||||
/*@JsonProperty("redis_username")
|
||||
@JsonProperty("redis_username")
|
||||
@Nullable
|
||||
public abstract String redisUsername();
|
||||
|
||||
@JsonProperty("redis_password")
|
||||
@Nullable
|
||||
public abstract String redisPassword();*/
|
||||
public abstract String redisPassword();
|
||||
|
||||
public static Builder builder() {
|
||||
return new AutoValue_RedisLookupDataAdapter_Config.Builder();
|
||||
@ -278,11 +270,11 @@ public class RedisLookupDataAdapter extends LookupDataAdapter {
|
||||
@JsonProperty("redis_database")
|
||||
public abstract Builder redisDB(int redisDB);
|
||||
|
||||
/*@JsonProperty("redis_username")
|
||||
@JsonProperty("redis_username")
|
||||
public abstract Builder redisUsername(String redisUsername);
|
||||
|
||||
@JsonProperty("redis_password")
|
||||
public abstract Builder redisPassword(String redisPassword);*/
|
||||
public abstract Builder redisPassword(String redisPassword);
|
||||
|
||||
public abstract Config build();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Graylog, Inc.
|
||||
* Copyright (C) 2024 johan@nosd.in
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the Server Side Public License, version 1,
|
||||
@ -44,38 +44,58 @@ class RedisLookupAdapterFieldSet extends React.Component {
|
||||
return (
|
||||
<fieldset>
|
||||
<Input type="text"
|
||||
id="redis_host"
|
||||
name="redis_host"
|
||||
label="Redis host"
|
||||
required
|
||||
onChange={this.props.handleFormEvent}
|
||||
help={this.props.validationMessage('redis_host', 'Your Redis Host')}
|
||||
bsStyle={this.props.validationState('redis_host')}
|
||||
value={config.redis_host}
|
||||
labelClassName="col-sm-3"
|
||||
wrapperClassName="col-sm-9" />
|
||||
id="redis_host"
|
||||
name="redis_host"
|
||||
label="Redis host"
|
||||
required
|
||||
onChange={this.props.handleFormEvent}
|
||||
help={this.props.validationMessage('redis_host', 'Your Redis Host')}
|
||||
bsStyle={this.props.validationState('redis_host')}
|
||||
value={config.redis_host}
|
||||
labelClassName="col-sm-3"
|
||||
wrapperClassName="col-sm-9" />
|
||||
<Input type="text"
|
||||
id="redis_port"
|
||||
name="redis_port"
|
||||
label="Redis port"
|
||||
required
|
||||
onChange={this.props.handleFormEvent}
|
||||
help={this.props.validationMessage('redis_port', 'Redis port instance is listening on')}
|
||||
bsStyle={this.props.validationState('redis_port')}
|
||||
value={config.redis_port}
|
||||
labelClassName="col-sm-3"
|
||||
wrapperClassName="col-sm-9" />
|
||||
id="redis_port"
|
||||
name="redis_port"
|
||||
label="Redis port"
|
||||
required
|
||||
onChange={this.props.handleFormEvent}
|
||||
help={this.props.validationMessage('redis_port', 'Redis port instance is listening on')}
|
||||
bsStyle={this.props.validationState('redis_port')}
|
||||
value={config.redis_port}
|
||||
labelClassName="col-sm-3"
|
||||
wrapperClassName="col-sm-9" />
|
||||
<Input type="text"
|
||||
id="redis_database"
|
||||
name="redis_database"
|
||||
label="Redis database"
|
||||
required
|
||||
onChange={this.props.handleFormEvent}
|
||||
help={this.props.validationMessage('redis_database', 'Redis database')}
|
||||
bsStyle={this.props.validationState('redis_database')}
|
||||
value={config.redis_database}
|
||||
labelClassName="col-sm-3"
|
||||
wrapperClassName="col-sm-9" />
|
||||
id="redis_database"
|
||||
name="redis_database"
|
||||
label="Redis database"
|
||||
required
|
||||
onChange={this.props.handleFormEvent}
|
||||
help={this.props.validationMessage('redis_database', 'Redis database')}
|
||||
bsStyle={this.props.validationState('redis_database')}
|
||||
value={config.redis_database}
|
||||
labelClassName="col-sm-3"
|
||||
wrapperClassName="col-sm-9" />
|
||||
<Input type="text"
|
||||
id="redis_username"
|
||||
name="redis_username"
|
||||
label="Redis username"
|
||||
onChange={this.props.handleFormEvent}
|
||||
help={this.props.validationMessage('redis_username', 'Redis username. Leave empty for no auth or "requirepass" authentication')}
|
||||
bsStyle={this.props.validationState('redis_username')}
|
||||
value={config.redis_username}
|
||||
labelClassName="col-sm-3"
|
||||
wrapperClassName="col-sm-9" />
|
||||
<Input type="password"
|
||||
id="redis_password"
|
||||
label="Redis password"
|
||||
onChange={this.props.handleFormEvent}
|
||||
help={this.props.validationMessage('redis_password', 'Redis password. Leave empty for no auth')}
|
||||
bsStyle={this.props.validationState('redis_password')}
|
||||
value={config.redis_password}
|
||||
labelClassName="col-sm-3"
|
||||
wrapperClassName="col-sm-9">
|
||||
</Input>
|
||||
</fieldset>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user