Skip to content

Commit 2919235

Browse files
Copilotrujche
andauthored
Align AzureRedisPasswordlessProperties with JDBC raw/effective scopes pattern; clarify CHANGELOG entry
Agent-Logs-Url: https://github.com/Azure/azure-sdk-for-java/sessions/bdd4ce6e-14e3-4a50-92e0-608069e8c44c Co-authored-by: rujche <171773178+rujche@users.noreply.github.com>
1 parent 011a932 commit 2919235

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

sdk/spring/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This section includes changes in `spring-cloud-azure-autoconfigure` module.
77

88
#### Bugs Fixed
99

10-
- Fixed `azure.scopes` using wrong default value for Azure China and Azure US Government when `spring.cloud.azure.profile.cloud-type` is set to `azure_china` or `azure_us_government`. The scopes are now correctly derived from the merged cloud type. ([#47096](https://github.com/Azure/azure-sdk-for-java/issues/47096))
10+
- Fixed JDBC/Azure Database passwordless connection scope defaulting using the wrong `azure.scopes` value for Azure China and Azure US Government when `spring.cloud.azure.profile.cloud-type` is set to `azure_china` or `azure_us_government`. The scopes are now correctly derived from the merged cloud type. ([#47096](https://github.com/Azure/azure-sdk-for-java/issues/47096))
1111

1212
## 7.2.0 (2026-04-17)
1313
- This release is compatible with Spring Boot 4.0.0-4.0.5. (Note: 4.0.x (x>5) should be supported, but they aren't tested with this release.)

sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/implementation/passwordless/properties/AzureRedisPasswordlessProperties.java

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
package com.azure.spring.cloud.autoconfigure.implementation.passwordless.properties;
55

6+
import com.azure.spring.cloud.core.implementation.properties.AzurePasswordlessPropertiesMapping;
67
import com.azure.spring.cloud.core.properties.PasswordlessProperties;
78
import com.azure.spring.cloud.core.properties.authentication.TokenCredentialProperties;
89
import com.azure.spring.cloud.core.properties.profile.AzureProfileProperties;
910
import com.azure.spring.cloud.core.provider.AzureProfileOptionsProvider;
1011

1112
import java.util.HashMap;
1213
import java.util.Map;
14+
import java.util.Properties;
1315

1416
/**
1517
* Configuration properties for passwordless connections with Azure Redis.
@@ -43,11 +45,22 @@ public class AzureRedisPasswordlessProperties implements PasswordlessProperties
4345

4446
/**
4547
* Get the scopes required for the access token.
48+
* Returns null if scopes have not been explicitly set, so that the default
49+
* scopes can be computed from the merged cloud type after property merging.
4650
*
47-
* @return scopes required for the access token
51+
* @return scopes required for the access token, or null if not explicitly set
4852
*/
4953
@Override
5054
public String getScopes() {
55+
return this.scopes;
56+
}
57+
58+
/**
59+
* Get the effective scopes, returning default cloud-specific scopes when not explicitly set.
60+
*
61+
* @return scopes required for the access token
62+
*/
63+
public String getEffectiveScopes() {
5164
return this.scopes == null ? getDefaultScopes() : this.scopes;
5265
}
5366

@@ -121,4 +134,25 @@ public TokenCredentialProperties getCredential() {
121134
public void setCredential(TokenCredentialProperties credential) {
122135
this.credential = credential;
123136
}
137+
138+
/**
139+
* Convert {@link AzureRedisPasswordlessProperties} to {@link Properties}.
140+
* Uses the effective scopes (cloud-type-aware) rather than the raw scopes value,
141+
* ensuring the correct default scope is used when scopes have not been explicitly set.
142+
*
143+
* @return converted {@link Properties} instance
144+
*/
145+
@Override
146+
public Properties toPasswordlessProperties() {
147+
Properties properties = new Properties();
148+
for (AzurePasswordlessPropertiesMapping m : AzurePasswordlessPropertiesMapping.values()) {
149+
String value = m == AzurePasswordlessPropertiesMapping.SCOPES
150+
? getEffectiveScopes()
151+
: m.getGetter().apply(this);
152+
if (value != null) {
153+
m.getSetter().accept(properties, value);
154+
}
155+
}
156+
return properties;
157+
}
124158
}

0 commit comments

Comments
 (0)