Skip to content

Commit 5d8f869

Browse files
atakavciuglide
andauthored
Basic documention for TBA support with some examples (redis#4102)
* tba doc * fix sub headers * fix spellcheck * updates with suggestions from @uglide Co-authored-by: Igor Malinovskiy <[email protected]> * review from @ggivo --------- Co-authored-by: Igor Malinovskiy <[email protected]>
1 parent aa56473 commit 5d8f869

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

.github/wordlist.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,3 +336,9 @@ zrevrangeByScore
336336
zrevrangeByScoreWithScores
337337
zrevrangeWithScores
338338
zunionstore
339+
authx
340+
entraid
341+
EntraID
342+
ACR
343+
AMR
344+
Entra

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,14 @@ Jedis supports retry and failover for your Redis deployments. This is useful whe
136136

137137
For the complete failover configuration options and examples, see the [Jedis failover docs](docs/failover.md).
138138

139+
## Token-Based Authentication
140+
141+
Jedis supports Token-Based authentication (TBA) starting with 5.3.0 GA release. This feature is complemented by an extension library that enhances the developer experience and provides most of the components required for TBA functionality.
142+
143+
Notably, the extension library includes built-in support for **Microsoft EntraID**, offering a seamless integration as part of the generic solution.
144+
145+
For more details and examples, please refer to the [Advanced Usage](docs/advanced-usage.md) documentation.
146+
139147
## Documentation
140148

141149
The [Jedis wiki](http://github.com/redis/jedis/wiki) contains several useful articles for using Jedis.

docs/advanced-usage.md

Lines changed: 89 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jedis.subscribe(l, "foo");
9797
Note that subscribe is a blocking operation because it will poll Redis for responses on the thread that calls subscribe. A single JedisPubSub instance can be used to subscribe to multiple channels. You can call subscribe or psubscribe on an existing JedisPubSub instance to change your subscriptions.
9898

9999

100-
### Monitoring
100+
## Monitoring
101101

102102
To use the monitor command you can do something like the following:
103103

@@ -122,6 +122,94 @@ jedis.monitor(new JedisMonitor() {
122122
}
123123
});
124124
```
125+
## Token-Based Authentication
126+
127+
Starting with version 5.3.0 GA, Jedis supports token-based authentication. The [redis-authx-entraid](https://github.com/redis/jvm-redis-authx-entraid) repository provides the necessary components that Jedis utilizes to enable this functionality.
128+
129+
Additionally, support for Microsoft EntraID has been fully implemented and is now available as an extension for Azure Managed Redis (AMR) and Azure Cache for Redis(ACR).
130+
131+
### Using With Custom Identity Provider
132+
Jedis provides a token-based authentication mechanism with a generic identity provider of your choice.
133+
For custom use of this feature, you will need to provide an implementation of `IdentityProvider` and `IdentityProviderConfig` and configure it in the way Jedis expects.
134+
135+
You will have the required interfaces from transitive Jedis dependencies;
136+
137+
```
138+
<dependency>
139+
<groupId>redis.clients.authentication</groupId>
140+
<artifactId>redis-authx-core</artifactId>
141+
<version>${version}</version>
142+
</dependency>
143+
```
144+
145+
**An example to get started:**
146+
```java
147+
public class YourCustomIdentityProviderConfig implements IdentityProviderConfig {
148+
...
149+
}
150+
151+
public class YourCustomIdentityProvider implements IdentityProvider {
152+
...
153+
}
154+
```
155+
156+
Then configure Jedis like this:
157+
```java
158+
IdentityProviderConfig yourCustomIdentityProviderConfig = new YourCustomIdentityProviderConfig();
159+
TokenAuthConfig tokenAuthConfig = TokenAuthConfig.builder().identityProviderConfig(yourCustomIdentityProviderConfig);
160+
161+
JedisClientConfig config = DefaultJedisClientConfig.builder()
162+
.authXManager(new AuthXManager(tokenAuthConfig)).build();
163+
...
164+
```
165+
### Using With Microsoft EntraID
166+
167+
Extension for EntraID is fully integrated and ready to use with [Azure Managed Redis](https://azure.microsoft.com/en-us/products/managed-redis)(AMR) or [Azure Cache for Redis](https://azure.microsoft.com/en-us/products/cache/)(ACR). All you need is to add the EntraID dependency and code for configuration for chosen authentication type with Microsoft EntraID service.
168+
169+
To get started, add the `redis-authx-entraid` extension as dependency;
170+
171+
```
172+
<dependency>
173+
<groupId>redis.clients.authentication</groupId>
174+
<artifactId>redis-authx-entraid</artifactId>
175+
<version>${version}</version>
176+
</dependency>
177+
```
178+
179+
After adding the dependency, configure it using `EntraIDTokenAuthConfigBuilder`:
180+
181+
```java
182+
...
183+
TokenAuthConfig tokenAuthConfig = EntraIDTokenAuthConfigBuilder.builder()
184+
.expirationRefreshRatio(0.8F)
185+
.clientId("yourClientId")
186+
.secret("yourClientSecret")
187+
.authority("yourAuthority")
188+
.scopes("yourRedisScopes").build();
189+
190+
AuthXManager authXManager = new AuthXManager(tokenAuthConfig);
191+
192+
JedisClientConfig config = DefaultJedisClientConfig.builder()
193+
.authXManager(authXManager).build();
194+
...
195+
```
196+
197+
Here you will see the `AuthXManager` class that is built into Jedis. Essentially it integrates the extension into Jedis and handles the authentication process.
198+
For other available configurations, detailed information and usage of Jedis with Microsoft EntraID, please refer to the [official guide](https://redis.io/docs/latest/develop/clients/jedis/amr/)
199+
200+
**Setting Up AMR or ACR with Microsoft EntraID:**
201+
202+
To use Microsoft EntraID with AMR or ACR, for sure you will need to set up and configure your AMR/ACR services as well as Microsoft EntraID. The following resources provide useful information;
203+
204+
[Azure Managed Redis](https://azure.microsoft.com/en-us/products/managed-redis)
205+
206+
[Azure Cache for Redis](https://azure.microsoft.com/en-us/products/cache/)
207+
208+
[Microsoft Entra ID for AMR authentication](https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/managed-redis/managed-redis-entra-for-authentication)
209+
210+
[Microsoft Entra ID for ACR authentication](https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-azure-active-directory-for-authentication)
211+
212+
[Use Microsoft Entra](https://learn.microsoft.com/en-us/azure/app-service/configure-authentication-provider-aad?tabs=workforce-configuration)
125213

126214
## Miscellaneous
127215

0 commit comments

Comments
 (0)