-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into DOC-4531-set-examples
- Loading branch information
Showing
58 changed files
with
2,756 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,41 @@ | ||
Lettuce 6.5.0 RELEASE NOTES | ||
Lettuce 6.7.0 RELEASE NOTES | ||
============================== | ||
|
||
The Redis team is delighted to announce the general availability of Lettuce 6.5. | ||
The Redis team is delighted to announce the general availability of Lettuce 6.7. | ||
|
||
Great news, everyone! Lettuce 6.5.0 comes with RedisJSON support enabled. | ||
Great news, everyone! Lettuce 6.7.0 comes with RedisJSON support enabled. | ||
For more on that, please consult with the [RedisJSON documentation](https://redis.io/docs/latest/develop/data-types/json/) and the [Lettuce guide on RedisJSON](https://redis.github.io/lettuce/user-guide/redis-json/). | ||
|
||
Lettuce 6 supports Redis 2.6+ up to Redis 7.x. In terms of Java runtime, Lettuce requires | ||
at least Java 8 and works with Java 21. | ||
|
||
Thanks to all contributors who made Lettuce 6.4.0 possible. | ||
Thanks to all contributors who made Lettuce 6.7.0 possible. | ||
|
||
If you need any support, meet Lettuce at | ||
|
||
* GitHub Discussions: https://github.com/lettuce-io/lettuce-core/discussions | ||
* Stack Overflow (Questions): https://stackoverflow.com/questions/tagged/lettuce | ||
* Join the chat at https://discord.gg/redis and look for the "Help:Tools Lettuce" channel | ||
* GitHub Issues (Bug reports, feature requests): https://github.com/lettuce-io/lettuce-core/issues | ||
* Documentation: https://lettuce.io/core/6.5.0.RELEASE/reference/ | ||
* Javadoc: https://lettuce.io/core/6.5.0.RELEASE/api/ | ||
* Documentation: https://lettuce.io/core/6.7.0.RELEASE/reference/ | ||
* Javadoc: https://lettuce.io/core/6.7.0.RELEASE/api/ | ||
|
||
Commands | ||
-------- | ||
|
||
* Add `CLUSTER MYSHARDID` in #2920 and `CLUSTER LINKS` in #2986 | ||
* Add `CLIENT TRACKINGINFO` in #2862 | ||
|
||
|
||
Enhancements | ||
------------ | ||
|
||
* Default ClientOptions.timeoutOptions to TimeoutOptions.enabled() (#2927) | ||
* Update completeExceptionally on ClusterCommand using super (#2980) | ||
|
||
|
||
Fixes | ||
----- | ||
* fix(2971): spublish typo fix (#2972) | ||
* Initialize slots with empty BitSet in RedisClusterNode's constructors (#2341) | ||
* Add defensive copy for Futures allOf() method (#2943) | ||
* fix:deadlock when reentrant exclusive lock (#2961) | ||
|
||
|
||
Other | ||
----- | ||
|
||
* Add badges to the README.md file (#2939) | ||
* Convert wiki to markdown docs (#2944) | ||
* Bump org.jacoco:jacoco-maven-plugin from 0.8.9 to 0.8.12 (#2921) | ||
* Bump org.apache.maven.plugins:maven-surefire-plugin from 3.2.5 to 3.3.1 (#2922) | ||
* Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.2.5 to 3.3.1 (#2958) | ||
* Bump org.apache.maven.plugins:maven-javadoc-plugin from 3.7.0 to 3.8.0 (#2957) | ||
* Bump org.apache.maven.plugins:maven-surefire-plugin from 3.3.1 to 3.4.0 (#2968) | ||
* Bump org.hdrhistogram:HdrHistogram from 2.1.12 to 2.2.2 (#2966) | ||
* Bump org.apache.maven.plugins:maven-compiler-plugin from 3.12.1 to 3.13.0 (#2978) | ||
* Bump org.apache.logging.log4j:log4j-bom from 2.17.2 to 2.24.0 (#2988) | ||
* Bump io.netty:netty-bom from 4.1.107.Final to 4.1.113.Final (#2990) | ||
* Suspected change in ubuntu causing CI failures (#2949) | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
137 changes: 137 additions & 0 deletions
137
src/main/java/io/lettuce/authx/TokenBasedRedisCredentialsProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
/* | ||
* Copyright 2024, Redis Ltd. and Contributors | ||
* All rights reserved. | ||
* | ||
* Licensed under the MIT License. | ||
*/ | ||
package io.lettuce.authx; | ||
|
||
import io.lettuce.core.RedisCredentials; | ||
import io.lettuce.core.RedisCredentialsProvider; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
import reactor.core.publisher.Sinks; | ||
import redis.clients.authentication.core.Token; | ||
import redis.clients.authentication.core.TokenAuthConfig; | ||
import redis.clients.authentication.core.TokenListener; | ||
import redis.clients.authentication.core.TokenManager; | ||
|
||
/** | ||
* A {@link RedisCredentialsProvider} implementation that supports token-based authentication for Redis. | ||
* <p> | ||
* This provider uses a {@link TokenManager} to manage and renew tokens, ensuring that the Redis client can authenticate with | ||
* Redis using a dynamically updated token. This is particularly useful in scenarios where Redis access is controlled via | ||
* token-based authentication, such as when Redis is integrated with an identity provider like EntraID. | ||
* </p> | ||
* <p> | ||
* The provider supports streaming of credentials and automatically emits new credentials whenever a token is renewed. It must | ||
* be used with {@link io.lettuce.core.ClientOptions.ReauthenticateBehavior#ON_NEW_CREDENTIALS} to automatically re-authenticate | ||
* connections whenever new tokens are emitted by the provider. | ||
* </p> | ||
* <p> | ||
* The lifecycle of this provider is externally managed. It should be closed when there are no longer any connections using it, | ||
* to stop the token management process and release resources. | ||
* </p> | ||
* | ||
* @since 6.6 | ||
*/ | ||
public class TokenBasedRedisCredentialsProvider implements RedisCredentialsProvider, AutoCloseable { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(TokenBasedRedisCredentialsProvider.class); | ||
|
||
private final TokenManager tokenManager; | ||
|
||
private final Sinks.Many<RedisCredentials> credentialsSink = Sinks.many().replay().latest(); | ||
|
||
private TokenBasedRedisCredentialsProvider(TokenManager tokenManager) { | ||
this.tokenManager = tokenManager; | ||
} | ||
|
||
private void init() { | ||
|
||
TokenListener listener = new TokenListener() { | ||
|
||
@Override | ||
public void onTokenRenewed(Token token) { | ||
String username = token.getUser(); | ||
char[] pass = token.getValue().toCharArray(); | ||
RedisCredentials credentials = RedisCredentials.just(username, pass); | ||
credentialsSink.tryEmitNext(credentials); | ||
} | ||
|
||
@Override | ||
public void onError(Exception exception) { | ||
log.error("Token renew failed!", exception); | ||
} | ||
|
||
}; | ||
|
||
try { | ||
tokenManager.start(listener, false); | ||
} catch (Exception e) { | ||
credentialsSink.tryEmitError(e); | ||
tokenManager.stop(); | ||
throw new RuntimeException("Failed to start TokenManager", e); | ||
} | ||
} | ||
|
||
/** | ||
* Resolve the latest available credentials as a Mono. | ||
* <p> | ||
* This method returns a Mono that emits the most recent set of Redis credentials. The Mono will complete once the | ||
* credentials are emitted. If no credentials are available at the time of subscription, the Mono will wait until | ||
* credentials are available. | ||
* | ||
* @return a Mono that emits the latest Redis credentials | ||
*/ | ||
@Override | ||
public Mono<RedisCredentials> resolveCredentials() { | ||
|
||
return credentialsSink.asFlux().next(); | ||
} | ||
|
||
/** | ||
* Expose the Flux for all credential updates. | ||
* <p> | ||
* This method returns a Flux that emits all updates to the Redis credentials. Subscribers will receive the latest | ||
* credentials whenever they are updated. The Flux will continue to emit updates until the provider is shut down. | ||
* | ||
* @return a Flux that emits all updates to the Redis credentials | ||
*/ | ||
@Override | ||
public Flux<RedisCredentials> credentials() { | ||
|
||
return credentialsSink.asFlux().onBackpressureLatest(); // Provide a continuous stream of credentials | ||
} | ||
|
||
@Override | ||
public boolean supportsStreaming() { | ||
return true; | ||
} | ||
|
||
/** | ||
* Stop the credentials provider and clean up resources. | ||
* <p> | ||
* This method stops the TokenManager and completes the credentials sink, ensuring that all resources are properly released. | ||
* It should be called when the credentials provider is no longer needed. | ||
*/ | ||
@Override | ||
public void close() { | ||
credentialsSink.tryEmitComplete(); | ||
tokenManager.stop(); | ||
} | ||
|
||
public static TokenBasedRedisCredentialsProvider create(TokenAuthConfig tokenAuthConfig) { | ||
return create(new TokenManager(tokenAuthConfig.getIdentityProviderConfig().getProvider(), | ||
tokenAuthConfig.getTokenManagerConfig())); | ||
} | ||
|
||
public static TokenBasedRedisCredentialsProvider create(TokenManager tokenManager) { | ||
TokenBasedRedisCredentialsProvider credentialManager = new TokenBasedRedisCredentialsProvider(tokenManager); | ||
credentialManager.init(); | ||
return credentialManager; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.