Skip to content
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

Support for StreamingCredentials #3068

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions src/main/java/io/lettuce/core/ClientOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,13 @@ public Builder disconnectedBehavior(DisconnectedBehavior disconnectedBehavior) {
return this;
}

/**
* Configure the {@link ReauthenticateBehavior} of the Lettuce driver. Defaults to
* {@link ReauthenticateBehavior#DEFAULT}.
*
* @param reauthenticateBehavior the {@link ReauthenticateBehavior} to use. Must not be {@code null}.
* @return {@code this}
*/
public Builder reauthenticateBehavior(ReauthenticateBehavior reauthenticateBehavior) {

LettuceAssert.notNull(reauthenticateBehavior, "ReuthenticatBehavior must not be null");
Expand Down Expand Up @@ -589,6 +596,12 @@ public DisconnectedBehavior getDisconnectedBehavior() {
return disconnectedBehavior;
}

/**
* Behavior for re-authentication when the {@link RedisCredentialsProvider} emits new credentials. Defaults to
* {@link ReauthenticateBehavior#DEFAULT}.
*
* @return the currently set {@link ReauthenticateBehavior}.
*/
public ReauthenticateBehavior getReauthenticateBehaviour() {
return reauthenticateBehavior;
}
Expand Down Expand Up @@ -725,35 +738,31 @@ public TimeoutOptions getTimeoutOptions() {
}

/**
* Defines the re-authentication behavior of the Redis client in relation to the {@link CredentialsProvider}.
* Defines the re-authentication behavior of the Redis client.
* <p/>
* Certain implementations of the {@link RedisCredentialsProvider} such as the {@link StreamingCredentialsProvider} could
* emit new credentials at runtime. This setting controls how the driver reacts to these newly emitted credentials.
*/
public enum ReauthenticateBehavior {

/**
* This is the default behavior. The client will fetch current credentials from the underlying
* {@link RedisCredentialsProvider} only when required.
*
* <p>
* No re-authentication is performed automatically when new credentials are emitted by the
* {@link StreamingCredentialsProvider} .
* </p>
*
* <p>
* This behavior is suitable for use cases with static credentials or where explicit reconnection is required to change
* credentials.
* </p>
* {@link RedisCredentialsProvider} only when the driver needs to, e.g. when the connection is first established or when
* it is re-established after a disconnect.
* <p/>
* No re-authentication is performed when new credentials are emitted by the {@link StreamingCredentialsProvider} .
*/
DEFAULT,

/**
* Automatically triggers re-authentication whenever new credentials are emitted by the
* {@link StreamingCredentialsProvider} or any other credentials manager.
* Automatically triggers re-authentication whenever new credentials are emitted by any implementation of the
* {@link StreamingCredentialsProvider} interface.
*
* <p>
* When enabled, the client subscribes to the credentials stream provided by the {@link StreamingCredentialsProvider}
* (or other compatible sources) and issues an {@code AUTH} command to the Redis server each time new credentials are
* received. This behavior supports dynamic credential scenarios, such as token-based authentication, or credential
* rotation where credentials are refreshed periodically to maintain access.
* When enabled, the client subscribes to the credential stream provided by the {@link StreamingCredentialsProvider} and
* issues an {@code AUTH} command to the Redis server each time new credentials are received. This behavior supports
* dynamic credential scenarios, such as token-based authentication, or credential rotation where credentials are
* refreshed periodically to maintain access.
* </p>
*
* <p>
Expand Down
Loading
Loading