Skip to content

Commit 373008f

Browse files
authored
Clarify AAD properties for Spring Cloud Azure (Azure#33538)
1 parent a871028 commit 373008f

File tree

9 files changed

+80
-42
lines changed

9 files changed

+80
-42
lines changed

.vscode/cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,7 @@
953953
"OIDC",
954954
"qpid",
955955
"reqoest",
956+
"signin",
956957
"Spel",
957958
"sqldb",
958959
"SQLDB",

sdk/spring/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ This section includes changes in `spring-cloud-azure-stream-binder-eventhubs` mo
1414
#### Breaking Changes
1515
- Make the default partition behavior of Spring Cloud Azure EventHubs binder be a round-robin assignment to align with Event Hubs.[#32816](https://github.com/Azure/azure-sdk-for-java/pull/32816).
1616

17+
### Spring Cloud Azure Autoconfigure
18+
This section includes changes in `spring-cloud-azure-autoconfigure` module.
19+
20+
#### Breaking Changes
21+
- Deprecated properties for AAD and AAD B2C. [#29471](https://github.com/Azure/azure-sdk-for-java/pull/33538).
22+
- Deprecated properties `spring.cloud.azure.active-directory.jwt-connect-timeout`, `spring.cloud.azure.active-directory.jwt-read-timeout`, `spring.cloud.azure.active-directory.jwt-size-limit`, if you want to configure them, please provide a RestOperations bean.
23+
- Deprecated properties `spring.cloud.azure.active-directory.b2c.jwt-connect-timeout`, `spring.cloud.azure.active-directory.b2c.jwt-read-timeout`, `spring.cloud.azure.active-directory.b2c.jwt-size-limit`, if you want to configure them, please provide a RestOperations bean.
24+
1725
## 4.6.0 (2023-02-07)
1826
- This release is compatible with Spring Boot 2.5.0-2.5.14, 2.6.0-2.6.14, 2.7.0-2.7.8. (Note: 2.5.x (x>14), 2.6.y (y>14) and 2.7.z (z>8) should be supported, but they aren't tested with this release.)
1927
- This release is compatible with Spring Cloud 2020.0.3-2020.0.6, 2021.0.0-2021.0.5. (Note: 2020.0.x (x>6) and 2021.0.y (y>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/aad/properties/AadAuthenticationProperties.java

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -82,42 +82,51 @@ public class AadAuthenticationProperties implements InitializingBean {
8282
private String redirectUriTemplate = "{baseUrl}/login/oauth2/code/";
8383

8484
/**
85-
* App ID URI which might be used in the "aud" claim of an id_token.
85+
* App ID URI which might be used in the "aud" claim of an id_token. For instance, 'api://{applicationId}'.
86+
* See Microsoft doc about APP ID URL for more details: https://learn.microsoft.com/azure/active-directory/develop/security-best-practices-for-app-registration#application-id-uri
8687
*/
8788
private String appIdUri;
8889

8990
/**
90-
* Add additional parameters to the Authorization URL.
91+
* Additional parameters above the standard parameters defined in the OAuth 2.0 Authorization Framework. Would be added to the Authorization URL for customizing the Authorization Request. For instance, 'prompt: login'.
92+
* See Microsoft doc about more additional parameters information: https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code
9193
*/
9294
private final Map<String, Object> authenticateAdditionalParameters = new HashMap<>();
9395

9496
/**
95-
* Connection Timeout for the JWKSet Remote URL call. Deprecated. If you want to configure this, please provide a RestOperations bean.
97+
* Connection Timeout(duration) for the JWKSet Remote URL call. The default value is `500s`.
98+
* @deprecated If you want to configure this, please provide a RestOperations bean.
9699
*/
100+
@Deprecated
97101
private Duration jwtConnectTimeout = Duration.ofMillis(RemoteJWKSet.DEFAULT_HTTP_CONNECT_TIMEOUT);
98102

99103
/**
100-
* Read Timeout for the JWKSet Remote URL call. Deprecated. If you want to configure this, please provide a RestOperations bean.
104+
* Read Timeout(duration) for the JWKSet Remote URL call. The default value is `500s`.
105+
* @deprecated If you want to configure this, please provide a RestOperations bean.
101106
*/
107+
@Deprecated
102108
private Duration jwtReadTimeout = Duration.ofMillis(RemoteJWKSet.DEFAULT_HTTP_READ_TIMEOUT);
103109

104110
/**
105-
* Size limit in Bytes of the JWKSet Remote URL call. Deprecated. If you want to configure this, please provide a RestOperations bean.
111+
* Size limit in Bytes of the JWKSet Remote URL call. The default value is `51200`.
112+
* @deprecated If you want to configure this, please provide a RestOperations bean.
106113
*/
114+
@Deprecated
107115
private int jwtSizeLimit = RemoteJWKSet.DEFAULT_HTTP_SIZE_LIMIT; /* bytes */
108116

109117
/**
110-
* The lifespan of the cached JWK set before it expires, default is 5 minutes.
118+
* The lifespan(duration) of the cached JWK set before it expires. The default value is `5m`.
111119
*/
112120
private Duration jwkSetCacheLifespan = Duration.ofMinutes(5);
113121

114122
/**
115-
* The refresh time of the cached JWK set before it expires, default is 5 minutes.
123+
* The refresh time(duration) of the cached JWK set before it expires. The default value is `5m`.
116124
*/
117125
private Duration jwkSetCacheRefreshTime = Duration.ofMinutes(5);
118126

119127
/**
120-
* The redirect uri after logout.
128+
* The redirect uri after logout. For instance, 'http://localhost:8080/'.
129+
* See Microsoft doc about Redirect URI for more details: https://learn.microsoft.com/azure/active-directory/develop/security-best-practices-for-app-registration#redirect-uri
121130
*/
122131
private String postLogoutRedirectUri;
123132

@@ -128,12 +137,19 @@ public class AadAuthenticationProperties implements InitializingBean {
128137
private Boolean sessionStateless = false;
129138

130139
/**
131-
* The OAuth2 authorization clients.
140+
* The OAuth2 authorization clients, contains the authorization grant type, client authentication method and scope.
141+
* The clients will be converted to OAuth2 ClientRegistration, the other ClientRegistration information(such as client id, client secret) inherits from the delegated OAuth2 login client 'azure'.
142+
* For instance,'
143+
* authorization-clients.webapi.authorization-grant-type=on_behalf_of,
144+
* authorization-clients.webapi.client-authentication-method=client_secret_post,
145+
* authorization-clients.webapi.scopes[0]={WEB_API_APP_ID_URL}/WebApi.ExampleScope1,
146+
* authorization-clients.webapi.scopes[0]={WEB_API_APP_ID_URL}/WebApi.ExampleScope2
147+
* '.
132148
*/
133149
private final Map<String, AuthorizationClientProperties> authorizationClients = new HashMap<>();
134150

135151
/**
136-
* Type of the Azure AD application.
152+
* Type of the Azure AD application. Supported types are: WEB_APPLICATION, RESOURCE_SERVER, RESOURCE_SERVER_WITH_OBO, WEB_APPLICATION_AND_RESOURCE_SERVER. The value can be inferred by dependencies, only 'web_application_and_resource_server' must be configured manually.
137153
*/
138154
private AadApplicationType applicationType;
139155

@@ -201,7 +217,7 @@ public static class UserGroupProperties {
201217
private Set<String> allowedGroupIds = new HashSet<>();
202218

203219
/**
204-
* If "true", use "v1.0/me/transitiveMemberOf" to get members. Otherwise, use "v1.0/me/memberOf".
220+
* Whether to use transitive way to get members. If "true", use "v1.0/me/transitiveMemberOf" to get members. Otherwise, use "v1.0/me/memberOf". The default value is `false`.
205221
*/
206222
private boolean useTransitiveMembers = false;
207223

sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/aad/properties/AadProfileProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class AadProfileProperties {
1818
*/
1919
private String tenantId; // tenantId can not set to "common" here, otherwise we can not know whether it's set by customer or it is the default value.
2020
/**
21-
* Name of the Azure cloud to connect to. Supported types are: AZURE, AZURE_CHINA, AZURE_GERMANY, AZURE_US_GOVERNMENT, OTHER.
21+
* Name of the Azure cloud to connect to. Supported types are: AZURE, AZURE_CHINA, AZURE_GERMANY, AZURE_US_GOVERNMENT, OTHER. The default value is `AZURE`.
2222
*/
2323
private AzureProfileOptionsProvider.CloudType cloudType;
2424
/**

sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/aad/properties/AadResourceServerProperties.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,12 @@ public class AadResourceServerProperties implements InitializingBean {
3838

3939
/**
4040
*
41-
* Configure which claim in access token be returned in AuthenticatedPrincipal#getName. Default value is "sub".
41+
* Configure which claim in access token be returned in AuthenticatedPrincipal#getName. Example: If use the default value, and the access_token's "sub" scope value is "testValue", then AuthenticatedPrincipal#getName will return "testValue". The default value is `"sub"`.
4242
*/
4343
private String principalClaimName;
4444

4545
/**
46-
* Configure which claim will be used to build GrantedAuthority, and prefix of the GrantedAuthority's string value.
47-
* Default value is: "scp" -> "SCOPE_", "roles" -> "APPROLE_".
46+
* Configure which claim will be used to build GrantedAuthority, and prefix of the GrantedAuthority's string value. Example: If use the default value, and the access_token's "scp" scope value is "testValue", then GrantedAuthority with "SCOPE_testValue" will be created. The default value is `"scp" -> "SCOPE_", "roles" -> "APPROLE_"`.
4847
*/
4948
private Map<String, String> claimToAuthorityPrefixMap;
5049

sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/aad/properties/AuthorizationClientProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import java.util.List;
1010

1111
/**
12-
* Properties for an oauth2 client.
12+
* Properties for an OAuth2 client.
1313
*/
1414
public class AuthorizationClientProperties {
1515

sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/aadb2c/properties/AadB2cProperties.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,30 @@ public class AadB2cProperties implements InitializingBean {
5454
private final AadB2cCredentialProperties credential = new AadB2cCredentialProperties();
5555

5656
/**
57-
* App ID URI which might be used in the "aud" claim of a token.
57+
* App ID URI which might be used in the "aud" claim of a token. For instance, 'https://{hostname}/{applicationId}'.
58+
* See Microsoft doc about APP ID URL for more details: https://learn.microsoft.com/azure/active-directory/develop/security-best-practices-for-app-registration#application-id-uri
5859
*/
5960
private String appIdUri;
6061

6162
/**
62-
* Connection Timeout for the JWKSet Remote URL call. Deprecated. If you want to configure this, please provide a RestOperations bean.
63+
* Connection Timeout(duration) for the JWKSet Remote URL call. The default value is `500s`.
64+
* @deprecated If you want to configure this, please provide a RestOperations bean.
6365
*/
66+
@Deprecated
6467
private Duration jwtConnectTimeout = Duration.ofMillis(RemoteJWKSet.DEFAULT_HTTP_CONNECT_TIMEOUT);
6568

6669
/**
67-
* Read Timeout for the JWKSet Remote URL call. Deprecated. If you want to configure this, please provide a RestOperations bean.
70+
* Read Timeout(duration) for the JWKSet Remote URL call. The default value is `500s`.
71+
* @deprecated If you want to configure this, please provide a RestOperations bean.
6872
*/
73+
@Deprecated
6974
private Duration jwtReadTimeout = Duration.ofMillis(RemoteJWKSet.DEFAULT_HTTP_READ_TIMEOUT);
7075

7176
/**
72-
* Size limit in Bytes of the JWKSet Remote URL call. Deprecated. If you want to configure this, please provide a RestOperations bean.
77+
* Size limit in Bytes of the JWKSet Remote URL call. The default value is `50*1024`.
78+
* @deprecated If you want to configure this, please provide a RestOperations bean.
7379
*/
80+
@Deprecated
7481
private int jwtSizeLimit = RemoteJWKSet.DEFAULT_HTTP_SIZE_LIMIT; /* bytes */
7582

7683
/**
@@ -79,7 +86,8 @@ public class AadB2cProperties implements InitializingBean {
7986
private String logoutSuccessUrl = DEFAULT_LOGOUT_SUCCESS_URL;
8087

8188
/**
82-
* Additional parameters for authentication.
89+
* Additional parameters above the standard parameters defined in the OAuth 2.0 Authorization Framework. Would be added to the Authorization URL for customizing the Authorization Request. For instance, 'prompt: login'.
90+
* See Microsoft doc about more additional parameters information: https://learn.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow#request-an-authorization-code
8391
*/
8492
private final Map<String, Object> authenticateAdditionalParameters = new HashMap<>();
8593

@@ -104,12 +112,18 @@ public class AadB2cProperties implements InitializingBean {
104112
private String loginFlow = DEFAULT_KEY_SIGN_UP_OR_SIGN_IN;
105113

106114
/**
107-
* User flows.
115+
* Azure AD B2C User flows. Configure the user flow type and name mapping. For instance, 'sign-up-or-sign-in: B2C_signin_or_signup'.
116+
* See Microsoft doc about User flows for more details: https://learn.microsoft.com/azure/active-directory-b2c/user-flow-overview#user-flows
108117
*/
109118
private Map<String, String> userFlows = new HashMap<>();
110119

111120
/**
112-
* Specify client configuration.
121+
* The OAuth2 authorization clients, contains the authorization grant type(only support client credentials) and scope.
122+
* The clients will be converted to OAuth2 ClientRegistration, the other ClientRegistration information(such as client id, client secret) inherits from the OAuth2 login client(sign-in user flow).
123+
* For instance, '
124+
* authorization-clients.webapi.authorization-grant-type=client_credentials,
125+
* authorization-clients.webapi.scopes[0]={WEB_API_APP_ID_URL}/.default
126+
* '.
113127
*/
114128
private final Map<String, AuthorizationClientProperties> authorizationClients = new HashMap<>();
115129

sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/aadb2c/properties/AuthorizationClientProperties.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import java.util.List;
99

1010
/**
11-
* Properties for an oauth2 client.
11+
* Properties for an OAuth2 client.
1212
*/
1313
public class AuthorizationClientProperties {
1414

0 commit comments

Comments
 (0)