From 3599006c7f7d90f84b0504d0fefd6fa890591580 Mon Sep 17 00:00:00 2001 From: damienbod Date: Tue, 28 Nov 2023 19:33:59 +0100 Subject: [PATCH 01/18] .NET 8 --- .../ApiWithMutlipleApis.csproj | 22 ++--- .../ServiceApi/ServiceApi.csproj | 18 ++-- .../UserApi/UserApi.csproj | 4 +- README.md | 88 +++++++------------ 4 files changed, 52 insertions(+), 80 deletions(-) diff --git a/AngularAzureADMultipleApis/ApiWithMutlipleApis/ApiWithMutlipleApis.csproj b/AngularAzureADMultipleApis/ApiWithMutlipleApis/ApiWithMutlipleApis.csproj index 688389f..7193cdf 100644 --- a/AngularAzureADMultipleApis/ApiWithMutlipleApis/ApiWithMutlipleApis.csproj +++ b/AngularAzureADMultipleApis/ApiWithMutlipleApis/ApiWithMutlipleApis.csproj @@ -1,27 +1,27 @@  - net7.0 + net8.0 3e9ac996-8e75-4dd9-9a5b-27a6e01a3f3d enable enable - - - + + + - - + + - - + + - - - + + + diff --git a/AngularAzureADMultipleApis/ServiceApi/ServiceApi.csproj b/AngularAzureADMultipleApis/ServiceApi/ServiceApi.csproj index e0840d6..5439c67 100644 --- a/AngularAzureADMultipleApis/ServiceApi/ServiceApi.csproj +++ b/AngularAzureADMultipleApis/ServiceApi/ServiceApi.csproj @@ -1,25 +1,25 @@  - net7.0 + net8.0 196b270c-b0c0-4b90-8f04-d3108e701d51 enable - + - - + + - - + + - - - + + + diff --git a/AngularAzureADMultipleApis/UserApi/UserApi.csproj b/AngularAzureADMultipleApis/UserApi/UserApi.csproj index 0a6bc84..7071290 100644 --- a/AngularAzureADMultipleApis/UserApi/UserApi.csproj +++ b/AngularAzureADMultipleApis/UserApi/UserApi.csproj @@ -1,14 +1,14 @@  - net7.0 + net8.0 aspnet-UserApiOne-2ba0bbf9-49f5-452e-8333-1e33a467b74e enable enable - + diff --git a/README.md b/README.md index 33f68b4..15c600e 100644 --- a/README.md +++ b/README.md @@ -19,64 +19,36 @@ ## History -2023-08-14 Updated downstream APIs solution - -2023-08-14 Updated packages - -2023-05-05 Updated packages - -2023-03-12 Updated .NET 7, updated nuget packages, implicit usings - -2022-10-09 Updated nuget packages - -2022-08-01 Updated nuget packages - -2022-04-03 Updated nuget packages, added nullable to projects, added CC flow demo - -2022-02-19 Updated nuget packages - -2022-01-07 Updated nuget packages - -2021-11-04 Updated to .NET 6 - -2021-08-13 Updated Blazor BFF app and fixed login button - -2021-07-03 Microsoft.Identity.Web to 1.14, Angular OIDC V12 - -2021-06-20 Microsoft.Identity.Web to 1.13.1 - -2021-06-06 Microsoft.Identity.Web to 1.12 - -2021-05-13 Microsoft.Identity.Web to 1.9.2, updated packages - -2021-04-15 Microsoft.Identity.Web to 1.9.1 - -2021-03-11 Microsoft.Identity.Web to 1.8.0 - -2021-03-05 Microsoft.Identity.Web to 1.7.0 - -2021-02-13 Added MSAL exception handling, Microsoft.Identity.Web to 1.6.0 - -2021-02-01 Added app roles authorization example - -2021-01-28 Added device code flow, Microsoft.Identity.Web to 1.5.1 - -2021-01-19 Updated nuget, npm packages, moved to latest secrets access for certs in Key Vault - -2021-01-05 Added token management, updated Microsoft.Identity.Web to 1.4.1 - -2020-12-14 Using multiple APIs in Blazor with Azure AD authentication - -2020-12-12 Updated Microsoft.Identity.Web to 1.4.0 - -2020-12-08 Added Using multiple APIs in Angular and ASP.NET Core with Azure AD authentication - -2020-12-04 Updated to .NET 5 - -2020-11-15 Updated Microsoft.Identity.Web to 1.3.0 - -2020-10-25 Updated Microsoft.Identity.Web to 1.2.0 - +- 2023-08-14 Updated .NET 8 +- 2023-08-14 Updated downstream APIs solution +- 2023-08-14 Updated packages +- 2023-05-05 Updated packages +- 2023-03-12 Updated .NET 7, updated nuget packages, implicit usings +- 2022-10-09 Updated nuget packages +- 2022-08-01 Updated nuget packages +- 2022-04-03 Updated nuget packages, added nullable to projects, added CC flow demo +- 2022-02-19 Updated nuget packages +- 2022-01-07 Updated nuget packages +- 2021-11-04 Updated to .NET 6 +- 2021-08-13 Updated Blazor BFF app and fixed login button +- 2021-07-03 Microsoft.Identity.Web to 1.14, Angular OIDC V12 +- 2021-06-20 Microsoft.Identity.Web to 1.13.1 +- 2021-06-06 Microsoft.Identity.Web to 1.12 +- 2021-05-13 Microsoft.Identity.Web to 1.9.2, updated packages +- 2021-04-15 Microsoft.Identity.Web to 1.9.1 +- 2021-03-11 Microsoft.Identity.Web to 1.8.0 +- 2021-03-05 Microsoft.Identity.Web to 1.7.0 +- 2021-02-13 Added MSAL exception handling, Microsoft.Identity.Web to 1.6.0 +- 2021-02-01 Added app roles authorization example +- 2021-01-28 Added device code flow, Microsoft.Identity.Web to 1.5.1 +- 2021-01-19 Updated nuget, npm packages, moved to latest secrets access for certs in Key Vault +- 2021-01-05 Added token management, updated Microsoft.Identity.Web to 1.4.1 +- 2020-12-14 Using multiple APIs in Blazor with Azure AD authentication +- 2020-12-12 Updated Microsoft.Identity.Web to 1.4.0 +- 2020-12-08 Added Using multiple APIs in Angular and ASP.NET Core with Azure AD authentication +- 2020-12-04 Updated to .NET 5 +- 2020-11-15 Updated Microsoft.Identity.Web to 1.3.0 +- 2020-10-25 Updated Microsoft.Identity.Web to 1.2.0 ## Links Private key JWT Client authentication From 5901a126f9b3108a8af1e6205c7a4bb49586b27b Mon Sep 17 00:00:00 2001 From: damienbod Date: Tue, 28 Nov 2023 19:36:51 +0100 Subject: [PATCH 02/18] Microsoft Entra ID --- README.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 15c600e..485f4b8 100644 --- a/README.md +++ b/README.md @@ -4,18 +4,18 @@ # Blogs -- [Implement Azure AD Client credentials flow using Client Certificates for service APIs](https://damienbod.com/2020/10/01/implement-azure-ad-client-credentials-flow-using-client-certificates-for-service-apis/) +- [Implement Microsoft Entra ID Client credentials flow using Client Certificates for service APIs](https://damienbod.com/2020/10/01/implement-azure-ad-client-credentials-flow-using-client-certificates-for-service-apis/) - [Using Key Vault certificates with Microsoft.Identity.Web and ASP.NET Core applications](https://damienbod.com/2020/10/09/using-key-vault-certificates-with-microsoft-identity-web-and-asp-net-core-applications/) - [Using encrypted access tokens in Azure with Microsoft.Identity.Web and Azure App registrations](https://damienbod.com/2020/10/22/using-encrypted-access-tokens-in-azure-with-microsoft-identity-web-and-azure-app-registrations/) -- [Implement a Web APP and an ASP.NET Core Secure API using Azure AD which delegates to a second API](https://damienbod.com/2020/11/09/implement-a-web-app-and-an-asp-net-core-secure-api-using-azure-ad-which-delegates-to-second-api/) -- [Using multiple APIs in Angular and ASP.NET Core with Azure AD authentication](https://damienbod.com/2020/12/08/using-multiple-apis-in-angular-and-asp-net-core-with-azure-ad-authentication/) -- [Using multiple APIs in Blazor with Azure AD authentication](https://damienbod.com/2020/12/14/using-multiple-apis-in-blazor-with-azure-ad-authentication/) -- [Azure AD Access Token Lifetime Policy Management in ASP.NET Core](https://damienbod.com/2021/01/05/azure-ad-access-token-lifetime-policy-management-in-asp-net-core/) -- [Implement OAUTH Device Code Flow with Azure AD and ASP.NET Core](https://damienbod.com/2021/01/28/implement-oauth-device-code-flow-with-azure-ad-and-asp-net-core/) -- [Implement app roles authorization with Azure AD and ASP.NET Core](https://damienbod.com/2021/02/01/implement-app-roles-authorization-with-azure-ad-and-asp-net-core/) +- [Implement a Web APP and an ASP.NET Core Secure API using Microsoft Entra ID which delegates to a second API](https://damienbod.com/2020/11/09/implement-a-web-app-and-an-asp-net-core-secure-api-using-azure-ad-which-delegates-to-second-api/) +- [Using multiple APIs in Angular and ASP.NET Core with Microsoft Entra ID authentication](https://damienbod.com/2020/12/08/using-multiple-apis-in-angular-and-asp-net-core-with-azure-ad-authentication/) +- [Using multiple APIs in Blazor with Microsoft Entra ID authentication](https://damienbod.com/2020/12/14/using-multiple-apis-in-blazor-with-azure-ad-authentication/) +- [Microsoft Entra ID Access Token Lifetime Policy Management in ASP.NET Core](https://damienbod.com/2021/01/05/azure-ad-access-token-lifetime-policy-management-in-asp-net-core/) +- [Implement OAUTH Device Code Flow with Microsoft Entra ID and ASP.NET Core](https://damienbod.com/2021/01/28/implement-oauth-device-code-flow-with-azure-ad-and-asp-net-core/) +- [Implement app roles authorization with Microsoft Entra ID and ASP.NET Core](https://damienbod.com/2021/02/01/implement-app-roles-authorization-with-azure-ad-and-asp-net-core/) - [Securing Blazor Web assembly using cookies](https://damienbod.com/2021/03/08/securing-blazor-web-assembly-using-cookies/) -- [Implementing authorization in Blazor ASP.NET Core applications using Azure AD security groups](https://damienbod.com/2022/02/21/implementing-authorization-in-blazor-asp-net-core-applications-using-azure-ad-security-groups/) -- [Implementing OAuth2 APP to APP security using Azure AD from a Web APP](https://damienbod.com/2022/03/28/implementing-oauth2-app-to-app-security-using-azure-ad-from-a-web-app/) +- [Implementing authorization in Blazor ASP.NET Core applications using Microsoft Entra ID security groups](https://damienbod.com/2022/02/21/implementing-authorization-in-blazor-asp-net-core-applications-using-azure-ad-security-groups/) +- [Implementing OAuth2 APP to APP security using Microsoft Entra ID from a Web APP](https://damienbod.com/2022/03/28/implementing-oauth2-app-to-app-security-using-azure-ad-from-a-web-app/) ## History @@ -54,7 +54,7 @@ https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow#second-case-access-token-request-with-a-certificate -## Links Azure Client credentials flow +## Links Microsoft Entra ID Client credentials flow https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/Client-credential-flows From 43984e87ee77074ab96475141aa138a849d18a5c Mon Sep 17 00:00:00 2001 From: damienbod Date: Tue, 28 Nov 2023 19:38:10 +0100 Subject: [PATCH 03/18] fix errors --- .../ServiceApi/SecurityHeadersDefinitions.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/AngularAzureADMultipleApis/ServiceApi/SecurityHeadersDefinitions.cs b/AngularAzureADMultipleApis/ServiceApi/SecurityHeadersDefinitions.cs index 7e13048..cc0c1dc 100644 --- a/AngularAzureADMultipleApis/ServiceApi/SecurityHeadersDefinitions.cs +++ b/AngularAzureADMultipleApis/ServiceApi/SecurityHeadersDefinitions.cs @@ -8,7 +8,6 @@ public static HeaderPolicyCollection GetHeaderPolicyCollection(bool isDev) { var policy = new HeaderPolicyCollection() .AddFrameOptionsDeny() - .AddXssProtectionBlock() .AddContentTypeOptionsNoSniff() .AddReferrerPolicyStrictOriginWhenCrossOrigin() .RemoveServerHeader() From db667d29db8b9b7c1c3030d3a48d08d5f673863d Mon Sep 17 00:00:00 2001 From: damienbod Date: Tue, 28 Nov 2023 19:47:24 +0100 Subject: [PATCH 04/18] .NET 8 --- AppRoles/WebApiWithRoles/WebApiWithRoles.csproj | 4 ++-- AppRoles/WebAppWithRoles/WebAppWithRoles.csproj | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/AppRoles/WebApiWithRoles/WebApiWithRoles.csproj b/AppRoles/WebApiWithRoles/WebApiWithRoles.csproj index 920dc01..ebf986f 100644 --- a/AppRoles/WebApiWithRoles/WebApiWithRoles.csproj +++ b/AppRoles/WebApiWithRoles/WebApiWithRoles.csproj @@ -1,13 +1,13 @@  - net7.0 + net8.0 enable enable - + diff --git a/AppRoles/WebAppWithRoles/WebAppWithRoles.csproj b/AppRoles/WebAppWithRoles/WebAppWithRoles.csproj index 5bf5b11..4f49bbb 100644 --- a/AppRoles/WebAppWithRoles/WebAppWithRoles.csproj +++ b/AppRoles/WebAppWithRoles/WebAppWithRoles.csproj @@ -1,16 +1,16 @@  - net7.0 + net8.0 bdff93cf-79ea-4b5e-aeaf-ea1490d39566 enable enable - - - + + + From 9e7e3e6b847445f2ce158e83c7273ed9b7a8acd0 Mon Sep 17 00:00:00 2001 From: damienbod Date: Tue, 28 Nov 2023 19:49:57 +0100 Subject: [PATCH 05/18] Microsoft Entra ID --- AppRoles/README_CONFIG.md | 2 +- AppRoles/WebAppWithRoles/Pages/Index.cshtml | 4 ++-- README.md | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AppRoles/README_CONFIG.md b/AppRoles/README_CONFIG.md index c7536a0..8aaafd6 100644 --- a/AppRoles/README_CONFIG.md +++ b/AppRoles/README_CONFIG.md @@ -25,7 +25,7 @@ https://docs.microsoft.com/en-us/azure/active-directory/develop/access-tokens https://docs.microsoft.com/en-us/aspnet/core/security/authorization/policies -# Azure authorization +# Microsoft Entra ID authorization https://docs.microsoft.com/en-us/azure/role-based-access-control/overview diff --git a/AppRoles/WebAppWithRoles/Pages/Index.cshtml b/AppRoles/WebAppWithRoles/Pages/Index.cshtml index 748f30d..b81aae9 100644 --- a/AppRoles/WebAppWithRoles/Pages/Index.cshtml +++ b/AppRoles/WebAppWithRoles/Pages/Index.cshtml @@ -1,10 +1,10 @@ @page @model IndexModel @{ - ViewData["Title"] = "Azure AD App roles"; + ViewData["Title"] = "Microsoft Entra ID App roles"; }
-

