From 419b0c7cc97f5a853aa93ecb1e7d31f2ff5ae272 Mon Sep 17 00:00:00 2001 From: Peter Ritzinger Date: Tue, 13 May 2025 09:19:03 +0200 Subject: [PATCH 1/3] Fix invalid scope in Lettuce sample using identity for Redis Cache --- sdk/identity/azure-identity/CHANGELOG.md | 1 + .../Lettuce/Azure-AAD-Authentication-With-Lettuce.md | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/sdk/identity/azure-identity/CHANGELOG.md b/sdk/identity/azure-identity/CHANGELOG.md index 27775c007ac9..feef9d9f6a3b 100644 --- a/sdk/identity/azure-identity/CHANGELOG.md +++ b/sdk/identity/azure-identity/CHANGELOG.md @@ -7,6 +7,7 @@ ### Breaking Changes ### Bugs Fixed +- Fix invalid scope in Lettuce sample using identity for Redis Cache. ### Other Changes diff --git a/sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Lettuce/Azure-AAD-Authentication-With-Lettuce.md b/sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Lettuce/Azure-AAD-Authentication-With-Lettuce.md index 4ee97c668a83..0ac7c29f8e15 100644 --- a/sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Lettuce/Azure-AAD-Authentication-With-Lettuce.md +++ b/sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Lettuce/Azure-AAD-Authentication-With-Lettuce.md @@ -112,7 +112,7 @@ System.out.println(sync.get("Az:testKey")); public static class AzureRedisCredentials implements RedisCredentials { // Note: The Scopes value will change as the Microsoft Entra authentication support hits public preview and eventually GA's. private TokenRequestContext tokenRequestContext = new TokenRequestContext() - .addScopes("cca5fbb-b7e4-4009-81f1-37e38fd66d78/.default"); + .addScopes("https://redis.azure.com/.default"); private TokenCredential tokenCredential; private final String username; @@ -198,7 +198,7 @@ DefaultAzureCredential defaultAzureCredential = new DefaultAzureCredentialBuilde // Note: The Scopes parameter will change as the Microsoft Entra authentication support hits public preview and eventually GA's. String token = defaultAzureCredential .getToken(new TokenRequestContext() - .addScopes("cca5fbb-b7e4-4009-81f1-37e38fd66d78/.default")).block().getToken(); + .addScopes("https://redis.azure.com/.default")).block().getToken(); String username = extractUsernameFromToken(token); From e7239e11e4ad42032a3d305798f26c7e7f2cb7d8 Mon Sep 17 00:00:00 2001 From: Peter Ritzinger Date: Tue, 13 May 2025 16:54:53 +0200 Subject: [PATCH 2/3] Remove comments about scope change --- .../Lettuce/Azure-AAD-Authentication-With-Lettuce.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Lettuce/Azure-AAD-Authentication-With-Lettuce.md b/sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Lettuce/Azure-AAD-Authentication-With-Lettuce.md index 0ac7c29f8e15..9d655e16e165 100644 --- a/sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Lettuce/Azure-AAD-Authentication-With-Lettuce.md +++ b/sdk/identity/azure-identity/src/samples/Azure-Cache-For-Redis/Lettuce/Azure-AAD-Authentication-With-Lettuce.md @@ -110,7 +110,6 @@ System.out.println(sync.get("Az:testKey")); * Redis Credential Implementation for Azure Redis for Cache */ public static class AzureRedisCredentials implements RedisCredentials { - // Note: The Scopes value will change as the Microsoft Entra authentication support hits public preview and eventually GA's. private TokenRequestContext tokenRequestContext = new TokenRequestContext() .addScopes("https://redis.azure.com/.default"); private TokenCredential tokenCredential; @@ -195,7 +194,6 @@ private static String extractUsernameFromToken(String token) { DefaultAzureCredential defaultAzureCredential = new DefaultAzureCredentialBuilder().build(); // Fetch a Microsoft Entra token to be used for authentication. The Microsoft Entra token will be used as password. -// Note: The Scopes parameter will change as the Microsoft Entra authentication support hits public preview and eventually GA's. String token = defaultAzureCredential .getToken(new TokenRequestContext() .addScopes("https://redis.azure.com/.default")).block().getToken(); @@ -340,7 +338,6 @@ private static RedisClient createLettuceRedisClient(String hostName, int port, T * Redis Credential Implementation for Azure Redis for Cache */ public static class AzureRedisCredentials implements RedisCredentials { - // Note: The Scopes parameter will change as the Microsoft Entra authentication support hits public preview and eventually GA's. private TokenRequestContext tokenRequestContext = new TokenRequestContext() .addScopes("https://redis.azure.com/.default"); private TokenCredential tokenCredential; @@ -426,7 +423,6 @@ private static String extractUsernameFromToken(String token) { DefaultAzureCredential defaultAzureCredential = new DefaultAzureCredentialBuilder().build(); // Fetch a Microsoft Entra token to be used for authentication. This token will be used as the password. -// Note: The Scopes parameter will change as the Microsoft Entra authentication support hits public preview and eventually GA's. TokenRequestContext trc = new TokenRequestContext().addScopes("https://redis.azure.com/.default"); AccessToken accessToken = getAccessToken(defaultAzureCredential, trc); @@ -773,7 +769,6 @@ private static String extractUsernameFromToken(String token) { DefaultAzureCredential defaultAzureCredential = new DefaultAzureCredentialBuilder().build(); // Fetch a Microsoft Entra token to be used for authentication. This token will be used as the password. -// Note: The Scopes parameter will change as the Microsoft Entra authentication support hits public preview and eventually GA's. TokenRequestContext trc = new TokenRequestContext().addScopes("https://redis.azure.com/.default"); // Instantiate the Token Refresh Cache, this cache will proactively refresh the access token 2 minutes before expiry. From 4d6ecf37793c5b55ca0bfc9570141e616d680cd4 Mon Sep 17 00:00:00 2001 From: Peter Ritzinger Date: Wed, 14 May 2025 17:55:22 +0200 Subject: [PATCH 3/3] Remove changelog entry --- sdk/identity/azure-identity/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/identity/azure-identity/CHANGELOG.md b/sdk/identity/azure-identity/CHANGELOG.md index feef9d9f6a3b..27775c007ac9 100644 --- a/sdk/identity/azure-identity/CHANGELOG.md +++ b/sdk/identity/azure-identity/CHANGELOG.md @@ -7,7 +7,6 @@ ### Breaking Changes ### Bugs Fixed -- Fix invalid scope in Lettuce sample using identity for Redis Cache. ### Other Changes