Skip to content

Commit f0d71af

Browse files
author
Rujun Chen
authored
Fix error in AzureActiveDirectoryConfiguration.allScopes() (Azure#17840)
* Fix error in AzureActiveDirectoryConfiguration.allScopes()
1 parent c6089a6 commit f0d71af

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

sdk/spring/azure-spring-boot-test-aad/src/test/java/com/azure/spring/aad/implementation/AzureActiveDirectoryConfigurationTest.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@ public void clientRegistered() {
3131
assertEquals("fake-client-secret", azure.getClientSecret());
3232

3333
AuthorizationServerEndpoints endpoints = new AuthorizationServerEndpoints();
34-
assertEquals(endpoints.authorizationEndpoint("fake-tenant-id"), azure.getProviderDetails().getAuthorizationUri());
34+
assertEquals(endpoints.authorizationEndpoint("fake-tenant-id"),
35+
azure.getProviderDetails().getAuthorizationUri());
3536
assertEquals(endpoints.tokenEndpoint("fake-tenant-id"), azure.getProviderDetails().getTokenUri());
3637
assertEquals(endpoints.jwkSetEndpoint("fake-tenant-id"), azure.getProviderDetails().getJwkSetUri());
3738
assertEquals("{baseUrl}/login/oauth2/code/{registrationId}", azure.getRedirectUriTemplate());
38-
assertDefaultScopes(azure, "openid", "profile");
39+
assertDefaultScopes(
40+
azure,
41+
"openid",
42+
"profile",
43+
"https://graph.microsoft.com/Directory.AccessAsUser.All",
44+
"https://graph.microsoft.com/User.Read");
3945
}
4046
}
4147

@@ -50,7 +56,14 @@ public void clientRequiresPermissionRegistered() {
5056
ClientRegistration graph = repo.findByRegistrationId("graph");
5157

5258
assertNotNull(azure);
53-
assertDefaultScopes(azure, "openid", "profile", "offline_access", "Calendars.Read");
59+
assertDefaultScopes(
60+
azure,
61+
"openid",
62+
"profile",
63+
"https://graph.microsoft.com/Directory.AccessAsUser.All",
64+
"https://graph.microsoft.com/User.Read",
65+
"offline_access",
66+
"Calendars.Read");
5467

5568
assertNotNull(graph);
5669
assertDefaultScopes(graph, "Calendars.Read");
@@ -73,6 +86,8 @@ public void clientRequiresMultiPermissions() {
7386
azure,
7487
"openid",
7588
"profile",
89+
"https://graph.microsoft.com/Directory.AccessAsUser.All",
90+
"https://graph.microsoft.com/User.Read",
7691
"offline_access",
7792
"Calendars.Read",
7893
"https://management.core.windows.net/user_impersonation");
@@ -92,7 +107,14 @@ public void clientRequiresPermissionInDefaultClient() {
92107
ClientRegistration azure = repo.findByRegistrationId("azure");
93108

94109
assertNotNull(azure);
95-
assertDefaultScopes(azure, "openid", "profile", "offline_access", "Calendars.Read");
110+
assertDefaultScopes(
111+
azure,
112+
"openid",
113+
"profile",
114+
"https://graph.microsoft.com/Directory.AccessAsUser.All",
115+
"https://graph.microsoft.com/User.Read",
116+
"offline_access",
117+
"Calendars.Read");
96118
}
97119
}
98120

sdk/spring/azure-spring-boot/src/main/java/com/azure/spring/aad/implementation/AzureActiveDirectoryConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private AzureClientRegistration createDefaultClient() {
6565
}
6666

6767
private Set<String> allScopes() {
68-
Set<String> result = openidScopes();
68+
Set<String> result = accessTokenScopes();
6969
for (AuthorizationProperties authProperties : properties.getAuthorization().values()) {
7070
result.addAll(authProperties.getScopes());
7171
}

0 commit comments

Comments
 (0)