+
+
+ +

This sample demonstrates how to take advantage of MSAL JS for adding Azure AD authentication to your + AngularJS apps.

+
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + + diff --git a/sdk/spring/azure-spring-boot-samples/pom.xml b/sdk/spring/azure-spring-boot-samples/pom.xml new file mode 100644 index 000000000000..8ce9e142a3f7 --- /dev/null +++ b/sdk/spring/azure-spring-boot-samples/pom.xml @@ -0,0 +1,151 @@ + + + 4.0.0 + + + org.springframework.boot + spring-boot-starter-parent + 2.2.0.RELEASE + + + + com.microsoft.azure + azure-spring-boot-samples + pom + 1.0.0 + + Azure Spring Boot Samples + Samples for Azure Spring Boot + https://github.com/Azure/azure-sdk-for-java + + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + + + microsoft + Microsoft Corporation + + + + + scm:git:git://github.com/azure/azure-sdk-for-java + scm:git:git://github.com/azure/azure-sdk-for-java + https://github.com/azure/azure-sdk-for-java + + + + GitHub + https://github.com/azure/azure-sdk-for-java/issues + + + + 1.8 + UTF-8 + UTF-8 + + + + + + com.microsoft.azure + azure-spring-boot-bom + 2.2.5-beta.1 + pom + import + + + commons-io + commons-io + 2.3 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + azure-spring-boot-sample-active-directory + + azure-spring-boot-sample-active-directory-backend + azure-spring-boot-sample-active-directory-backend-v2 + azure-spring-boot-sample-active-directory-stateless + + + + + + + + + + + diff --git a/sdk/spring/pom.xml b/sdk/spring/pom.xml index 84980d7d61a7..32eeb80d892c 100644 --- a/sdk/spring/pom.xml +++ b/sdk/spring/pom.xml @@ -10,8 +10,12 @@ 1.0.0 azure-spring-boot + azure-spring-boot-bom azure-spring-boot-starter azure-spring-boot-starter-active-directory + + azure-spring-boot-samples + From f504d58e14401d510e78ade5c2ff7c8e9de009f0 Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Wed, 22 Apr 2020 18:01:09 +0800 Subject: [PATCH 02/11] remove all en-us part of URL, fix codestyle, rename readmes --- sdk/spring/azure-spring-boot-bom/pom.xml | 21 ++++---- .../{README-a.md => README.md} | 6 +-- ...ureADOAuth2V2BackendSampleApplication.java | 1 + .../azure/aad/controller/HomeController.java | 1 + .../AADOAuth2LoginSecurityConfig.java | 1 + .../src/main/resources/application.properties | 12 +++++ .../{README-a.md => README.md} | 6 +-- ...AzureADOAuth2BackendSampleApplication.java | 1 + .../azure/aad/controller/HomeController.java | 1 + .../AADOAuth2LoginSecurityConfig.java | 1 + .../src/main/resources/application.properties | 7 +++ .../{README-a.md => README.md} | 4 +- ...reADStatelessBackendSampleApplication.java | 1 + .../azure/aad/controller/MainController.java | 1 + .../aad/security/AADWebSecurityConfig.java | 1 + .../src/main/resources/application.properties | 6 +++ .../{README-a.md => README.md} | 12 ++--- ...ingBootAutoconfigureSampleApplication.java | 1 + ...ontroller.java => TodoListController.java} | 20 +++++-- .../microsoft/azure/aad/model/TodoItem.java | 1 + .../azure/aad/security/WebSecurityConfig.java | 1 + .../src/main/resources/application.properties | 7 +++ sdk/spring/azure-spring-boot-samples/pom.xml | 54 ------------------- .../README.md | 8 +-- sdk/spring/ci.yml | 3 ++ 25 files changed, 91 insertions(+), 87 deletions(-) rename sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/{README-a.md => README.md} (89%) create mode 100644 sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/resources/application.properties rename sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/{README-a.md => README.md} (88%) create mode 100644 sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/resources/application.properties rename sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/{README-a.md => README.md} (91%) create mode 100644 sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/resources/application.properties rename sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/{README-a.md => README.md} (91%) rename sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/controller/{TodolistController.java => TodoListController.java} (87%) create mode 100644 sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/resources/application.properties diff --git a/sdk/spring/azure-spring-boot-bom/pom.xml b/sdk/spring/azure-spring-boot-bom/pom.xml index 39e3a9b6ffd2..73870aff8dec 100644 --- a/sdk/spring/azure-spring-boot-bom/pom.xml +++ b/sdk/spring/azure-spring-boot-bom/pom.xml @@ -67,51 +67,52 @@ azure-active-directory-spring-boot-starter 2.2.5-beta.1 + + 2.2.5-beta.1 <!– {x-version-update;com.microsoft.azure:azure-spring-boot-starter-active-directory-b2c;current} –> com.microsoft.azure azure-spring-boot-starter-cosmosdb - 2.2.5-beta.1 + 2.2.5-beta.1 <!– {x-version-update;com.microsoft.azure:azure-spring-boot-starter-cosmosdb;current} –> com.microsoft.azure azure-spring-boot-starter-data-gremlin - 2.2.5-beta.1 + 2.2.5-beta.1 <!– {x-version-update;com.microsoft.azure:azure-spring-boot-starter-data-gremlin;current} –> com.microsoft.azure azure-keyvault-secrets-spring-boot-starter - 2.2.5-beta.1 + 2.2.5-beta.1 <!– {x-version-update;com.microsoft.azure:azure-keyvault-secrets-spring-boot-starter;current} –> com.microsoft.azure azure-spring-boot-starter-mediaservices - 2.2.5-beta.1 + 2.2.5-beta.1 <!– {x-version-update;com.microsoft.azure:azure-spring-boot-starter-mediaservices;current} –> com.microsoft.azure azure-spring-boot-starter-metrics - 2.2.5-beta.1 + 2.2.5-beta.1 <!– {x-version-update;com.microsoft.azure:azure-spring-boot-starter-metrics;current} –> com.microsoft.azure azure-spring-boot-starter-servicebus - 2.2.5-beta.1 + 2.2.5-beta.1 <!– {x-version-update;com.microsoft.azure:azure-spring-boot-starter-servicebus;current} –> com.microsoft.azure azure-spring-boot-starter-servicebus-jms - 2.2.5-beta.1 + 2.2.5-beta.1 <!– {x-version-update;com.microsoft.azure:azure-spring-boot-starter-servicebus-jms;current} –> com.microsoft.azure azure-spring-boot-starter-storage - 2.2.5-beta.1 - + 2.2.5-beta.1 <!– {x-version-update;com.microsoft.azure:azure-spring-boot-starter-storage;current} –> + --> diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README-a.md b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md similarity index 89% rename from sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README-a.md rename to sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md index 1906a0741923..edba8e3a3428 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README-a.md +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md @@ -2,11 +2,11 @@ #### Register your application with your Azure Active Directory Tenant -Follow the guide [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app). +Follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app). #### Configure groups for sign in user -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/en-us/azure/active-directory/active-directory-groups-create-azure-portal), configure the user with `group1`. +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`. #### Configure application.properties @@ -68,7 +68,7 @@ azure.activedirectory.active-directory-groups=group1, group2 ### FAQ #### If registered application is not multi-tenanted, how to run this sample? -In this auto-configuration, by [default](https://github.com/Microsoft/azure-spring-boot/blob/master/azure-spring-boot/src/main/resources/aad-oauth2-common.properties#L1-L4) `/common` is used for the tenant value. According to [Active Directory Sign In Request format](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-protocols-oidc#send-the-sign-in-request), if your application is not multi-tenanted, you have to configure a tenant specific authorization endpoints. +In this auto-configuration, by [default](https://github.com/Microsoft/azure-spring-boot/blob/master/azure-spring-boot/src/main/resources/aad-oauth2-common.properties#L1-L4) `/common` is used for the tenant value. According to [Active Directory Sign In Request format](https://docs.microsoft.com/azure/active-directory/develop/v2-protocols-oidc#send-the-sign-in-request), if your application is not multi-tenanted, you have to configure a tenant specific authorization endpoints. Configure endpoints with specific tenant-id by replacing `common` in your application.properties file: ```properties diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/AzureADOAuth2V2BackendSampleApplication.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/AzureADOAuth2V2BackendSampleApplication.java index 39ebd4859b95..9f847d6fcab1 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/AzureADOAuth2V2BackendSampleApplication.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/AzureADOAuth2V2BackendSampleApplication.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad; import org.springframework.boot.SpringApplication; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/controller/HomeController.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/controller/HomeController.java index c17e38136d69..11c18e51da93 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/controller/HomeController.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/controller/HomeController.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad.controller; import org.springframework.beans.factory.annotation.Autowired; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/security/AADOAuth2LoginSecurityConfig.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/security/AADOAuth2LoginSecurityConfig.java index d4ec08372f3e..c17d43a37ab4 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/security/AADOAuth2LoginSecurityConfig.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/java/microsoft/azure/aad/security/AADOAuth2LoginSecurityConfig.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad.security; import com.microsoft.azure.spring.autoconfigure.aad.AADAuthenticationFailureHandler; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/resources/application.properties b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/resources/application.properties new file mode 100644 index 000000000000..d595d18bba8f --- /dev/null +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/src/main/resources/application.properties @@ -0,0 +1,12 @@ +spring.security.oauth2.client.registration.azure.client-id=xxxxxx-your-client-id-xxxxxx +spring.security.oauth2.client.registration.azure.client-secret=xxxxxx-your-client-secret-xxxxxx + +azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx + +# It's suggested the logged in user should at least belong to one of the below groups +# If not, the logged in user will not be able to access any authorization controller rest APIs +azure.activedirectory.active-directory-groups=group1, group2 +azure.activedirectory.environment=global-v2-graph +azure.activedirectory.user-group.key=@odata.type +azure.activedirectory.user-group.value=#microsoft.graph.group +azure.activedirectory.user-group.object-id-key=id diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README-a.md b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md similarity index 88% rename from sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README-a.md rename to sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md index cd82392e35bf..5c0715adeaa5 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README-a.md +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md @@ -2,11 +2,11 @@ #### Register your application with your Azure Active Directory Tenant -Follow the guide [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-oauth-code#register-your-application-with-your-ad-tenant). +Follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/active-directory-protocols-oauth-code#register-your-application-with-your-ad-tenant). #### Configure groups for sign in user -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/en-us/azure/active-directory/active-directory-groups-create-azure-portal), configure the user with `group1`. +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`. #### Configure application.properties @@ -68,7 +68,7 @@ azure.activedirectory.active-directory-groups=group1, group2 ### FAQ #### If registered application is not multi-tenanted, how to run this sample? -In this auto-configuration, by [default](https://github.com/Microsoft/azure-spring-boot/blob/master/azure-spring-boot/src/main/resources/aad-oauth2-common.properties#L1-L4) `/common` is used for the tenant value. According to [Active Directory Sign In Request format](https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-protocols-openid-connect-code#send-the-sign-in-request), if your application is not multi-tenanted, you have to configure a tenant specific authorization endpoints. +In this auto-configuration, by [default](https://github.com/Microsoft/azure-spring-boot/blob/master/azure-spring-boot/src/main/resources/aad-oauth2-common.properties#L1-L4) `/common` is used for the tenant value. According to [Active Directory Sign In Request format](https://docs.microsoft.com/azure/active-directory/develop/active-directory-protocols-openid-connect-code#send-the-sign-in-request), if your application is not multi-tenanted, you have to configure a tenant specific authorization endpoints. Configure endpoints with specific tenant-id by replacing `common` in your application.properties file: ```properties diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/AzureADOAuth2BackendSampleApplication.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/AzureADOAuth2BackendSampleApplication.java index f0b25bc3db6a..56af58d87c45 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/AzureADOAuth2BackendSampleApplication.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/AzureADOAuth2BackendSampleApplication.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad; import org.springframework.boot.SpringApplication; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/controller/HomeController.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/controller/HomeController.java index c17e38136d69..11c18e51da93 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/controller/HomeController.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/controller/HomeController.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad.controller; import org.springframework.beans.factory.annotation.Autowired; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/security/AADOAuth2LoginSecurityConfig.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/security/AADOAuth2LoginSecurityConfig.java index e8510fd79fda..7588826cfd3f 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/security/AADOAuth2LoginSecurityConfig.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/java/microsoft/azure/aad/security/AADOAuth2LoginSecurityConfig.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad.security; import org.springframework.beans.factory.annotation.Autowired; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/resources/application.properties b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/resources/application.properties new file mode 100644 index 000000000000..00957319d578 --- /dev/null +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/src/main/resources/application.properties @@ -0,0 +1,7 @@ +spring.security.oauth2.client.registration.azure.client-id=xxxxxx-your-client-id-xxxxxx +spring.security.oauth2.client.registration.azure.client-secret=xxxxxx-your-client-secret-xxxxxx + +azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx +# It's suggested the logged in user should at least belong to one of the below groups +# If not, the logged in user will not be able to access any authorization controller rest APIs +azure.activedirectory.active-directory-groups=group1, group2 diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README-a.md b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README.md similarity index 91% rename from sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README-a.md rename to sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README.md index 2bb236fa0335..727b2a9bbd31 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README-a.md +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README.md @@ -15,13 +15,13 @@ to get it working with your Azure AD tenant on both sides. #### Register your application with your Azure Active Directory Tenant -Follow the guide [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-protocols-openid-connect-code#register-your-application-with-your-ad-tenant). +Follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/v1-protocols-openid-connect-code#register-your-application-with-your-ad-tenant). #### Configure appRoles In order to use only the `id_token` for our authentication and authorization purposes we will use the `appRoles` feature which AAD provides. Follow the guide -[Add app roles in your application](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-add-app-roles-in-azure-ad-apps) +[Add app roles in your application](https://docs.microsoft.com/azure/active-directory/develop/howto-add-app-roles-in-azure-ad-apps) For the test SPA provided with this example you should create the following roles in your manifest: diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/AzureADStatelessBackendSampleApplication.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/AzureADStatelessBackendSampleApplication.java index 935ab622dd32..5a0bf90fb92c 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/AzureADStatelessBackendSampleApplication.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/AzureADStatelessBackendSampleApplication.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad; import org.springframework.boot.SpringApplication; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/controller/MainController.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/controller/MainController.java index 9c939cd61c8b..8b9e45f4eec2 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/controller/MainController.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/controller/MainController.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad.controller; import org.springframework.security.access.prepost.PreAuthorize; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/security/AADWebSecurityConfig.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/security/AADWebSecurityConfig.java index 155e255978e6..5473dfdbfd64 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/security/AADWebSecurityConfig.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/java/microsoft/azure/aad/security/AADWebSecurityConfig.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad.security; import com.microsoft.azure.spring.autoconfigure.aad.AADAppRoleStatelessAuthenticationFilter; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/resources/application.properties b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/resources/application.properties new file mode 100644 index 000000000000..43b7229d876d --- /dev/null +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/src/main/resources/application.properties @@ -0,0 +1,6 @@ +# By default, azure.activedirectory.environment property has value `global`, +# supported value is global, cn. Please refer to the README for details. +# azure.activedirectory.environment=global +azure.activedirectory.session-stateless=true +azure.activedirectory.client-id=xxxxxxxx-your-client-id-xxxxxxxxxxxx + diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README-a.md b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README.md similarity index 91% rename from sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README-a.md rename to sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README.md index 805803bb80e4..764e848df7bf 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README-a.md +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README.md @@ -26,14 +26,14 @@ To run this sample, you'll need: - A Windows machine (necessary if you want to run the app on Windows) - An OS X machine (necessary if you want to run the app on Mac) - A Linux machine (necessary if you want to run the app on Linux) -- An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, see [How to get an Azure AD tenant](https://azure.microsoft.com/en-us/documentation/articles/active-directory-howto-tenant/) +- An Azure Active Directory (Azure AD) tenant. For more information on how to get an Azure AD tenant, see [How to get an Azure AD tenant](https://azure.microsoft.com/documentation/articles/active-directory-howto-tenant/) - A user account in your Azure AD tenant. This sample will not work with a Personal Microsoft account (formerly Windows Live account). Therefore, if you signed in to the [Azure portal](https://portal.azure.com) with a Microsoft account and have never created a user account in your directory before, you need to do that now. -- A [client secret](https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-create-service-principal-portal#create-a-new-application-secret) for the registered application. -- Configure groups in your Azure AD tenant with your users in that groups, see [how to create groups](https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-groups-create-azure-portal) +- A [client secret](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal#create-a-new-application-secret) for the registered application. +- Configure groups in your Azure AD tenant with your users in that groups, see [how to create groups](https://docs.microsoft.com/azure/active-directory/fundamentals/active-directory-groups-create-azure-portal) - The sample retrieves user's group membership using Azure AD graph API which requires the registered app to have `Direcory.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. #### Note -- If you are not the admin, you need consent from your admin for the the `Directory.AccessAsUser.All` permission. For details see [Directory Permissions](https://docs.microsoft.com/en-us/graph/permissions-reference#directory-permissions) +- If you are not the admin, you need consent from your admin for the the `Directory.AccessAsUser.All` permission. For details see [Directory Permissions](https://docs.microsoft.com/graph/permissions-reference#directory-permissions) @@ -48,7 +48,7 @@ or download and extract the repository .zip file, and navigate to `azure-active- ### Step 2: Register the sample with your Azure Active Directory tenant -To register it follow the steps below or follow the guide [here](https://docs.microsoft.com/en-us/azure/active-directory/develop/v1-protocols-oauth-code#register-your-application-with-your-ad-tenant). +To register it follow the steps below or follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/v1-protocols-oauth-code#register-your-application-with-your-ad-tenant). #### Choose the Azure AD tenant where you want to create your applications @@ -95,7 +95,7 @@ In the steps below, "ClientID" is the same as "Application ID" or "AppId". Open application.properties in your project to configure #### Configure Application Properties -1. If your azure account follows format xxx@xxx.partner.onmschina.cn, configure property `azure.activedirectory.environment=cn` to use [Azure China](https://docs.microsoft.com/en-us/azure/china/china-welcome), the default value is `global`. +1. If your azure account follows format xxx@xxx.partner.onmschina.cn, configure property `azure.activedirectory.environment=cn` to use [Azure China](https://docs.microsoft.com/azure/china/china-welcome), the default value is `global`. 1. Put Application ID and client-secret in `client-id` and `client-secret` respectively e.g. `azure.activedirectory.client-id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` `azure.activedirectory.client-secret=ABCDEFGHIJKLMNOOPQRSTUVWXYZABCDEFGHIJKLMNOPQ` diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/AzureAdIntegrationSpringBootAutoconfigureSampleApplication.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/AzureAdIntegrationSpringBootAutoconfigureSampleApplication.java index 5987552dc53b..0921e04ce9fe 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/AzureAdIntegrationSpringBootAutoconfigureSampleApplication.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/AzureAdIntegrationSpringBootAutoconfigureSampleApplication.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad; import org.springframework.boot.SpringApplication; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/controller/TodolistController.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/controller/TodoListController.java similarity index 87% rename from sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/controller/TodolistController.java rename to sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/controller/TodoListController.java index b69a4741cc47..910a01e58ccf 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/controller/TodolistController.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/controller/TodoListController.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad.controller; import com.microsoft.azure.spring.autoconfigure.aad.UserGroup; @@ -10,16 +11,24 @@ import org.springframework.http.ResponseEntity; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; import java.util.stream.Collectors; @RestController -public class TodolistController { +public class TodoListController { private final List todoList = new ArrayList<>(); - public TodolistController() { + public TodoListController() { todoList.add(0, new TodoItem(2398, "anything", "whoever")); } @@ -38,7 +47,8 @@ public Map home() { method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE}) public ResponseEntity getTodoItem(@PathVariable("index") int index) { if (index > todoList.size() - 1) { - return new ResponseEntity<>(new TodoItem(-1, "index out of range", null), HttpStatus.NOT_FOUND); + return new ResponseEntity<>(new TodoItem(-1, "index out of range", null), + HttpStatus.NOT_FOUND); } return new ResponseEntity<>(todoList.get(index), HttpStatus.OK); } diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/model/TodoItem.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/model/TodoItem.java index bb318ed1042c..e663d597fae6 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/model/TodoItem.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/model/TodoItem.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad.model; import com.fasterxml.jackson.annotation.*; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/security/WebSecurityConfig.java b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/security/WebSecurityConfig.java index 93c4dc9342a2..be04934813b4 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/security/WebSecurityConfig.java +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/java/microsoft/azure/aad/security/WebSecurityConfig.java @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. + package microsoft.azure.aad.security; import com.microsoft.azure.spring.autoconfigure.aad.AADAuthenticationFilter; diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/resources/application.properties b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/resources/application.properties new file mode 100644 index 000000000000..66000b84384a --- /dev/null +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/src/main/resources/application.properties @@ -0,0 +1,7 @@ +# By default, azure.activedirectory.environment property has value `global`, +# supported value is global, cn. Please refer to the README for details. +# azure.activedirectory.environment=global +azure.activedirectory.client-id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +azure.activedirectory.client-secret=ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQR +azure.activedirectory.ActiveDirectoryGroups=group1,group2 + diff --git a/sdk/spring/azure-spring-boot-samples/pom.xml b/sdk/spring/azure-spring-boot-samples/pom.xml index 8ce9e142a3f7..937f0d61b2d0 100644 --- a/sdk/spring/azure-spring-boot-samples/pom.xml +++ b/sdk/spring/azure-spring-boot-samples/pom.xml @@ -71,60 +71,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - org.springframework.boot spring-boot-maven-plugin diff --git a/sdk/spring/azure-spring-boot-starter-active-directory/README.md b/sdk/spring/azure-spring-boot-starter-active-directory/README.md index 407bf79f59f0..ea532d3a3adf 100644 --- a/sdk/spring/azure-spring-boot-starter-active-directory/README.md +++ b/sdk/spring/azure-spring-boot-starter-active-directory/README.md @@ -42,7 +42,7 @@ Refer to different samples for different authentication ways. ##### Authenticate in backend -Please refer to [azure-spring-boot-sample-active-directory-backend](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README-a.md) for authenticate in backend. +Please refer to [azure-spring-boot-sample-active-directory-backend](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md) for authenticate in backend. Configure application.properties: ```properties @@ -76,7 +76,7 @@ public class AADOAuth2LoginConfigSample extends WebSecurityConfigurerAdapter { ##### Authenticate in frontend -Please refer to [azure-active-directory-spring-boot-sample](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README-a.md) for how to integrate Spring Security and Azure AD for authentication and authorization in a Single Page Application (SPA) scenario. +Please refer to [azure-active-directory-spring-boot-sample](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README.md) for how to integrate Spring Security and Azure AD for authentication and authorization in a Single Page Application (SPA) scenario. Configure application.properties: ```properties @@ -181,9 +181,9 @@ If you're using [Azure China](https://docs.microsoft.com/azure/china/china-welco azure.activedirectory.environment=cn-v2-graph ``` -Please refer to [azure-spring-boot-sample-active-directory-backend-v2](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/) to see a sample configured to use the Microsoft Graph API. +Please refer to [azure-spring-boot-sample-active-directory-backend-v2](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md) to see a sample configured to use the Microsoft Graph API. ### Using Microsoft identity platform endpoints -If you want to use v2 version endpoints to do authorization and authentication, please pay attention to the attributes of claims, because there are some attributes exits in v1 version id-token by default but not in v2 version id-token, if you have to get that attribute, please make sure to add it into your scope. +If you want to use v2 version endpoints to do authorization and authentication, please pay attention to the attributes of claims, because there are some attributes exists in v1 version id-token by default but not in v2 version id-token, if you have to get that attribute, please make sure to add it into your scope. There is the doc [Difference between v1 and v2](https://docs.microsoft.com/azure/active-directory/develop/azure-ad-endpoint-comparison), For example, the name attribute doesn't exist in v2 token, if you want it, you need add `profile` to your scope, like this: ```properties spring.security.oauth2.client.registration.azure.scope=openid, https://graph.microsoft.com/user.read, profile diff --git a/sdk/spring/ci.yml b/sdk/spring/ci.yml index 450120cde9ef..73ada314a11a 100644 --- a/sdk/spring/ci.yml +++ b/sdk/spring/ci.yml @@ -41,6 +41,9 @@ stages: - name: azure-spring-boot groupId: com.microsoft.azure safeName: azurespringboot + - name: azure-spring-boot-bom + groupId: com.microsoft.azure + safeName: azurespringbootbom - name: azure-spring-boot-starter groupId: com.microsoft.azure safeName: azurespringbootstarter From a05d0e422080647273c445c2fb8c7a0db68e5624 Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Thu, 30 Apr 2020 15:02:43 +0800 Subject: [PATCH 03/11] fix README.md files --- .../README.md | 49 ++++++++++++------- .../README.md | 46 +++++++++-------- .../README.md | 46 ++++++++--------- .../README.md | 45 ++++++++++------- .../README.md | 39 +++++++-------- 5 files changed, 125 insertions(+), 100 deletions(-) diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md index edba8e3a3428..a68e2fd7d639 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md @@ -1,15 +1,28 @@ -### How to configure +# OAuth 2.0 Sample for Azure AD Spring Boot Starter client library for Java -#### Register your application with your Azure Active Directory Tenant +## Key concepts +This sample illustrates how to use `azure-active-directory-spring-boot-starter` package to work with OAuth 2.0 and OpenID Connect protocols on Auzre. This sample will use Microsoft Graph API to retrieve user info. This is the key difference from [azure-spring-boot-sample-active-directory-backend](../azure-spring-boot-sample-active-directory-backend/README.md). It's reflected by these configurations in `appication.properties`: +```properties +azure.activedirectory.environment=global-v2-graph +azure.activedirectory.user-group.key=@odata.type +azure.activedirectory.user-group.value=#microsoft.graph.group +azure.activedirectory.user-group.object-id-key=id +``` + +## Getting started + +### Register your application with your Azure Active Directory Tenant Follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/quickstart-register-app). -#### Configure groups for sign in user +### Configure groups for sign in user 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`. -#### Configure application.properties +## Examples + +### Configure application.properties ```properties spring.security.oauth2.client.registration.azure.client-id=xxxxxx-your-client-id-xxxxxx @@ -21,17 +34,15 @@ azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx azure.activedirectory.active-directory-groups=group1, group2 ``` -### How to run - - - Use Maven +### Run with Maven - ``` - # Under azure-spring-boot project root directory - mvn clean install -DskipTests - cd azure-spring-boot-samples - cd azure-active-directory-spring-boot-backend-sample - mvn spring-boot:run - ``` +```shell +# Under azure-spring-boot project root directory +mvn clean install -DskipTests +cd azure-spring-boot-samples +cd azure-spring-boot-sample-active-directory-backend-v2 +mvn spring-boot:run +``` ### Check the authentication and authorization @@ -41,7 +52,7 @@ azure.activedirectory.active-directory-groups=group1, group2 4. Access `group2 Message` link, should fail with forbidden error message -### Want to take full control over every configuration property +### * Take full control over every configuration property If you want to adjust the configuration properties according to certain requirements, try below application.properties and change accordingly. @@ -65,9 +76,9 @@ azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx azure.activedirectory.active-directory-groups=group1, group2 ``` -### FAQ +## Troubleshooting -#### If registered application is not multi-tenanted, how to run this sample? +### If registered application is not multi-tenanted, how to run this sample? In this auto-configuration, by [default](https://github.com/Microsoft/azure-spring-boot/blob/master/azure-spring-boot/src/main/resources/aad-oauth2-common.properties#L1-L4) `/common` is used for the tenant value. According to [Active Directory Sign In Request format](https://docs.microsoft.com/azure/active-directory/develop/v2-protocols-oidc#send-the-sign-in-request), if your application is not multi-tenanted, you have to configure a tenant specific authorization endpoints. Configure endpoints with specific tenant-id by replacing `common` in your application.properties file: @@ -77,6 +88,6 @@ spring.security.oauth2.client.provider.azure-oauth-provider.token-uri=https://lo spring.security.oauth2.client.provider.azure-oauth-provider.user-info-uri=https://login.microsoftonline.com/{your-tenant-id}/openid/userinfo spring.security.oauth2.client.provider.azure-oauth-provider.jwk-set-uri=https://login.microsoftonline.com/{your-tenant-id}/discovery/keys ``` - -#### Meet with `AADSTS240002: Input id_token cannot be used as 'urn:ietf:params:oauth:grant-type:jwt-bearer' grant` error. +--- +### Meet with `AADSTS240002: Input id_token cannot be used as 'urn:ietf:params:oauth:grant-type:jwt-bearer' grant` error. In Azure portal, app registration manifest page, configure `oauth2AllowImplicitFlow` in your application manifest to `true`. See [this issue](https://github.com/MicrosoftDocs/azure-docs/issues/8121#issuecomment-387090099) for details on this workaround. diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md index 5c0715adeaa5..9f7cee1116c6 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md @@ -1,16 +1,21 @@ -### How to configure +# OAuth 2.0 Sample for Azure AD Spring Boot Starter client library for Java -#### Register your application with your Azure Active Directory Tenant +## Key concepts +This sample illustrates how to use `azure-active-directory-spring-boot-starter` package to work with OAuth 2.0 and OpenID Connect protocols on Auzre. This sample will use default Azure Active Directory Graph API to query user info. + +## Getting started + +### Register your application with your Azure Active Directory Tenant Follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/active-directory-protocols-oauth-code#register-your-application-with-your-ad-tenant). -#### Configure groups for sign in user +### Configure groups for sign in user 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`. +## Examples -#### Configure application.properties - +### Configure application.properties ```properties spring.security.oauth2.client.registration.azure.client-id=xxxxxx-your-client-id-xxxxxx spring.security.oauth2.client.registration.azure.client-secret=xxxxxx-your-client-secret-xxxxxx @@ -21,17 +26,14 @@ azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx azure.activedirectory.active-directory-groups=group1, group2 ``` -### How to run - - - Use Maven - - ``` - # Under azure-spring-boot project root directory - mvn clean install -DskipTests - cd azure-spring-boot-samples - cd azure-active-directory-spring-boot-backend-sample - mvn spring-boot:run - ``` +### Run with Maven +```shell +# Under azure-spring-boot project root directory +mvn clean install -DskipTests +cd azure-spring-boot-samples +cd azure-spring-boot-sample-active-directory-backend +mvn spring-boot:run +``` ### Check the authentication and authorization @@ -41,7 +43,7 @@ azure.activedirectory.active-directory-groups=group1, group2 4. Access `group2 Message` link, should fail with forbidden error message -### Want to take full control over every configuration property +### * Take full control over every configuration property If you want to adjust the configuration properties according to certain requirements, try below application.properties and change accordingly. @@ -65,9 +67,9 @@ azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx azure.activedirectory.active-directory-groups=group1, group2 ``` -### FAQ +## Troubleshooting -#### If registered application is not multi-tenanted, how to run this sample? +### If registered application is not multi-tenanted, how to run this sample? In this auto-configuration, by [default](https://github.com/Microsoft/azure-spring-boot/blob/master/azure-spring-boot/src/main/resources/aad-oauth2-common.properties#L1-L4) `/common` is used for the tenant value. According to [Active Directory Sign In Request format](https://docs.microsoft.com/azure/active-directory/develop/active-directory-protocols-openid-connect-code#send-the-sign-in-request), if your application is not multi-tenanted, you have to configure a tenant specific authorization endpoints. Configure endpoints with specific tenant-id by replacing `common` in your application.properties file: @@ -77,7 +79,9 @@ spring.security.oauth2.client.provider.azure.token-uri=https://login.microsofton spring.security.oauth2.client.provider.azure.user-info-uri=https://login.microsoftonline.com/{your-tenant-id}/openid/userinfo spring.security.oauth2.client.provider.azure.jwk-set-uri=https://login.microsoftonline.com/{your-tenant-id}/discovery/keys ``` - -#### Meet with `AADSTS240002: Input id_token cannot be used as 'urn:ietf:params:oauth:grant-type:jwt-bearer' grant` error. +---- +### Meet with `AADSTS240002: Input id_token cannot be used as 'urn:ietf:params:oauth:grant-type:jwt-bearer' grant` error. In Azure portal, app registration manifest page, configure `oauth2AllowImplicitFlow` in your application manifest to `true`. See [this issue](https://github.com/MicrosoftDocs/azure-docs/issues/8121#issuecomment-387090099) for details on this workaround. +## Next steps +## Contributing \ No newline at end of file diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README.md b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README.md index 727b2a9bbd31..7657cfa4e839 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README.md +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/README.md @@ -1,23 +1,22 @@ -## About this sample +# Stateless authentication filter sample for Azure AD Spring Boot Starter client library for Java + +## Key concepts -### Overview This demo project explains the usage of the stateless authentication filter `AADAppRoleStatelessAuthenticationFilter`. This project is composed of a vue.js frontend and a simple backend with three endpoints * `/public` (accessible by anyone) * `/authorized` (role "user" required) * `/admin/demo` (role "admin" required). -### Get started +## Getting started The sample is composed of two layers: vue.js client and Spring Boot RESTful Web Service. You need to make some changes to get it working with your Azure AD tenant on both sides. -### How to configure - -#### Register your application with your Azure Active Directory Tenant +### Register your application with your Azure Active Directory Tenant Follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/v1-protocols-openid-connect-code#register-your-application-with-your-ad-tenant). -#### Configure appRoles +### Configure appRoles In order to use only the `id_token` for our authentication and authorization purposes we will use the `appRoles` feature which AAD provides. Follow the guide @@ -60,6 +59,9 @@ Furthermore enable the implicit flow in the manifest for the demo application "oauth2AllowImplicitFlow": "true", ``` +## Examples +### Configure the sample + #### Configure application.properties You have to activate the stateless app-role auth filter and configure the `client-id`of your application registration: @@ -73,23 +75,21 @@ azure.aad.app-role.client-id=xxxxxx-your-client-id-xxxxxx Add your `tenant-id` and `client-id` in `src/main/resources/static/index.html`: -``` - data: { - clientId: 'xxxxxxxx-your-client-id-xxxxxxxxxxxx', - tenantId: 'xxxxxxxx-your-tenant-id-xxxxxxxxxxxx', - tokenType: 'id_token', - token: null, - log: null - }, +```json +data: { + clientId: 'xxxxxxxx-your-client-id-xxxxxxxxxxxx', + tenantId: 'xxxxxxxx-your-tenant-id-xxxxxxxxxxxx', + tokenType: 'id_token', + token: null, + log: null +}, ``` -### How to run +### Run with Maven - - Use Maven - - ``` - mvn clean package spring-boot:run - ``` +```shell +mvn clean package spring-boot:run +``` ### Check the authentication and authorization @@ -104,4 +104,6 @@ Add your `tenant-id` and `client-id` in `src/main/resources/static/index.html`: #### Demo ![demoonstration video](docs/demo.webp "Demo Video") - +## Troubleshooting +## Next steps +## Contributing diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README.md b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README.md index 764e848df7bf..941a4ca6f492 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README.md +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README.md @@ -7,17 +7,14 @@ products: - azure-active-directory - java spring boot --- +# Authentication filter sample for Azure AD Spring Boot Starter client library for Java -## About this sample - -### Overview +## Key concepts This sample illustrates how to use `azure-active-directory-spring-boot-starter` package to plugin JWT token filter into Spring Security filter chain. The filter injects `UserPrincipal` object that is associated with the thread of the current user request. User's AAD membership info, along with token claimsset, JWS object etc. are accessible from the object which can be used for role based authorization. Methods like `isMemberOf` is also supported. -### Get started +## Getting started The sample is composed of two layers: Angular JS client and Spring Boot RESTful Web Service. You need to make some changes to get it working with your Azure AD tenant on both sides. -## How to run this sample - To run this sample, you'll need: - JDK 1.8 and above @@ -35,17 +32,18 @@ To run this sample, you'll need: #### Note - If you are not the admin, you need consent from your admin for the the `Directory.AccessAsUser.All` permission. For details see [Directory Permissions](https://docs.microsoft.com/graph/permissions-reference#directory-permissions) - +## Examples ### Step 1: Clone or download this repository From your command line: ```command line -git clone https://github.com/microsoft/azure-spring-boot.git +git clone https://github.com/Azure/azure-sdk-for-java.git ``` or download and extract the repository .zip file, and navigate to `azure-active-directory-spring-boot-sample` from the list of samples. +--- ### Step 2: Register the sample with your Azure Active Directory tenant To register it follow the steps below or follow the guide [here](https://docs.microsoft.com/azure/active-directory/develop/v1-protocols-oauth-code#register-your-application-with-your-ad-tenant). @@ -88,27 +86,34 @@ As a first step you'll need to: requested permissions for all account in the tenant. You need to be an Azure AD tenant admin to do this. +--- ### Step 3: Configure the sample to use your Azure AD tenant In the steps below, "ClientID" is the same as "Application ID" or "AppId". -Open application.properties in your project to configure +Open application.properties in your project to configure: -#### Configure Application Properties 1. If your azure account follows format xxx@xxx.partner.onmschina.cn, configure property `azure.activedirectory.environment=cn` to use [Azure China](https://docs.microsoft.com/azure/china/china-welcome), the default value is `global`. -1. Put Application ID and client-secret in `client-id` and `client-secret` respectively e.g. - `azure.activedirectory.client-id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` - `azure.activedirectory.client-secret=ABCDEFGHIJKLMNOOPQRSTUVWXYZABCDEFGHIJKLMNOPQ` -1. List all the AAD groups `ActiveDirectoryGroups` that you want to have a Spring Security role object mapping to it. The role objects can then be used to manage access to resources that is behind Spring Security. e.g. - `azure.activedirectory.active-directory-groups=group1,group2` (groups that you created in your Azure AD tenant) - + +2. Put Application ID and client-secret in `client-id` and `client-secret` respectively e.g. +```properties +azure.activedirectory.client-id=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx +azure.activedirectory.client-secret=ABCDEFGHIJKLMNOOPQRSTUVWXYZABCDEFGHIJKLMNOPQ +``` + +3. List all the AAD groups `ActiveDirectoryGroups` that you want to have a Spring Security role object mapping to it. The role objects can then be used to manage access to resources that is behind Spring Security. e.g. +```properties +# groups that you created in your Azure AD tenant +azure.activedirectory.active-directory-groups=group1,group2 +``` + --- ### Step 4: Change Role_group1 to your group 1. You can use `@PreAuthorize` annotation or `UserPrincipal` to manage access to web API based on user's group membership. You will need to change `ROLE_group1` to groups you want to allow to access the API in `TodoListController.java` or you will get "Access is denied". - +--- ### Step 5: Angular JS In `app.js`, make following changes. The client leverages Azure AD library for JS to handle AAD authentication in single page application. The following snippet of code configures msal provider for your registered app. ClientID is your application ID and \ is a identifier within the directory itself (e.g. a domain associated to the tenant, such as contoso.onmicrosoft.com, or the GUID representing the TenantID property of the directory). -``` +```js window.applicationConfig = { clientID: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' }; @@ -146,3 +151,7 @@ msalProvider.init( * If running locally, browse to `http://localhost:8080` and click `Login` or `Todo List`, your browser will be redirected to `https://login.microsoftonline.com/` for authentication. * Upon successful login, `Todo List` will give you a default item and you can perform add, update or delete operation. The backend RESTful API will accept or deny your request based on authenticated user roles. + +## Troubleshooting +## Next steps +## Contributing \ No newline at end of file diff --git a/sdk/spring/azure-spring-boot-starter-active-directory/README.md b/sdk/spring/azure-spring-boot-starter-active-directory/README.md index ea532d3a3adf..c3df84339277 100644 --- a/sdk/spring/azure-spring-boot-starter-active-directory/README.md +++ b/sdk/spring/azure-spring-boot-starter-active-directory/README.md @@ -3,7 +3,7 @@ ## Overview With Spring Starter for Azure Active Directory, now you can get started quickly to build the authentication workflow for a web application that uses Azure AD and OAuth 2.0 to secure its back end. It also enables developers to create a role based authorization workflow for a Web API secured by Azure AD, with the power of the Spring Security Filter Chain. -### Key concepts +## Key concepts This package provides 2 ways to integrate with Spring Security and authenticate with Azure Active Directory. * Authenticate in backend, auto configuration for common Azure Active Directory OAuth2 properties and `OAuth2UserService` to map authorities are provided. * Authenticate in frontend, sends bearer authorization code to backend, in backend a Spring Security filter validates the Jwt token from Azure AD and save authentication. The Jwt token is also used to acquire a On-Behalf-Of token for Azure AD Graph API so that authenticated user's membership information is available for authorization of access of API resources. Below is a diagram that shows the layers and typical flow for Single Page Application with Spring Boot web API backend that uses the filter for Authentication and Authorization. @@ -14,7 +14,7 @@ The authorization flow is composed of 3 phrases: * Get On-Behalf-Of token and membership info from Azure AD Graph API * Evaluate the permission based on membership info to grant or deny access -##Getting started +## Getting started #### Register the Application in Azure AD * **Register a new application**: Go to Azure Portal - Azure Active Directory - App registrations - New application registration to register the application in Azure Active Directory. `Application ID` is `client-id` in `application.properties`. * **Grant permissions to the application**: After application registration succeeded, go to API ACCESS - Required permissions - DELEGATED PERMISSIONS, tick `Access the directory as the signed-in user` and `Sign in and read user profile`. Click `Grant Permissions` (Note: you will need administrator privilege to grant permission). @@ -22,10 +22,10 @@ The authorization flow is composed of 3 phrases: #### Add Maven Dependency -`azure-spring-boot-starter-active-directory` is published on Maven Central Repository. +`azure-active-directory-spring-boot-starter` is published on Maven Central Repository. If you are using Maven, add the following dependency. -[//]: # "{x-version-update-start;com.azure:azure-spring-boot-starter-active-directory;dependency}" +[//]: # "{x-version-update-start;com.azure:azure-active-directory-spring-boot-starter;current}" ```xml com.azure @@ -36,15 +36,15 @@ If you are using Maven, add the following dependency. [//]: # "{x-version-update-end}" ## Examples -#### Configure application.properties and autowire beans +### Configure application.properties and autowire beans Refer to different samples for different authentication ways. -##### Authenticate in backend +### Authenticate in backend -Please refer to [azure-spring-boot-sample-active-directory-backend](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md) for authenticate in backend. +Please refer to [azure-spring-boot-sample-active-directory-backend](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/README.md) for authenticate in backend. Or [azure-spring-boot-sample-active-directory-backend-v2](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md) to use Microsoft Graph API instead of Azure Active Directory Graph API. -Configure application.properties: +#### Configure application.properties: ```properties spring.security.oauth2.client.registration.azure.client-id=xxxxxx-your-client-id-xxxxxx spring.security.oauth2.client.registration.azure.client-secret=xxxxxx-your-client-secret-xxxxxx @@ -52,7 +52,7 @@ azure.activedirectory.tenant-id=xxxxxx-your-tenant-id-xxxxxx azure.activedirectory.active-directory-groups=group1, group2 ``` -Autowire `OAuth2UserService` bean in `WebSecurityConfigurerAdapter`: +#### Autowire `OAuth2UserService` bean in `WebSecurityConfigurerAdapter`: ```java @EnableWebSecurity @@ -74,11 +74,11 @@ public class AADOAuth2LoginConfigSample extends WebSecurityConfigurerAdapter { } ``` -##### Authenticate in frontend +### Authenticate in frontend Please refer to [azure-active-directory-spring-boot-sample](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory/README.md) for how to integrate Spring Security and Azure AD for authentication and authorization in a Single Page Application (SPA) scenario. -Configure application.properties: +#### Configure application.properties: ```properties azure.activedirectory.client-id=Application-ID-in-AAD-App-registrations azure.activedirectory.client-secret=Key-in-AAD-API-ACCESS @@ -90,7 +90,7 @@ If you're using [Azure China](https://docs.microsoft.com/azure/china/china-welco azure.activedirectory.environment=cn ``` -* Autowire `AADAuthenticationFilter` in `WebSecurityConfig.java` file +#### Autowire `AADAuthenticationFilter` in `WebSecurityConfig.java` file ```java @EnableGlobalMethodSecurity(securedEnabled = true, prePostEnabled = true) @@ -105,7 +105,7 @@ public class AADAuthenticationFilterConfigSample extends WebSecurityConfigurerAd * Role-based Authorization with annotation `@PreAuthorize("hasRole('GROUP_NAME')")` * Role-based Authorization with method `isMemberOf()` -##### Authenticate stateless APIs using AAD app roles +### Authenticate stateless APIs using AAD app roles This scenario fits best for stateless Spring backends exposing an API to SPAs ([OAuth 2.0 implicit grant flow](https://docs.microsoft.com/azure/active-directory/develop/v1-oauth2-implicit-grant-flow)) or service-to-service access using the [client credentials grant flow](https://docs.microsoft.com/azure/active-directory/develop/v1-oauth2-client-creds-grant-flow). @@ -113,14 +113,14 @@ The stateless processing can be activated with the `azure.activedirectory.sessio The authorization is using the [AAD AppRole feature](https://docs.microsoft.com/azure/architecture/multitenant-identity/app-roles#roles-using-azure-ad-app-roles), so instead of using the `groups` claim the token has a `roles` claim which contains roles [configured in your manifest](https://docs.microsoft.com/azure/active-directory/develop/howto-add-app-roles-in-azure-ad-apps#examples). -Configure your `application properties`: +#### Configure your `application properties`: ```properties azure.activedirectory.session-stateless=true azure.activedirectory.client-id=xxxxxx-your-client-id-xxxxxx ``` -Define your roles in your application registration manifest: +#### Define your roles in your application registration manifest: ```json "appRoles": [ { @@ -136,7 +136,7 @@ Define your roles in your application registration manifest: ], ``` -Autowire the auth filter and attach it to the filter chain: +#### Autowire the auth filter and attach it to the filter chain: ```java @EnableWebSecurity @@ -163,7 +163,7 @@ public class AADAppRoleStatelessAuthenticationFilterConfigSample extends WebSecu The roles you want to use within your application have to be [set up in the manifest of your application registration](https://docs.microsoft.com/azure/active-directory/develop/howto-add-app-roles-in-azure-ad-apps). -##### Using The Microsoft Graph API +### Using The Microsoft Graph API 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. * **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. @@ -182,6 +182,7 @@ azure.activedirectory.environment=cn-v2-graph ``` Please refer to [azure-spring-boot-sample-active-directory-backend-v2](../azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md) to see a sample configured to use the Microsoft Graph API. + ### Using Microsoft identity platform endpoints If you want to use v2 version endpoints to do authorization and authentication, please pay attention to the attributes of claims, because there are some attributes exists in v1 version id-token by default but not in v2 version id-token, if you have to get that attribute, please make sure to add it into your scope. There is the doc [Difference between v1 and v2](https://docs.microsoft.com/azure/active-directory/develop/azure-ad-endpoint-comparison), For example, the name attribute doesn't exist in v2 token, if you want it, you need add `profile` to your scope, like this: @@ -224,7 +225,7 @@ public class AADOAuth2LoginConditionalPolicyConfigSample extends WebSecurityConf } ``` ## Next steps -#### Allow telemetry +### Allow telemetry Microsoft would like to collect data about how users use this Spring boot starter. Microsoft uses this information to improve our tooling experience. Participation is voluntary. If you don't want to participate, just simply disable it by setting below configuration in `application.properties`. @@ -234,8 +235,6 @@ azure.activedirectory.allow-telemetry=false When telemetry is enabled, an HTTP request will be sent to URL `https://dc.services.visualstudio.com/v2/track`. So please make sure it's not blocked by your firewall. Find more information about Azure Service Privacy Statement, please check [Microsoft Online Services Privacy Statement](https://www.microsoft.com/privacystatement/OnlineServices/Default.aspx). -## Key concepts - ## Troubleshooting ## Contributing From f6907c50c8a12598fe36b5b732b427a86a2faec6 Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Thu, 30 Apr 2020 15:26:31 +0800 Subject: [PATCH 04/11] fix README.md --- .../README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md index a68e2fd7d639..50047168d320 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/README.md @@ -91,3 +91,6 @@ spring.security.oauth2.client.provider.azure-oauth-provider.jwk-set-uri=https:// --- ### Meet with `AADSTS240002: Input id_token cannot be used as 'urn:ietf:params:oauth:grant-type:jwt-bearer' grant` error. In Azure portal, app registration manifest page, configure `oauth2AllowImplicitFlow` in your application manifest to `true`. See [this issue](https://github.com/MicrosoftDocs/azure-docs/issues/8121#issuecomment-387090099) for details on this workaround. + +## Next steps +## Contributing \ No newline at end of file From 99a999b42eeaa11b52ad2dab5ec252f8ff8b88ca Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Fri, 8 May 2020 17:46:27 +0800 Subject: [PATCH 05/11] add azure-spring-boot in jacoco-test-coverage pom file to make build-from-source successful --- eng/jacoco-test-coverage/pom.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eng/jacoco-test-coverage/pom.xml b/eng/jacoco-test-coverage/pom.xml index a437a2cedbab..43d0d0cbab57 100644 --- a/eng/jacoco-test-coverage/pom.xml +++ b/eng/jacoco-test-coverage/pom.xml @@ -182,6 +182,11 @@ azure-cosmos 4.0.1-beta.3 + + com.microsoft.azure + azure-spring-boot + 2.2.5-beta.1 + From 8a3cf58d472f64d840a293ccde7f59c25bb6cec1 Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Sat, 9 May 2020 09:53:05 +0800 Subject: [PATCH 06/11] move Spring versions to version_client.txt to keep consistency --- eng/versioning/version_client.txt | 3 +++ eng/versioning/version_data.txt | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/eng/versioning/version_client.txt b/eng/versioning/version_client.txt index 47322524d680..94e0c17308de 100644 --- a/eng/versioning/version_client.txt +++ b/eng/versioning/version_client.txt @@ -42,6 +42,9 @@ com.azure:azure-storage-perf;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-storage-queue;12.5.1;12.6.0-beta.1 com.azure:perf-test-core;1.0.0-beta.1;1.0.0-beta.1 com.azure:azure-test-watcher;1.0.0-beta.1;1.0.0-beta.1 +com.microsoft.azure:azure-spring-boot;2.2.4;2.2.5-beta.1 +com.microsoft.azure:azure-spring-boot-starter;2.2.4;2.2.5-beta.1 +com.microsoft.azure:azure-active-directory-spring-boot-starter;2.2.4;2.2.5-beta.1 # Unreleased dependencies: Copy the entry from above, prepend "unreleased_" and remove the current # version. Unreleased dependencies are only valid for dependency versions. diff --git a/eng/versioning/version_data.txt b/eng/versioning/version_data.txt index 4470658aae31..099f8d4a6356 100644 --- a/eng/versioning/version_data.txt +++ b/eng/versioning/version_data.txt @@ -40,6 +40,3 @@ com.microsoft.azure.msi_auth_token_provider:azure-authentication-msi-token-provi com.microsoft.azure:azure-eventgrid;1.4.0-beta.1;1.4.0-beta.1 com.microsoft.azure:azure-loganalytics;1.0.0-beta-2;1.0.0-beta.2 com.microsoft.azure:azure-media;1.0.0-beta.1;1.0.0-beta.1 -com.microsoft.azure:azure-spring-boot;2.2.4;2.2.5-beta.1 -com.microsoft.azure:azure-spring-boot-starter;2.2.4;2.2.5-beta.1 -com.microsoft.azure:azure-active-directory-spring-boot-starter;2.2.4;2.2.5-beta.1 From 94c0ed9ee6e1b59c57a3d55e1f98eb5d856f3a66 Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Wed, 13 May 2020 17:15:13 +0800 Subject: [PATCH 07/11] add additional modules to build in ci.yml --- sdk/spring/ci.yml | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/sdk/spring/ci.yml b/sdk/spring/ci.yml index 73ada314a11a..e51d81324a18 100644 --- a/sdk/spring/ci.yml +++ b/sdk/spring/ci.yml @@ -50,8 +50,14 @@ stages: - name: azure-active-directory-spring-boot-starter groupId: com.microsoft.azure safeName: azurespringbootstarteractivedirectory - - - - - + AdditionalModules: + - name: azure-spring-boot-samples + groupId: com.microsoft.azure + - name: azure-spring-boot-sample-active-directory + groupId: com.microsoft.azure + - name: azure-spring-boot-sample-active-directory-backend + groupId: com.microsoft.azure + - name: azure-spring-boot-sample-active-directory-backend-v2 + groupId: com.microsoft.azure + - name: azure-spring-boot-sample-active-directory-stateless + groupId: com.microsoft.azure From 050e05f1a91871b7021b22aac24e23b779d5f700 Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Thu, 21 May 2020 17:20:02 +0800 Subject: [PATCH 08/11] add configurations for JavaDoc plugins and entries in jacoco-test-coverage --- eng/jacoco-test-coverage/pom.xml | 10 +++ .../pom.xml | 70 +++++++++++++++++++ sdk/spring/azure-spring-boot-starter/pom.xml | 70 +++++++++++++++++++ 3 files changed, 150 insertions(+) diff --git a/eng/jacoco-test-coverage/pom.xml b/eng/jacoco-test-coverage/pom.xml index 69426a34f445..83ed5a5a3fe6 100644 --- a/eng/jacoco-test-coverage/pom.xml +++ b/eng/jacoco-test-coverage/pom.xml @@ -192,6 +192,16 @@ azure-spring-boot 2.2.5-beta.1 + + com.microsoft.azure + azure-spring-boot-starter + 2.2.5-beta.1 + + + com.microsoft.azure + azure-active-directory-spring-boot-starter + 2.2.5-beta.1 + diff --git a/sdk/spring/azure-spring-boot-starter-active-directory/pom.xml b/sdk/spring/azure-spring-boot-starter-active-directory/pom.xml index 711803dd33e6..bed27e0c4cee 100644 --- a/sdk/spring/azure-spring-boot-starter-active-directory/pom.xml +++ b/sdk/spring/azure-spring-boot-starter-active-directory/pom.xml @@ -97,6 +97,76 @@ + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.1.1 + + + attach-javadocs + + jar + + + true + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.2 + + + empty-javadoc-jar-with-readme + package + + jar + + + javadoc + ${project.basedir}/javadocTemp + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + copy-readme-to-javadocTemp + prepare-package + + + Deleting existing ${project.basedir}/javadocTemp + + + + Copying ${project.basedir}/README.md to + ${project.basedir}/javadocTemp/README.md + + + + + + run + + + + + diff --git a/sdk/spring/azure-spring-boot-starter/pom.xml b/sdk/spring/azure-spring-boot-starter/pom.xml index 772fe5b86f80..bb2ce52779bd 100644 --- a/sdk/spring/azure-spring-boot-starter/pom.xml +++ b/sdk/spring/azure-spring-boot-starter/pom.xml @@ -55,6 +55,76 @@ + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.1.1 + + + attach-javadocs + + jar + + + true + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.1.2 + + + empty-javadoc-jar-with-readme + package + + jar + + + javadoc + ${project.basedir}/javadocTemp + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + copy-readme-to-javadocTemp + prepare-package + + + Deleting existing ${project.basedir}/javadocTemp + + + + Copying ${project.basedir}/README.md to + ${project.basedir}/javadocTemp/README.md + + + + + + run + + + + + From 266ae5e287511070626d147a528f1c32b9485e78 Mon Sep 17 00:00:00 2001 From: Yi Liu Date: Wed, 27 May 2020 17:58:36 +0800 Subject: [PATCH 09/11] remove dependencyManagement and move bom file to sdk/boms --- .../azure-spring-boot-bom/pom.xml | 0 sdk/boms/ci.yml | 3 +++ .../pom.xml | 1 + .../pom.xml | 1 + .../pom.xml | 1 + .../pom.xml | 1 + sdk/spring/azure-spring-boot-samples/pom.xml | 17 ----------------- 7 files changed, 7 insertions(+), 17 deletions(-) rename sdk/{spring => boms}/azure-spring-boot-bom/pom.xml (100%) diff --git a/sdk/spring/azure-spring-boot-bom/pom.xml b/sdk/boms/azure-spring-boot-bom/pom.xml similarity index 100% rename from sdk/spring/azure-spring-boot-bom/pom.xml rename to sdk/boms/azure-spring-boot-bom/pom.xml diff --git a/sdk/boms/ci.yml b/sdk/boms/ci.yml index 6db7700c6902..93d58b88cee8 100644 --- a/sdk/boms/ci.yml +++ b/sdk/boms/ci.yml @@ -40,3 +40,6 @@ stages: - name: azure-sdk-bom groupId: com.azure safeName: azuresdkbom + - name: azure-spring-boot-bom + groupID: com.microsoft.azure + safeName: azurespringbootbom diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/pom.xml index 1bcc0411b772..0534c1a707ff 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/pom.xml +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend-v2/pom.xml @@ -21,6 +21,7 @@ com.microsoft.azure azure-active-directory-spring-boot-starter + 2.2.5-beta.1 diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/pom.xml index 4a21bf72e586..b6dbbfcd8a32 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/pom.xml +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-backend/pom.xml @@ -21,6 +21,7 @@ com.microsoft.azure azure-active-directory-spring-boot-starter + 2.2.5-beta.1 diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/pom.xml index cda76e65383e..b86e3af75b79 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/pom.xml +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory-stateless/pom.xml @@ -23,6 +23,7 @@ com.microsoft.azure azure-active-directory-spring-boot-starter + 2.2.5-beta.1 diff --git a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/pom.xml b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/pom.xml index 81f942376fc0..1efff6e3fbd2 100644 --- a/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/pom.xml +++ b/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-active-directory/pom.xml @@ -21,6 +21,7 @@ com.microsoft.azure azure-active-directory-spring-boot-starter + 2.2.5-beta.1 org.springframework.boot diff --git a/sdk/spring/azure-spring-boot-samples/pom.xml b/sdk/spring/azure-spring-boot-samples/pom.xml index 937f0d61b2d0..4e2e4bdae9d8 100644 --- a/sdk/spring/azure-spring-boot-samples/pom.xml +++ b/sdk/spring/azure-spring-boot-samples/pom.xml @@ -52,23 +52,6 @@ UTF-8 - - - - com.microsoft.azure - azure-spring-boot-bom - 2.2.5-beta.1 - pom - import - - - commons-io - commons-io - 2.3 - - - - From fbcc5aa85b4dad2108c297c543cf568ecaba0718 Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Wed, 27 May 2020 22:08:39 +0800 Subject: [PATCH 10/11] remove azure-spring-boot-bom in spring ci --- sdk/spring/ci.yml | 5 +---- sdk/spring/pom.xml | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/sdk/spring/ci.yml b/sdk/spring/ci.yml index 9a0e04d43960..15c390255b8c 100644 --- a/sdk/spring/ci.yml +++ b/sdk/spring/ci.yml @@ -41,9 +41,6 @@ stages: - name: azure-spring-boot groupId: com.microsoft.azure safeName: azurespringboot - - name: azure-spring-boot-bom - groupId: com.microsoft.azure - safeName: azurespringbootbom - name: azure-spring-boot-starter groupId: com.microsoft.azure safeName: azurespringbootstarter @@ -72,4 +69,4 @@ stages: - name: azure-spring-boot-sample-active-directory-backend-v2 groupId: com.microsoft.azure - name: azure-spring-boot-sample-active-directory-stateless - groupId: com.microsoft.azure \ No newline at end of file + groupId: com.microsoft.azure diff --git a/sdk/spring/pom.xml b/sdk/spring/pom.xml index 56aceb30aa97..0b84e9420b66 100644 --- a/sdk/spring/pom.xml +++ b/sdk/spring/pom.xml @@ -10,7 +10,6 @@ 1.0.0 azure-spring-boot - azure-spring-boot-bom azure-spring-boot-starter azure-spring-boot-starter-active-directory azure-spring-boot-starter-active-directory-b2c From da2970d4d8a119297de76d1bd5b43c375a9f42f8 Mon Sep 17 00:00:00 2001 From: Xiaolu Dai Date: Wed, 10 Jun 2020 11:45:53 +0800 Subject: [PATCH 11/11] remove current tags from azure-spring-boot-bom --- sdk/boms/azure-spring-boot-bom/pom.xml | 44 ++++++++------------------ 1 file changed, 14 insertions(+), 30 deletions(-) diff --git a/sdk/boms/azure-spring-boot-bom/pom.xml b/sdk/boms/azure-spring-boot-bom/pom.xml index 73870aff8dec..35435557fe68 100644 --- a/sdk/boms/azure-spring-boot-bom/pom.xml +++ b/sdk/boms/azure-spring-boot-bom/pom.xml @@ -55,64 +55,48 @@ com.microsoft.azure azure-spring-boot - 2.2.5-beta.1 + 2.2.5-beta.1 com.microsoft.azure azure-spring-boot-starter - 2.2.5-beta.1 + 2.2.5-beta.1 com.microsoft.azure azure-active-directory-spring-boot-starter - 2.2.5-beta.1 + 2.2.5-beta.1 -