Skip to content

Commit e68bbf1

Browse files
authored
update readmes of aad starter and backend sample (Azure#17855)
1 parent c21791e commit e68bbf1

File tree

3 files changed

+15
-31
lines changed
  • sdk/spring
    • azure-spring-boot-samples
      • azure-spring-boot-sample-active-directory-backend-v2
      • azure-spring-boot-sample-active-directory-backend
    • azure-spring-boot-starter-active-directory

3 files changed

+15
-31
lines changed

sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@ azure.activedirectory.user-group.object-id-key=id
1515

1616
Follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app).
1717

18-
The sample retrieves user's group membership using Azure AD graph API which requires the registered app to have `Directory.AccessAsUser.All` "Access the directory as the signed-in user" under `Delegated Permissions`. You need AAD admin privilege to be able to grant the permission in API ACCESS -> Required permission. You can follow the below steps:
19-
20-
* In the list of pages for the app, select **API permissions**
21-
- Click the **Add a permission** button and then,
22-
- Ensure that the **Microsoft APIs** tab is selected
23-
- In the *Commonly used Microsoft APIs* section, click on **Microsoft Graph**
24-
- In the **Delegated permissions** section, ensure that the right permissions are checked: **Directory.AccessAsUser.All**
25-
- Select the **Add permissions** button
2618
### Configure groups for sign in user
2719