Azure AD authentication, authorization with roles

+

Microsoft Entra ID authentication, authorization with roles

Web App which accesses Web API with different roles

diff --git a/README.md b/README.md index 485f4b8..a825859 100644 --- a/README.md +++ b/README.md @@ -43,9 +43,9 @@ - 2021-01-28 Added device code flow, Microsoft.Identity.Web to 1.5.1 - 2021-01-19 Updated nuget, npm packages, moved to latest secrets access for certs in Key Vault - 2021-01-05 Added token management, updated Microsoft.Identity.Web to 1.4.1 -- 2020-12-14 Using multiple APIs in Blazor with Azure AD authentication +- 2020-12-14 Using multiple APIs in Blazor with Microsoft Entra ID authentication - 2020-12-12 Updated Microsoft.Identity.Web to 1.4.0 -- 2020-12-08 Added Using multiple APIs in Angular and ASP.NET Core with Azure AD authentication +- 2020-12-08 Added Using multiple APIs in Angular and ASP.NET Core with Microsoft Entra ID authentication - 2020-12-04 Updated to .NET 5 - 2020-11-15 Updated Microsoft.Identity.Web to 1.3.0 - 2020-10-25 Updated Microsoft.Identity.Web to 1.2.0 From c2d350b94da300b3ab35e38806b68c73abd4a19b Mon Sep 17 00:00:00 2001 From: damienbod Date: Tue, 28 Nov 2023 19:58:59 +0100 Subject: [PATCH 06/18] Update graph --- .../Client/BlazorAzureADWithApis.Client.csproj | 10 +++++----- .../Server/BlazorAzureADWithApis.Server.csproj | 16 ++++++++-------- .../Server/Controllers/GraphProfileController.cs | 2 +- .../Application/MsGraphApplicationService.cs | 4 ++-- .../Shared/BlazorAzureADWithApis.Shared.csproj | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/BlazorBff/BlazorAzureAdBff/Client/BlazorAzureADWithApis.Client.csproj b/BlazorBff/BlazorAzureAdBff/Client/BlazorAzureADWithApis.Client.csproj index 4083370..cb43ed3 100644 --- a/BlazorBff/BlazorAzureAdBff/Client/BlazorAzureADWithApis.Client.csproj +++ b/BlazorBff/BlazorAzureAdBff/Client/BlazorAzureADWithApis.Client.csproj @@ -1,17 +1,17 @@  - net7.0 + net8.0 true enable enable - - - - + + + + diff --git a/BlazorBff/BlazorAzureAdBff/Server/BlazorAzureADWithApis.Server.csproj b/BlazorBff/BlazorAzureAdBff/Server/BlazorAzureADWithApis.Server.csproj index 9f90c4a..51441fa 100644 --- a/BlazorBff/BlazorAzureAdBff/Server/BlazorAzureADWithApis.Server.csproj +++ b/BlazorBff/BlazorAzureAdBff/Server/BlazorAzureADWithApis.Server.csproj @@ -1,14 +1,14 @@  - net7.0 + net8.0 enable 7b7a3ab3-3ad6-4820-a521-dcdaf28f15cb enable - + @@ -17,12 +17,12 @@ - - - - - - + + + + + + diff --git a/BlazorBff/BlazorAzureAdBff/Server/Controllers/GraphProfileController.cs b/BlazorBff/BlazorAzureAdBff/Server/Controllers/GraphProfileController.cs index a994ee8..b91105c 100644 --- a/BlazorBff/BlazorAzureAdBff/Server/Controllers/GraphProfileController.cs +++ b/BlazorBff/BlazorAzureAdBff/Server/Controllers/GraphProfileController.cs @@ -26,7 +26,7 @@ public GraphProfileController(MsGraphDelegatedService microsoftGraphDelegatedCli public async Task> Get() { var userData = await _microsoftGraphDelegatedClientService.GetGraphApiUser(); - return new List { $"DisplayName: {userData.DisplayName}", + return new List { $"DisplayName: {userData!.DisplayName}", $"GivenName: {userData.GivenName}", $"AboutMe: {userData.AboutMe}" }; } } diff --git a/BlazorBff/BlazorAzureAdBff/Server/Services/Application/MsGraphApplicationService.cs b/BlazorBff/BlazorAzureAdBff/Server/Services/Application/MsGraphApplicationService.cs index f20054a..f2dc17e 100644 --- a/BlazorBff/BlazorAzureAdBff/Server/Services/Application/MsGraphApplicationService.cs +++ b/BlazorBff/BlazorAzureAdBff/Server/Services/Application/MsGraphApplicationService.cs @@ -23,7 +23,7 @@ public MsGraphApplicationService(IConfiguration configuration) .GetAsync(); } - public async Task GetGraphApiUserMemberGroups(string userId) + public async Task GetGraphApiUserMemberGroups(string userId) { var graphServiceClient = GetGraphClient(); @@ -34,7 +34,7 @@ public MsGraphApplicationService(IConfiguration configuration) return await graphServiceClient.Users[userId] .GetMemberGroups - .PostAsync(requestBody); + .PostAsGetMemberGroupsPostResponseAsync(requestBody); } private GraphServiceClient GetGraphClient() { diff --git a/BlazorBff/BlazorAzureAdBff/Shared/BlazorAzureADWithApis.Shared.csproj b/BlazorBff/BlazorAzureAdBff/Shared/BlazorAzureADWithApis.Shared.csproj index 82e7f88..43e82e3 100644 --- a/BlazorBff/BlazorAzureAdBff/Shared/BlazorAzureADWithApis.Shared.csproj +++ b/BlazorBff/BlazorAzureAdBff/Shared/BlazorAzureADWithApis.Shared.csproj @@ -1,13 +1,13 @@  - net7.0 + net8.0 enable enable - + From 35c0f801b9cf022940146e16afe0e5a6d0ada9ca Mon Sep 17 00:00:00 2001 From: damienbod Date: Tue, 28 Nov 2023 20:07:32 +0100 Subject: [PATCH 07/18] .NET 8 --- .../Client/BlazorAzureADWithApis.Client.csproj | 12 ++++++------ .../BlazorAzureADWithApis/Client/Pages/Index.razor | 2 +- .../Client/Shared/NavMenu.razor | 2 +- .../BlazorAzureADWithApis/Client/wwwroot/index.html | 2 +- .../Server/BlazorAzureADWithApis.Server.csproj | 10 +++++----- .../Server/Services/ServiceApiClientService.cs | 2 +- .../Shared/BlazorAzureADWithApis.Shared.csproj | 2 +- BlazorWithApis/README_CONFIG.md | 2 +- BlazorWithApis/ServiceApi/ServiceApi.csproj | 4 ++-- BlazorWithApis/UserApi/UserApi.csproj | 4 ++-- 10 files changed, 21 insertions(+), 21 deletions(-) diff --git a/BlazorWithApis/BlazorAzureADWithApis/Client/BlazorAzureADWithApis.Client.csproj b/BlazorWithApis/BlazorAzureADWithApis/Client/BlazorAzureADWithApis.Client.csproj index cdcb40d..f40c4b6 100644 --- a/BlazorWithApis/BlazorAzureADWithApis/Client/BlazorAzureADWithApis.Client.csproj +++ b/BlazorWithApis/BlazorAzureADWithApis/Client/BlazorAzureADWithApis.Client.csproj @@ -1,18 +1,18 @@  - net7.0 + net8.0 service-worker-assets.js enable enable - - - - - + + + + + diff --git a/BlazorWithApis/BlazorAzureADWithApis/Client/Pages/Index.razor b/BlazorWithApis/BlazorAzureADWithApis/Client/Pages/Index.razor index 89ebf8d..02fbd81 100644 --- a/BlazorWithApis/BlazorAzureADWithApis/Client/Pages/Index.razor +++ b/BlazorWithApis/BlazorAzureADWithApis/Client/Pages/Index.razor @@ -1,3 +1,3 @@ @page "/" -

Azure AD with multiple APIs

+

Microsoft Entra ID with multiple APIs

diff --git a/BlazorWithApis/BlazorAzureADWithApis/Client/Shared/NavMenu.razor b/BlazorWithApis/BlazorAzureADWithApis/Client/Shared/NavMenu.razor index 4f8e647..ba135aa 100644 --- a/BlazorWithApis/BlazorAzureADWithApis/Client/Shared/NavMenu.razor +++ b/BlazorWithApis/BlazorAzureADWithApis/Client/Shared/NavMenu.razor @@ -1,5 +1,5 @@