-
Notifications
You must be signed in to change notification settings - Fork 991
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
Token based authentication integration with core extension #3063
Merged
Conversation
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
ggivo
changed the title
Token based auth
Token based authentication integration with core extension
Nov 28, 2024
ggivo
force-pushed
the
token-based-auth
branch
2 times, most recently
from
November 28, 2024 09:17
cb51afa
to
ec791b2
Compare
atakavci
reviewed
Dec 1, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can anticipate what BaseRedisAuthenticationHandler
holds but lets see the actual impl before moving further.
This enables use cases like credential rotation and token based auth without client disconnect. Especially with Pub/Sub clients will reduce the chnance of missing events.
ggivo
force-pushed
the
token-based-auth
branch
from
December 3, 2024 10:30
dd30876
to
78a0aea
Compare
ggivo
force-pushed
the
token-based-auth
branch
from
December 4, 2024 10:37
78a0aea
to
6531424
Compare
DEFAULT_REAUTHENTICATE_BEHAVIOUR
- Moved Authentication handler to DefaultEndpoint - updated since 6.6.0
ggivo
force-pushed
the
token-based-auth
branch
from
December 8, 2024 12:51
1fa739e
to
78fb436
Compare
ggivo
force-pushed
the
token-based-auth
branch
from
December 8, 2024 13:10
78fb436
to
98e72fb
Compare
ggivo
force-pushed
the
token-based-auth
branch
from
December 8, 2024 13:13
d33710e
to
b7efe6c
Compare
Defer the re-auth operation in case there is on-going multi Tx in lettuce need to be externally synchronised when used in multithreaded env. Since re-auth happens from different thread we need to make sure it does not happen while there is ongoing transaction.
…provider with static one provider Add unit tests for setCredentials
ggivo
force-pushed
the
token-based-auth
branch
from
December 13, 2024 14:53
b7efe6c
to
7b0fb4c
Compare
move credentials() method to RedisCredentialsProvider. Resolve issue with unsafe cast after extending RedisCredentialsProvider with supportsStreaming() method
Provide a way for lettuce clients to use token-based authentication. TOKENs come with a TTL. After a Redis client authenticates with a TOKEN, if they didn't renew their authentication we need to evict (close) them. The suggested approach is to leverage the existing CredentialsProvider and add support for streaming credentials to handle token refresh scenarios. Each time a new token is received connection is reauthenticated.
ggivo
force-pushed
the
token-based-auth
branch
from
December 18, 2024 10:05
432c4f9
to
528e329
Compare
Verify authentication using Azure AD with service principals
…upportsStreaming()
ggivo
force-pushed
the
token-based-auth
branch
from
December 18, 2024 10:16
528e329
to
0e0f502
Compare
tishun
approved these changes
Dec 19, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
src/main/java/io/lettuce/authx/TokenBasedRedisCredentialsProvider.java
Outdated
Show resolved
Hide resolved
src/main/java/io/lettuce/authx/TokenBasedRedisCredentialsProvider.java
Outdated
Show resolved
Hide resolved
…der.java Co-authored-by: Tihomir Krasimirov Mateev <[email protected]>
ggivo
force-pushed
the
token-based-auth
branch
from
December 19, 2024 12:45
c4dafe4
to
adfe98e
Compare
ggivo
force-pushed
the
token-based-auth
branch
from
December 19, 2024 13:02
adfe98e
to
a2a8e10
Compare
tishun
reviewed
Dec 19, 2024
tishun
reviewed
Dec 19, 2024
tishun
reviewed
Dec 19, 2024
TokenBasedRedisCredentialsProvider
tishun
added a commit
that referenced
this pull request
Dec 20, 2024
* Support for StreamingCredentials This enables use cases like credential rotation and token based auth without client disconnect. Especially with Pub/Sub clients will reduce the chnance of missing events. * Tests & publish ReauthEvent * Clean up & Format & Add ReauthenticateEvent test * Conditionally enable connection reauthentication based on client setting DEFAULT_REAUTHENTICATE_BEHAVIOUR * Client setting for enabling reauthentication - Moved Authentication handler to DefaultEndpoint - updated since 6.6.0 * formating * resolve conflict with main * format * dispath using connection handler * Support multi with re-auth Defer the re-auth operation in case there is on-going multi Tx in lettuce need to be externally synchronised when used in multithreaded env. Since re-auth happens from different thread we need to make sure it does not happen while there is ongoing transaction. * Fix EndpointId missing in events * format * Add unit tests for setCredenatials * Skip preProcessing of auth command to avoid replacing the credential provider with static one provider Add unit tests for setCredentials * clean up - remove dead code * Moved almost all code inside the new handler * fix inTransaction lock with dispatch command batch * Remove StreamingCredentialsProvider interface. move credentials() method to RedisCredentialsProvider. Resolve issue with unsafe cast after extending RedisCredentialsProvider with supportsStreaming() method * Add authentication handler to ClusterPubSub connections * Token based auth integration with core extension Provide a way for lettuce clients to use token-based authentication. TOKENs come with a TTL. After a Redis client authenticates with a TOKEN, if they didn't renew their authentication we need to evict (close) them. The suggested approach is to leverage the existing CredentialsProvider and add support for streaming credentials to handle token refresh scenarios. Each time a new token is received connection is reauthenticated. * rebase to address "oid" core-autx lib change formating * Add EntraId integration tests Verify authentication using Azure AD with service principals * StreamingCredentialsProvider replaced with RedisCredentialsProvider.supportsStreaming() * pub/sub test basic functionality with entraid auth * Update src/main/java/io/lettuce/authx/TokenBasedRedisCredentialsProvider.java Co-authored-by: Tihomir Krasimirov Mateev <[email protected]> * Addressing review comments from @tishun * Bump redis-authx-core & redis-authx-entraid from 0.1.0-SNAPSHOT to 0.1.1-beta1 * add java doc for TokenBasedRedisCredentialsProvider --------- Co-authored-by: Tihomir Mateev <[email protected]> Co-authored-by: Tihomir Krasimirov Mateev <[email protected]>
thachlp
pushed a commit
to thachlp/lettuce
that referenced
this pull request
Dec 31, 2024
* Support for StreamingCredentials This enables use cases like credential rotation and token based auth without client disconnect. Especially with Pub/Sub clients will reduce the chnance of missing events. * Tests & publish ReauthEvent * Clean up & Format & Add ReauthenticateEvent test * Conditionally enable connection reauthentication based on client setting DEFAULT_REAUTHENTICATE_BEHAVIOUR * Client setting for enabling reauthentication - Moved Authentication handler to DefaultEndpoint - updated since 6.6.0 * formating * resolve conflict with main * format * dispath using connection handler * Support multi with re-auth Defer the re-auth operation in case there is on-going multi Tx in lettuce need to be externally synchronised when used in multithreaded env. Since re-auth happens from different thread we need to make sure it does not happen while there is ongoing transaction. * Fix EndpointId missing in events * format * Add unit tests for setCredenatials * Skip preProcessing of auth command to avoid replacing the credential provider with static one provider Add unit tests for setCredentials * clean up - remove dead code * Moved almost all code inside the new handler * fix inTransaction lock with dispatch command batch * Remove StreamingCredentialsProvider interface. move credentials() method to RedisCredentialsProvider. Resolve issue with unsafe cast after extending RedisCredentialsProvider with supportsStreaming() method * Add authentication handler to ClusterPubSub connections * Token based auth integration with core extension Provide a way for lettuce clients to use token-based authentication. TOKENs come with a TTL. After a Redis client authenticates with a TOKEN, if they didn't renew their authentication we need to evict (close) them. The suggested approach is to leverage the existing CredentialsProvider and add support for streaming credentials to handle token refresh scenarios. Each time a new token is received connection is reauthenticated. * rebase to address "oid" core-autx lib change formating * Add EntraId integration tests Verify authentication using Azure AD with service principals * StreamingCredentialsProvider replaced with RedisCredentialsProvider.supportsStreaming() * pub/sub test basic functionality with entraid auth * Update src/main/java/io/lettuce/authx/TokenBasedRedisCredentialsProvider.java Co-authored-by: Tihomir Krasimirov Mateev <[email protected]> * Addressing review comments from @tishun * Bump redis-authx-core & redis-authx-entraid from 0.1.0-SNAPSHOT to 0.1.1-beta1 * add java doc for TokenBasedRedisCredentialsProvider --------- Co-authored-by: Tihomir Mateev <[email protected]> Co-authored-by: Tihomir Krasimirov Mateev <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
This PR Provides the required changes to integrate the token based authentication using the
core
module from redis-authx.TokenBasedRedisCredentialsProvider is the main component which handles the id provider creation and management as well as glueing the renewal process to lettuce connection management.
An instance of
TokenBasedRedisCredentialsProvider
should be provided to Letuce connection through respectiveRedisUri
. In addtionClientOptions.ReauthenticateBehavior.ON_NEW_CREDENTIALS
should be configured on theRedisClient
TokenBasedRedisCredentialsProvider
lifecycle is not controlled by the RedisClient itself and need to me managed externaly.TokenBasedRedisCredentialsProvider.shutdown()
method need to be invoked once no longer needed to stop renewing tokens.The configuration and creation of TokenBasedRedisCredentialsProvider is achieved through identity provider-specific configuration builders.
MS EntraID identity provider is already provided within redis-authx.
A basic usage would look like;
Make sure that:
mvn formatter:format
target. Don’t submit any formatting related changes.