2820
In order to try the authorization action with this sample with minimum effort, [configure the user and groups in Azure Active Directory](https://docs.microsoft.com/azure/active-directory/active-directory-groups-create-azure-portal), configure the user with `group1`.
@@ -34,8 +26,8 @@ In order to try the authorization action with this sample with minimum effort, [
3426

3527
```properties
3628
azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx
37-
azure.activedirectory.client-id=xxxxxx-your-client-id-xxxxxx
38-
azure.activedirectory.client-secret=xxxxxx-your-client-secret-xxxxxx
29+
spring.security.oauth2.client.registration.azure.client-id=xxxxxx-your-client-id-xxxxxx
30+
spring.security.oauth2.client.registration.azure.client-secret=xxxxxx-your-client-secret-xxxxxx
3931
# It's suggested the logged in user should at least belong to one of the below groups
4032
# If not, the logged in user will not be able to access any authorization controller rest APIs
4133
azure.activedirectory.user-group.allowed-groups=group1, group2

sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ This sample illustrates how to use `azure-spring-boot-starter-active-directory`
99

1010
Follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/active-directory-protocols-oauth-code#register-your-application-with-your-ad-tenant).
1111

12-
The sample retrieves user's group membership using Azure AD graph API which requires the registered app to have `Directory.AccessAsUser.All` "Access the directory as the signed-in user" under `Delegated Permissions`. You need AAD admin privilege to be able to grant the permission in API ACCESS -> Required permission.
13-
You can follow the below steps:
14-
15-
* In the list of pages for the app, select **API permissions**
16-
- Click the **Add a permission** button
17-
- Ensure that the **Microsoft APIs** tab is selected
18-
- In the *Supported legacy APIs* section, click on **Azure Active Directory Graph**
19-
- In the **Delegated permissions** section, ensure that the right permissions are checked: **Directory.AccessAsUser.All**
20-
- Select the **Add permissions** button
21-
2212
### Platform configurations
2313

2414
![Platform configurations](docs/image-platform-configurations.png "Platform configurations")
@@ -35,8 +25,8 @@ In order to try the authorization action with this sample with minimum effort, [
3525
### Configure application.properties
3626
```properties
3727
azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx
38-
azure.activedirectory.client-id=xxxxxx-your-client-id-xxxxxx
39-
azure.activedirectory.client-secret=xxxxxx-your-client-secret-xxxxxx
28+
spring.security.oauth2.client.registration.azure.client-id=xxxxxx-your-client-id-xxxxxx
29+
spring.security.oauth2.client.registration.azure.client-secret=xxxxxx-your-client-secret-xxxxxx
4030
# It's suggested the logged in user should at least belong to one of the below groups
4131
# If not, the logged in user will not be able to access any authorization controller rest APIs
4232
azure.activedirectory.user-group.allowed-groups=group1, group2

sdk/spring/azure-spring-boot-starter-active-directory/README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ Please refer to [azure-spring-boot-sample-active-directory-backend](https://gith
6767
#### Configure application.properties:
6868
```properties
6969
azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx
70-
azure.activedirectory.client-id=xxxxxx-your-client-id-xxxxxx
71-
azure.activedirectory.client-secret=xxxxxx-your-client-secret-xxxxxx
70+
spring.security.oauth2.client.registration.azure.client-id=xxxxxx-your-client-id-xxxxxx
71+
spring.security.oauth2.client.registration.azure.client-secret=xxxxxx-your-client-secret-xxxxxx
7272
azure.activedirectory.user-group.allowed-groups=group1, group2
7373
```
7474

@@ -184,16 +184,18 @@ The roles you want to use within your application have to be [set up in the mani
184184
application registration](https://docs.microsoft.com/azure/active-directory/develop/howto-add-app-roles-in-azure-ad-apps).
185185

186186
### Using The Microsoft Graph API
187-
By default, azure-spring-boot is set up to utilize the Azure AD Graph. If you would prefer, it can be set up to utilize the Microsoft Graph instead. In order to do this, you will need to update the app registration in Azure to grant the application permissions to the Microsoft Graph API and add some properties to the application.properties file.
187+
By default, azure-spring-boot is set up to utilize the Microsoft Graph. If you would prefer, it can be set up to utilize the Azure AD Graph instead. In order to do this, you will need to update the app registration in Azure to grant the application permissions to the Azure AD Graph API and add some properties to the application.properties file.
188188

189-
* **Grant permissions to the application**: After application registration succeeded, go to API permissions - Add a permission, select `Microsoft Graph`, select Delegated permissions, tick `Directory.AccessAsUser.All - Access the directory as the signed-in user` and `Use.Read - Sign in and read user profile`. Click `Add Permissions` (Note: you will need administrator privilege to grant permission). Furthermore, you can remove the API permissions to the Azure Active Directory Graph, as these will not be needed.
189+
* **Grant permissions to the application**: After application registration succeeded, go to API permissions - Add a permission, select `Azure Active Directory Graph`, select Delegated permissions, tick `Directory.AccessAsUser.All - Access the directory as the signed-in user` and `Use.Read - Sign in and read user profile`. Click `Add Permissions` (Note: you will need administrator privilege to grant permission). Furthermore, you can remove the API permissions to the Microsoft Graph, as these will not be needed.
190190

191191
* **Configure your `application properties`**:
192192
```properties
193-
azure.activedirectory.environment=global-v2-graph
194-
azure.activedirectory.user-group.key=@odata.type
195-
azure.activedirectory.user-group.value=#microsoft.graph.group
196-
azure.activedirectory.user-group.object-id-key=id
193+
spring.security.oauth2.client.provider.azure.authorization-uri=https://login.microsoftonline.com/common/oauth2/authorize
194+
spring.security.oauth2.client.provider.azure.token-uri=https://login.microsoftonline.com/common/oauth2/token
195+
spring.security.oauth2.client.provider.azure.user-info-uri=https://login.microsoftonline.com/common/openid/userinfo
196+
spring.security.oauth2.client.provider.azure.jwk-set-uri=https://login.microsoftonline.com/common/discovery/keys
197+
#
198+
spring.security.oauth2.client.registration.azure.scope=openid, https://graph.windows.net/user.read, {your-customized-scope}
197199
```
198200

199201
If you're using [Azure China](https://docs.microsoft.com/azure/china/china-welcome), please set the environment property in the `application.properties` file to:
@@ -208,7 +210,7 @@ Please refer to [azure-spring-boot-sample-active-directory-backend-v2](https://g
208210

209211
By default, `azure-spring-boot-starter-active-directory` configures scopes of `openid`, `profile` and `https://graph.microsoft.com/user.read` to implement OpenID Connect protocol and access of Microsoft Graph API. For customization of scope, developers need to configure in the `application.properties`:
210212
```yaml
211-
azure.activedirectory.scope = openid, profile, https://graph.microsoft.com/user.read, {your-customized-scope}
213+
spring.security.oauth2.client.registration.azure.scope = openid, profile, https://graph.microsoft.com/user.read, {your-customized-scope}
212214
```
213215
Note, if you don't configure the 3 mentioned permissions, this starter will add them automatically.
214216

0 commit comments

Comments
 (0)