-
Notifications
You must be signed in to change notification settings - Fork 6
[NAE-2246] Enable Redis TLS & Configure Redis Sentinel #377
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
038a2e9
a73853f
ed71275
ffdbcc0
c6ecb92
652a6b7
678d277
58f0db8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,6 +16,7 @@ | |
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.context.annotation.Primary; | ||
| import org.springframework.core.io.Resource; | ||
| import org.springframework.data.redis.connection.RedisNode; | ||
| import org.springframework.data.elasticsearch.core.RefreshPolicy; | ||
| import org.springframework.util.LinkedMultiValueMap; | ||
| import org.springframework.util.MultiValueMap; | ||
|
|
@@ -107,8 +108,9 @@ public ElasticsearchProperties elasticsearchProperties() { | |
| @Bean | ||
| @Primary | ||
| public RedisProperties redisProperties() { | ||
| if (redis.getNamespace() == null) { | ||
| redis.setNamespace(databaseName); | ||
| String namespace = redis.getSession().getNamespace(); | ||
| if (namespace == null || namespace.isBlank() || "spring:session".equals(namespace)) { | ||
| redis.getSession().setNamespace("spring:session:" + databaseName); | ||
| } | ||
|
Comment on lines
+111
to
114
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid double Now that 🤖 Prompt for AI Agents |
||
| return redis; | ||
| } | ||
|
|
@@ -189,7 +191,7 @@ public static class MongoProperties extends org.springframework.boot.autoconfigu | |
| /** | ||
| * Specifies the maximum number of connections that can be initiated concurrently. | ||
| * This property is used to throttle the number of simultaneous connection attempts | ||
| * to limit resource usage and prevent connection saturation. | ||
| * to limit resource usage and prevent connection saturation. | ||
| */ | ||
| private int maxConnecting = 2; | ||
|
|
||
|
|
@@ -523,7 +525,7 @@ public static class ElasticsearchProperties { | |
| */ | ||
| @Valid | ||
| private BatchProperties batch = new BatchProperties(); | ||
|
|
||
|
|
||
| /** | ||
| * Configuration properties for handling queues in Elasticsearch operations. | ||
|
|
@@ -709,17 +711,15 @@ public static class QueueProperties { | |
| } | ||
| } | ||
|
|
||
|
|
||
| /** | ||
| * Configuration properties for Redis session management in the application. | ||
| * <p> | ||
| * This class extends {@link RedisSessionProperties}, providing additional | ||
| * configurations specific to Redis-based session handling in the application. | ||
| * It allows customization of connection details, session limiting, and other Redis-specific settings. | ||
| * Represents configuration properties for Redis used within the application. | ||
| * This class contains configurations related to the Redis server, including its | ||
| * connection details, sentinel and cluster settings, and session management properties. | ||
| */ | ||
| @Data | ||
| @EqualsAndHashCode(callSuper = true) | ||
| @ConfigurationProperties(prefix = "netgrif.engine.session") | ||
| public static class RedisProperties extends RedisSessionProperties { | ||
| @ConfigurationProperties(prefix = "netgrif.engine.data.redis") | ||
| public static class RedisProperties { | ||
|
|
||
| /** | ||
| * Hostname or IP address of the Redis server. | ||
|
|
@@ -731,7 +731,7 @@ public static class RedisProperties extends RedisSessionProperties { | |
| * Port number for connecting to the Redis server. | ||
| * Default value is {@code 6379}. | ||
| */ | ||
| private int port = 6379; | ||
| private int port = RedisNode.DEFAULT_PORT; | ||
|
|
||
| /** | ||
| * Username for authenticating with the Redis server. | ||
|
|
@@ -746,22 +746,101 @@ public static class RedisProperties extends RedisSessionProperties { | |
| private String password; | ||
|
|
||
| /** | ||
| * Flag indicating whether to enable session limit functionality. | ||
| * If {@code true}, sessions will be limited based on the configured {@link #maxSession} value. | ||
| * Indicates whether SSL (Secure Sockets Layer) is enabled for connections. | ||
| * Set to {@code true} to enable SSL or {@code false} to disable it. | ||
| * This property is primarily used for configuring secure communication | ||
| * with a Redis server. | ||
| */ | ||
| private boolean ssl = false; | ||
|
|
||
| /** | ||
| * Configuration properties for Redis Sentinel. | ||
| * <p> | ||
| * This property defines the settings required for connecting to a Redis Sentinel | ||
| * setup. It includes information about the master node, a list of sentinel nodes, | ||
| * and optional authentication credentials such as username and password. | ||
| */ | ||
| private boolean enabledLimitSession = false; | ||
| private RedisSentinelProperties sentinel = new RedisSentinelProperties(); | ||
|
|
||
| /** | ||
| * Maximum number of sessions allowed per user when session limiting is enabled. | ||
| * Default value is {@code 1}. | ||
| * Configuration property for managing Redis-based session settings for this application. | ||
| * Uses the {@link EngineRedisSessionProperties} class to define specific session handling configurations. | ||
| * Allows customization of session behavior such as session limiting and filtering. | ||
| */ | ||
| private int maxSession = 1; | ||
| private EngineRedisSessionProperties session = new EngineRedisSessionProperties(); | ||
|
|
||
| /** | ||
| * Flag indicating whether Redis filtering is enabled. | ||
| * Default value is {@code false}. | ||
| * Represents configuration properties for Redis Sentinel. | ||
| * This class is typically used to configure and connect to a Redis Sentinel setup | ||
| * by specifying the master node and the sentinel nodes involved. | ||
| */ | ||
| private boolean enabledFilter = false; | ||
| @Data | ||
| public static class RedisSentinelProperties { | ||
|
|
||
| public static final String DEFAULT_SENTINEL_NODE = "localhost:" + RedisNode.DEFAULT_SENTINEL_PORT; | ||
|
|
||
| /** | ||
| * The name of the Redis master node to which Redis Sentinel clients should connect. | ||
| * Specifies the master node in a Redis Sentinel deployment that is responsible for | ||
| * managing the data and serving read/write queries. | ||
| * This variable is essential for identifying the Redis master node among the available | ||
| * nodes in the Sentinel setup. | ||
| */ | ||
| private String master; | ||
|
|
||
| /** | ||
| * A list of Redis Sentinel nodes used for connection. | ||
| * Each node in the list should be in the format of "host:port". | ||
| * By default, this list contains a single node pointing to "localhost:26379". | ||
| * In a Redis Sentinel setup, multiple nodes can be specified to ensure high availability and fault tolerance. | ||
| */ | ||
| private List<String> nodes = List.of(DEFAULT_SENTINEL_NODE); | ||
|
|
||
| /** | ||
| * The username used for authentications or configurations related to Redis Sentinel properties. | ||
| * This variable can be used to specify an optional username for connecting to a Redis database | ||
| * when authentication is configured to require one. | ||
| */ | ||
| private String username; | ||
|
|
||
| /** | ||
| * The password used for authentication with the Redis Sentinel setup. | ||
| * This variable specifies the password needed to connect to the Redis database | ||
| * when the configuration requires authentication for access. | ||
| * It ensures secure communication and prevents unauthorized access to the database. | ||
| */ | ||
| private String password; | ||
| } | ||
|
|
||
| /** | ||
| * Configuration properties for Redis session management in the application. | ||
| * <p> | ||
| * This class extends {@link RedisSessionProperties}, providing additional | ||
| * configurations specific to Redis-based session handling in the application. | ||
| * It allows session limiting and other Redis-specific session settings. | ||
| */ | ||
| @Data | ||
| @EqualsAndHashCode(callSuper = true) | ||
| public static class EngineRedisSessionProperties extends RedisSessionProperties { | ||
|
|
||
| /** | ||
| * Flag indicating whether to enable session limit functionality. | ||
| * If {@code true}, sessions will be limited based on the configured {@link #maxSession} value. | ||
| */ | ||
| private boolean enabledLimitSession = false; | ||
|
|
||
| /** | ||
| * Maximum number of sessions allowed per user when session limiting is enabled. | ||
| * Default value is {@code 1}. | ||
| */ | ||
| private int maxSession = 1; | ||
|
|
||
| /** | ||
| * Flag indicating whether Redis filtering is enabled. | ||
| * Default value is {@code false}. | ||
| */ | ||
| private boolean enabledFilter = false; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -19,7 +19,7 @@ public class ImpersonationConfigurationProperties { | |||||
| * The Redis namespace used for storing impersonation configurations. | ||||||
| * This value is resolved from the "redisProperties.namespace" SpEL expression. | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Update the outdated comment. The comment references the old SpEL expression path. It should be updated to reflect the new nested structure. Apply this diff to update the comment: - * This value is resolved from the "redisProperties.namespace" SpEL expression.
+ * This value is resolved from the "redisProperties.session.namespace" SpEL expression.📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| */ | ||||||
| @Value("#{redisProperties.namespace}") | ||||||
| @Value("#{redisProperties.session.namespace}") | ||||||
| private String redisNamespace; | ||||||
|
Comment on lines
+22
to
23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainVerify the redisProperties bean structure supports the new nested path. The SpEL expression change aligns with the broader refactoring to nest session-related Redis properties. However, ensure that:
Run the following script to verify that the Additionally, verify that migration documentation or release notes exist for this breaking change: 🏁 Script executed: #!/bin/bash
# Description: Verify redisProperties bean has session.namespace structure
# Search for the RedisProperties class definition and its session property
ast-grep --pattern $'class $_ {
$$$
session
$$$
}'
# Also search for getSession or setSession methods in properties classes
rg -n -C5 --type=java 'getSession|setSession|class.*Properties' application-engine/src/main/java/com/netgrif/application/engine/configuration/properties/Length of output: 105172 🏁 Script executed: #!/bin/bash
# Search for migration docs or changelog entries
fd -e md . | xargs rg -l 'migration|breaking.*change|Redis.*Sentinel|session.*namespace' --type=mdLength of output: 57 🏁 Script executed: #!/bin/bash
# Check CHANGELOG.md for breaking change documentation
cat application-engine/CHANGELOG.md | head -100Length of output: 3686 🏁 Script executed: #!/bin/bash
# Search CHANGELOG for redis and session related entries
rg -n 'redis|session|namespace' application-engine/CHANGELOG.md -iLength of output: 311 🏁 Script executed: #!/bin/bash
# Search for migration guides or breaking change documentation
fd -e md -e rst . | xargs grep -l "breaking\|migration\|upgrade" 2>/dev/null | head -20Length of output: 65 Document this breaking change in the CHANGELOG and provide migration guidance. The SpEL expression change is structurally correct—the
🤖 Prompt for AI Agents |
||||||
|
|
||||||
| /** | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.