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

Token based authentication integration with core extension #4011

Merged
merged 24 commits into from
Dec 20, 2024

Conversation

atakavci
Copy link
Contributor

@atakavci atakavci commented Nov 6, 2024

This PR Provides the required changes to integrate the token based authentication using the core module from redis-authx.

AuthXManager is the main component which handles the id provider creation and management as well as glueing the renewal process to jedis clients internal connection management.

An instance of AuthXManager should be provided to jedis simply via JedisClientConfiguration.
The configuration and creation of AuthXManager can be easily achieved through identity provider-specific configuration builders.
MS EntraID identity provider is already provided within redis-authx.

A basic usage would look like;

    TokenAuthConfig tokenAuthConfig = EntraIDTokenAuthConfigBuilder.builder()
        .clientId("YOUR_CLIENT_ID").secret("YOUR_SECRET")
        .authority("YOUR_AUTHORITY").scopes("SCOPES").build();

    DefaultJedisClientConfig jedisConfig = DefaultJedisClientConfig.builder()
        .authXManager(new AuthXManager(tokenAuthConfig)).build();

    try (JedisPooled jedis = new JedisPooled(hnp, jedisConfig)) {
      ...
      ...
    }

@atakavci atakavci marked this pull request as draft November 7, 2024 07:25
Copy link
Collaborator

@sazzad16 sazzad16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would easier to review if you could avoid formatting-only changes.

pom.xml Outdated Show resolved Hide resolved
atakavci and others added 3 commits November 18, 2024 18:35
- introduce authenticationeventlisteners
- clenaup in connectionpool
- add entraidtestcontext
- add redisintegrationtests
- fix failing tokenbasedauthentication unit&integ tests
@atakavci atakavci marked this pull request as ready for review December 10, 2024 09:16
- set audiences with scopes
- managed identity tests
pom.xml Outdated Show resolved Hide resolved
@@ -69,11 +76,23 @@ public final void punsubscribe(T... patterns) {
}

public final void ping() {
sendAndFlushCommand(Command.PING);
authenticator.commandSync.lock();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO it would be good to mention why we need to lock here.

As far as I can tell this is because the AUTH command is async and we want to be sure we dont get a concurrency problem when the user and auth threads attempt to write in the same time?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats correct , i will provide explanation in another iteration

tishun
tishun previously approved these changes Dec 20, 2024
Copy link

@tishun tishun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@uglide uglide left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Endpoints in tests should be fixed.

AuthXManager manager = new AuthXManager(EntraIDTokenAuthConfigBuilder.builder()
.lowerRefreshBoundMillis(1000).identityProviderConfig(idpConfig).build());

HostAndPort hp = HostAndPorts.getClusterServers().get(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use here cluster-entraid-acl endpoint

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as long as this endpoint answers to cluster commands it would be fine. Right now the tests can run without entraid enabled endpoints and make the necessary assertions on it. It would be better to keep them running on each commit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the integration test, we do not bring up the endpoints hardcoded in the cluster config, so we need to switch to the cluster-entraid-acl to be able to run the tests. Let me know if I'm missing something here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes , it doesnt run with entraid enabled env but runs within every integration test in jedis repo

return result;
}).when(authXManager).addConnection(any(Connection.class));

HostAndPort hp = HostAndPorts.getClusterServers().get(0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same case with other one

@uglide uglide merged commit d4a569c into redis:master Dec 20, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants