From e266d034c660c725dac68059f0e0af696e299f67 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 18 Nov 2020 11:07:25 -0800 Subject: [PATCH 1/7] Remove obsolete AzureAd --- src/Azure/Azure.slnf | 8 - .../AzureAD/Controllers/AccountController.cs | 47 -- .../AzureAD/Pages/Account/AccessDenied.cshtml | 10 - .../Pages/Account/AccessDenied.cshtml.cs | 24 - .../Areas/AzureAD/Pages/Account/Error.cshtml | 23 - .../AzureAD/Pages/Account/Error.cshtml.cs | 40 -- .../AzureAD/Pages/Account/SignedOut.cshtml | 10 - .../AzureAD/Pages/Account/SignedOut.cshtml.cs | 31 -- .../AzureAD/Pages/Account/_viewImports.cshtml | 2 - .../src/Areas/AzureAD/Pages/_ViewStart.cshtml | 13 - ...AzureADAccountControllerFeatureProvider.cs | 24 - .../AzureADAuthenticationBuilderExtensions.cs | 231 -------- .../src/AzureADCookieOptionsConfiguration.cs | 60 --- .../src/AzureADDefaults.cs | 47 -- .../AzureADJwtBearerOptionsConfiguration.cs | 60 --- ...zureADOpenIdConnectOptionsConfiguration.cs | 62 --- .../src/AzureADOptions.cs | 74 --- .../src/AzureADOptionsConfiguration.cs | 40 -- .../src/AzureADOptionsValidation.cs | 22 - .../src/AzureADSchemeOptions.cs | 25 - ...spNetCore.Authentication.AzureAD.UI.csproj | 20 - .../src/Properties/AssemblyInfo.cs | 6 - .../src/PublicAPI.Shipped.txt | 47 -- .../src/PublicAPI.Unshipped.txt | 1 - ...eADAuthenticationBuilderExtensionsTests.cs | 509 ------------------ .../Controllers/AccountControllerTests.cs | 281 ---------- ...Core.Authentication.AzureAD.UI.Test.csproj | 20 - .../test/xunit.runner.json | 3 - .../Controllers/AccountController.cs | 85 --- .../Pages/Account/AccessDenied.cshtml | 10 - .../Pages/Account/AccessDenied.cshtml.cs | 24 - .../AzureADB2C/Pages/Account/Error.cshtml | 23 - .../AzureADB2C/Pages/Account/Error.cshtml.cs | 40 -- .../AzureADB2C/Pages/Account/SignedOut.cshtml | 10 - .../Pages/Account/SignedOut.cshtml.cs | 31 -- .../Pages/Account/_viewImports.cshtml | 2 - .../Areas/AzureADB2C/Pages/_ViewStart.cshtml | 13 - ...reADB2CAccountControllerFeatureProvider.cs | 24 - .../AzureADB2CCookieOptionsConfiguration.cs | 55 -- ...AzureADB2CJwtBearerOptionsConfiguration.cs | 55 -- ...eADB2COpenIdConnectOptionsConfiguration.cs | 77 --- ...ureAdB2CAuthenticationBuilderExtensions.cs | 228 -------- .../src/AzureAdB2CDefaults.cs | 53 -- .../AzureAdB2COpenIDConnectEventHandlers.cs | 89 --- .../src/AzureAdB2COptions.cs | 90 ---- .../src/AzureAdB2COptionsConfiguration.cs | 40 -- .../src/AzureAdB2CSchemeOptions.cs | 25 - ...etCore.Authentication.AzureADB2C.UI.csproj | 20 - .../src/Properties/AssemblyInfo.cs | 6 - .../src/PublicAPI.Shipped.txt | 53 -- .../src/PublicAPI.Unshipped.txt | 1 - ...B2CAuthenticationBuilderExtensionsTests.cs | 426 --------------- ...ureAdB2COpenIDConnectEventHandlersTests.cs | 175 ------ .../Controllers/AccountControllerTests.cs | 388 ------------- ...e.Authentication.AzureADB2C.UI.Test.csproj | 20 - .../test/xunit.runner.json | 3 - src/Azure/AzureAD/AzureAD.ruleset | 12 - src/Azure/AzureAD/Directory.Build.props | 8 - src/Azure/AzureAD/README.md | 4 - .../FunctionalTests/ApiAuthenticationTests.cs | 91 ---- ...hentication.AzureAD.FunctionalTests.csproj | 44 -- .../FunctionalTests/WebAuthenticationTests.cs | 219 -------- .../test/FunctionalTests/xunit.runner.json | 3 - .../AzureAD.WebSite/AzureAD.WebSite.csproj | 16 - .../Controllers/TestController.cs | 15 - .../testassets/AzureAD.WebSite/Program.cs | 30 -- .../testassets/AzureAD.WebSite/Startup.cs | 31 -- 67 files changed, 4279 deletions(-) delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Controllers/AccountController.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/AccessDenied.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/AccessDenied.cshtml.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/Error.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/Error.cshtml.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/SignedOut.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/SignedOut.cshtml.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/_viewImports.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/_ViewStart.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAccountControllerFeatureProvider.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADCookieOptionsConfiguration.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADDefaults.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADJwtBearerOptionsConfiguration.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOpenIdConnectOptionsConfiguration.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptions.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptionsConfiguration.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptionsValidation.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADSchemeOptions.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/Properties/AssemblyInfo.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/PublicAPI.Shipped.txt delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/src/PublicAPI.Unshipped.txt delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/test/AzureADAuthenticationBuilderExtensionsTests.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/test/Controllers/AccountControllerTests.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/test/Microsoft.AspNetCore.Authentication.AzureAD.UI.Test.csproj delete mode 100644 src/Azure/AzureAD/Authentication.AzureAD.UI/test/xunit.runner.json delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Controllers/AccountController.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/AccessDenied.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/AccessDenied.cshtml.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/SignedOut.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/SignedOut.cshtml.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/_viewImports.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/_ViewStart.cshtml delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CAccountControllerFeatureProvider.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CCookieOptionsConfiguration.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CJwtBearerOptionsConfiguration.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2COpenIdConnectOptionsConfiguration.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CAuthenticationBuilderExtensions.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CDefaults.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COpenIDConnectEventHandlers.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COptions.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COptionsConfiguration.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CSchemeOptions.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Properties/AssemblyInfo.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/PublicAPI.Shipped.txt delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/PublicAPI.Unshipped.txt delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/AzureAdB2CAuthenticationBuilderExtensionsTests.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/AzureAdB2COpenIDConnectEventHandlersTests.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/Controllers/AccountControllerTests.cs delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test.csproj delete mode 100644 src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/xunit.runner.json delete mode 100644 src/Azure/AzureAD/AzureAD.ruleset delete mode 100644 src/Azure/AzureAD/Directory.Build.props delete mode 100644 src/Azure/AzureAD/README.md delete mode 100644 src/Azure/AzureAD/test/FunctionalTests/ApiAuthenticationTests.cs delete mode 100644 src/Azure/AzureAD/test/FunctionalTests/Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj delete mode 100644 src/Azure/AzureAD/test/FunctionalTests/WebAuthenticationTests.cs delete mode 100644 src/Azure/AzureAD/test/FunctionalTests/xunit.runner.json delete mode 100644 src/Azure/AzureAD/test/testassets/AzureAD.WebSite/AzureAD.WebSite.csproj delete mode 100644 src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Controllers/TestController.cs delete mode 100644 src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Program.cs delete mode 100644 src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Startup.cs diff --git a/src/Azure/Azure.slnf b/src/Azure/Azure.slnf index 61efcd7a1858..943c010a2eb6 100644 --- a/src/Azure/Azure.slnf +++ b/src/Azure/Azure.slnf @@ -2,13 +2,6 @@ "solution": { "path": "..\\..\\AspNetCore.sln", "projects" : [ - "src\\Azure\\AzureAD\\Authentication.AzureAD.UI\\src\\Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj", - "src\\Azure\\AzureAD\\Authentication.AzureAD.UI\\test\\Microsoft.AspNetCore.Authentication.AzureAD.UI.Test.csproj", - "src\\Azure\\AzureAD\\Authentication.AzureADB2C.UI\\src\\Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj", - "src\\Azure\\AzureAD\\Authentication.AzureADB2C.UI\\test\\Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test.csproj", - "src\\Azure\\AzureAD\\samples\\AzureADB2CSample\\AzureADB2CSample.csproj", - "src\\Azure\\AzureAD\\test\\FunctionalTests\\Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj", - "src\\Azure\\AzureAD\\test\\testassets\\AzureAD.WebSite\\AzureAD.WebSite.csproj", "src\\Servers\\Kestrel\\Kestrel\\src\\Microsoft.AspNetCore.Server.Kestrel.csproj", "src\\Servers\\Kestrel\\Core\\src\\Microsoft.AspNetCore.Server.Kestrel.Core.csproj", "src\\Middleware\\StaticFiles\\src\\Microsoft.AspNetCore.StaticFiles.csproj", @@ -30,7 +23,6 @@ "src\\Security\\Authentication\\OpenIdConnect\\src\\Microsoft.AspNetCore.Authentication.OpenIdConnect.csproj", "src\\Security\\Authentication\\OAuth\\src\\Microsoft.AspNetCore.Authentication.OAuth.csproj", "src\\Security\\Authentication\\Core\\src\\Microsoft.AspNetCore.Authentication.csproj", - "src\\Azure\\AzureAD\\samples\\AzureADSample\\AzureADSample.csproj", "src\\Security\\Authentication\\Cookies\\src\\Microsoft.AspNetCore.Authentication.Cookies.csproj", "src\\Security\\Authentication\\JwtBearer\\src\\Microsoft.AspNetCore.Authentication.JwtBearer.csproj" ] diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Controllers/AccountController.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Controllers/AccountController.cs deleted file mode 100644 index c728ee4e494d..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Controllers/AccountController.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureAD.Controllers.Internal -{ - [NonController] - [AllowAnonymous] - [Area("AzureAD")] - [Route("[area]/[controller]/[action]")] - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AccountController : Controller - { - public AccountController(IOptionsMonitor options) - { - Options = options; - } - - public IOptionsMonitor Options { get; } - - [HttpGet("{scheme?}")] - public IActionResult SignIn([FromRoute] string scheme) - { - scheme = scheme ?? AzureADDefaults.AuthenticationScheme; - var redirectUrl = Url.Content("~/"); - return Challenge( - new AuthenticationProperties { RedirectUri = redirectUrl }, - scheme); - } - - [HttpGet("{scheme?}")] - public IActionResult SignOut([FromRoute] string scheme) - { - scheme = scheme ?? AzureADDefaults.AuthenticationScheme; - var options = Options.Get(scheme); - var callbackUrl = Url.Page("/Account/SignedOut", pageHandler: null, values: null, protocol: Request.Scheme); - return SignOut( - new AuthenticationProperties { RedirectUri = callbackUrl }, - options.CookieSchemeName, - options.OpenIdConnectSchemeName); - } - } -} \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/AccessDenied.cshtml b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/AccessDenied.cshtml deleted file mode 100644 index 591045d3cd92..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/AccessDenied.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@page -@model AccessDeniedModel -@{ - ViewData["Title"] = "Access denied"; -} - -
-

@ViewData["Title"]

-

You do not have access to this resource.

-
diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/AccessDenied.cshtml.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/AccessDenied.cshtml.cs deleted file mode 100644 index 94db862a83a2..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/AccessDenied.cshtml.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal -{ - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - [AllowAnonymous] - public class AccessDeniedModel : PageModel - { - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public void OnGet() - { - } - } -} \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/Error.cshtml b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/Error.cshtml deleted file mode 100644 index 173f0834258a..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/Error.cshtml +++ /dev/null @@ -1,23 +0,0 @@ -@page -@model ErrorModel -@{ - ViewData["Title"] = "Error"; -} - -

Error.

-

An error occurred while processing your request.

- -@if (Model.ShowRequestId) -{ -

- Request ID: @Model.RequestId -

-} - -

Development Mode

-

- Swapping to Development environment will display more detailed information about the error that occurred. -

-

- Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. -

diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/Error.cshtml.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/Error.cshtml.cs deleted file mode 100644 index 32ad8b4e7c51..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/Error.cshtml.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System.Diagnostics; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal -{ - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - [AllowAnonymous] - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public class ErrorModel : PageModel - { - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public string RequestId { get; set; } - - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public void OnGet() - { - RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/SignedOut.cshtml b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/SignedOut.cshtml deleted file mode 100644 index 92ede3a14521..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/SignedOut.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@page -@model SignedOutModel -@{ - ViewData["Title"] = "Signed out"; -} - -

@ViewData["Title"]

-

- You have successfully signed out. -

diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/SignedOut.cshtml.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/SignedOut.cshtml.cs deleted file mode 100644 index 48eac9f5d075..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/SignedOut.cshtml.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal -{ - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - [AllowAnonymous] - public class SignedOutModel : PageModel - { - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public IActionResult OnGet() - { - if (User.Identity.IsAuthenticated) - { - return LocalRedirect("~/"); - } - - return Page(); - } - } -} \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/_viewImports.cshtml b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/_viewImports.cshtml deleted file mode 100644 index 69cc620e9866..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/Account/_viewImports.cshtml +++ /dev/null @@ -1,2 +0,0 @@ -@using Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal -@namespace Microsoft.AspNetCore.Authentication.AzureAD.UI.Pages.Internal \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/_ViewStart.cshtml b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/_ViewStart.cshtml deleted file mode 100644 index c51721cd4009..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Areas/AzureAD/Pages/_ViewStart.cshtml +++ /dev/null @@ -1,13 +0,0 @@ -@using Microsoft.AspNetCore.Hosting -@using Microsoft.AspNetCore.Mvc.ViewEngines - -@inject IWebHostEnvironment Environment -@inject ICompositeViewEngine Engine - -@{ - var result = Engine.FindView(ViewContext, "_Layout", isMainPage: false); - if (result.Success) - { - Layout = "_Layout"; - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAccountControllerFeatureProvider.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAccountControllerFeatureProvider.cs deleted file mode 100644 index 41efc90242d9..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAccountControllerFeatureProvider.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using System.Collections.Generic; -using System.Reflection; -using Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureAD.Controllers.Internal; -using Microsoft.AspNetCore.Mvc.ApplicationParts; -using Microsoft.AspNetCore.Mvc.Controllers; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADAccountControllerFeatureProvider : IApplicationFeatureProvider, IApplicationFeatureProvider - { - public void PopulateFeature(IEnumerable parts, ControllerFeature feature) - { - if (!feature.Controllers.Contains(typeof(AccountController).GetTypeInfo())) - { - feature.Controllers.Add(typeof(AccountController).GetTypeInfo()); - } - } - } -} \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs deleted file mode 100644 index dcc93dd7dea3..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADAuthenticationBuilderExtensions.cs +++ /dev/null @@ -1,231 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using System.Collections.Generic; -using System.Linq; -using Microsoft.AspNetCore.Authentication.AzureAD.UI; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Mvc.ApplicationParts; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Extension methods to add Azure Active Directory Authentication to your application. - /// - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static class AzureADAuthenticationBuilderExtensions - { - /// - /// Adds JWT Bearer authentication to your app for Azure Active Directory Applications. - /// - /// The . - /// The to configure the - /// . - /// - /// The . - [Obsolete("This is obsolete and will be removed in a future version. Use AddMicrosoftWebApiAuthentication from Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static AuthenticationBuilder AddAzureADBearer(this AuthenticationBuilder builder, Action configureOptions) => - builder.AddAzureADBearer( - AzureADDefaults.BearerAuthenticationScheme, - AzureADDefaults.JwtBearerAuthenticationScheme, - configureOptions); - - /// - /// Adds JWT Bearer authentication to your app for Azure Active Directory Applications. - /// - /// The . - /// The identifier for the virtual scheme. - /// The identifier for the underlying JWT Bearer scheme. - /// The to configure the - /// . - /// - /// The . - [Obsolete("This is obsolete and will be removed in a future version. Use AddMicrosoftWebApiAuthentication from Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static AuthenticationBuilder AddAzureADBearer( - this AuthenticationBuilder builder, - string scheme, - string jwtBearerScheme, - Action configureOptions) - { - - builder.AddPolicyScheme(scheme, displayName: null, configureOptions: o => - { - o.ForwardDefault = jwtBearerScheme; - }); - - builder.Services.Configure(TryAddJwtBearerSchemeMapping(scheme, jwtBearerScheme)); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADOptionsConfiguration>()); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADOptionsValidation>()); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADJwtBearerOptionsConfiguration>()); - - builder.Services.Configure(scheme, configureOptions); - builder.AddJwtBearer(jwtBearerScheme, o => { }); - - return builder; - } - - /// - /// Adds Azure Active Directory Authentication to your application. - /// - /// The . - /// The to configure the - /// - /// - /// The . - [Obsolete("This is obsolete and will be removed in a future version. Use AddMicrosoftWebApiAuthentication from Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static AuthenticationBuilder AddAzureAD(this AuthenticationBuilder builder, Action configureOptions) => - builder.AddAzureAD( - AzureADDefaults.AuthenticationScheme, - AzureADDefaults.OpenIdScheme, - AzureADDefaults.CookieScheme, - AzureADDefaults.DisplayName, - configureOptions); - - /// - /// Adds Azure Active Directory Authentication to your application. - /// - /// The . - /// The identifier for the virtual scheme. - /// The identifier for the underlying Open ID Connect scheme. - /// The identifier for the underlying cookie scheme. - /// The display name for the scheme. - /// The to configure the - /// - /// - /// The . - [Obsolete("This is obsolete and will be removed in a future version. Use AddMicrosoftWebApiAuthentication from Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static AuthenticationBuilder AddAzureAD( - this AuthenticationBuilder builder, - string scheme, - string openIdConnectScheme, - string cookieScheme, - string displayName, - Action configureOptions) - { - AddAdditionalMvcApplicationParts(builder.Services); - builder.AddPolicyScheme(scheme, displayName, o => - { - o.ForwardDefault = cookieScheme; - o.ForwardChallenge = openIdConnectScheme; - }); - - builder.Services.Configure(TryAddOpenIDCookieSchemeMappings(scheme, openIdConnectScheme, cookieScheme)); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADOptionsConfiguration>()); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADOptionsValidation>()); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADOpenIdConnectOptionsConfiguration>()); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADCookieOptionsConfiguration>()); - - builder.Services.Configure(scheme, configureOptions); - - builder.AddOpenIdConnect(openIdConnectScheme, null, o => { }); - builder.AddCookie(cookieScheme, null, o => { }); - - return builder; - } - - private static Action TryAddJwtBearerSchemeMapping(string scheme, string jwtBearerScheme) - { - return TryAddMapping; - - void TryAddMapping(AzureADSchemeOptions o) - { - if (o.JwtBearerMappings.ContainsKey(scheme)) - { - throw new InvalidOperationException($"A scheme with the name '{scheme}' was already added."); - } - foreach (var mapping in o.JwtBearerMappings) - { - if (mapping.Value.JwtBearerScheme == jwtBearerScheme) - { - throw new InvalidOperationException( - $"The JSON Web Token Bearer scheme '{jwtBearerScheme}' can't be associated with the Azure Active Directory scheme '{scheme}'. " + - $"The JSON Web Token Bearer scheme '{jwtBearerScheme}' is already mapped to the Azure Active Directory scheme '{mapping.Key}'"); - } - } - o.JwtBearerMappings.Add(scheme, new AzureADSchemeOptions.JwtBearerSchemeMapping - { - JwtBearerScheme = jwtBearerScheme - }); - }; - } - - private static Action TryAddOpenIDCookieSchemeMappings(string scheme, string openIdConnectScheme, string cookieScheme) - { - return TryAddMapping; - - void TryAddMapping(AzureADSchemeOptions o) - { - if (o.OpenIDMappings.ContainsKey(scheme)) - { - throw new InvalidOperationException($"A scheme with the name '{scheme}' was already added."); - } - foreach (var mapping in o.OpenIDMappings) - { - if (mapping.Value.CookieScheme == cookieScheme) - { - throw new InvalidOperationException( - $"The cookie scheme '{cookieScheme}' can't be associated with the Azure Active Directory scheme '{scheme}'. " + - $"The cookie scheme '{cookieScheme}' is already mapped to the Azure Active Directory scheme '{mapping.Key}'"); - } - - if (mapping.Value.OpenIdConnectScheme == openIdConnectScheme) - { - throw new InvalidOperationException( - $"The Open ID Connect scheme '{openIdConnectScheme}' can't be associated with the Azure Active Directory scheme '{scheme}'. " + - $"The Open ID Connect scheme '{openIdConnectScheme}' is already mapped to the Azure Active Directory scheme '{mapping.Key}'"); - } - } - o.OpenIDMappings.Add(scheme, new AzureADSchemeOptions.AzureADOpenIDSchemeMapping - { - OpenIdConnectScheme = openIdConnectScheme, - CookieScheme = cookieScheme - }); - }; - } - - private static void AddAdditionalMvcApplicationParts(IServiceCollection services) - { - var additionalParts = GetAdditionalParts(); - var mvcBuilder = services - .AddMvc() - .ConfigureApplicationPartManager(apm => - { - foreach (var part in additionalParts) - { - if (!apm.ApplicationParts.Any(ap => HasSameName(ap.Name, part.Name))) - { - apm.ApplicationParts.Add(part); - } - } - - apm.FeatureProviders.Add(new AzureADAccountControllerFeatureProvider()); - }); - - bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal); - } - - private static IEnumerable GetAdditionalParts() - { - var thisAssembly = typeof(AzureADAuthenticationBuilderExtensions).Assembly; - var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true); - - foreach (var reference in relatedAssemblies) - { - yield return new CompiledRazorAssemblyPart(reference); - } - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADCookieOptionsConfiguration.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADCookieOptionsConfiguration.cs deleted file mode 100644 index 607d0f78ed8f..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADCookieOptionsConfiguration.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADCookieOptionsConfiguration : IConfigureNamedOptions - { - private readonly IOptions _schemeOptions; - private readonly IOptionsMonitor _AzureADOptions; - - public AzureADCookieOptionsConfiguration(IOptions schemeOptions, IOptionsMonitor AzureADOptions) - { - _schemeOptions = schemeOptions; - _AzureADOptions = AzureADOptions; - } - - public void Configure(string name, CookieAuthenticationOptions options) - { - var AzureADScheme = GetAzureADScheme(name); - if (AzureADScheme is null) - { - return; - } - - var AzureADOptions = _AzureADOptions.Get(AzureADScheme); - if (name != AzureADOptions.CookieSchemeName) - { - return; - } - - options.LoginPath = $"/AzureAD/Account/SignIn/{AzureADScheme}"; - options.LogoutPath = $"/AzureAD/Account/SignOut/{AzureADScheme}"; - options.AccessDeniedPath = "/AzureAD/Account/AccessDenied"; - options.Cookie.SameSite = SameSiteMode.None; - } - - public void Configure(CookieAuthenticationOptions options) - { - } - - private string GetAzureADScheme(string name) - { - foreach (var mapping in _schemeOptions.Value.OpenIDMappings) - { - if (mapping.Value.CookieScheme == name) - { - return mapping.Key; - } - } - - return null; - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADDefaults.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADDefaults.cs deleted file mode 100644 index c4d21967014f..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADDefaults.cs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI -{ - /// - /// Constants for different Azure Active Directory authentication components. - /// - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static class AzureADDefaults - { - /// - /// The scheme name for Open ID Connect when using - /// . - /// - public const string OpenIdScheme = "AzureADOpenID"; - - /// - /// The scheme name for cookies when using - /// . - /// - public const string CookieScheme = "AzureADCookie"; - - /// - /// The default scheme for Azure Active Directory Bearer. - /// - public const string BearerAuthenticationScheme = "AzureADBearer"; - - /// - /// The scheme name for JWT Bearer when using - /// . - /// - public const string JwtBearerAuthenticationScheme = "AzureADJwtBearer"; - - /// - /// The default scheme for Azure Active Directory. - /// - public const string AuthenticationScheme = "AzureAD"; - - /// - /// The display name for Azure Active Directory. - /// - public static readonly string DisplayName = "Azure Active Directory"; - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADJwtBearerOptionsConfiguration.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADJwtBearerOptionsConfiguration.cs deleted file mode 100644 index 5dbc09ee6398..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADJwtBearerOptionsConfiguration.cs +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.AzureAD.UI; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADJwtBearerOptionsConfiguration : IConfigureNamedOptions - { - private readonly IOptions _schemeOptions; - private readonly IOptionsMonitor _azureADOptions; - - public AzureADJwtBearerOptionsConfiguration( - IOptions schemeOptions, - IOptionsMonitor azureADOptions) - { - _schemeOptions = schemeOptions; - _azureADOptions = azureADOptions; - } - - public void Configure(string name, JwtBearerOptions options) - { - var azureADScheme = GetAzureADScheme(name); - if (azureADScheme is null) - { - return; - } - - var azureADOptions = _azureADOptions.Get(azureADScheme); - if (name != azureADOptions.JwtBearerSchemeName) - { - return; - } - - options.Audience = azureADOptions.ClientId; - options.Authority = new Uri(new Uri(azureADOptions.Instance), azureADOptions.TenantId).ToString(); - } - - public void Configure(JwtBearerOptions options) - { - } - - private string GetAzureADScheme(string name) - { - foreach (var mapping in _schemeOptions.Value.JwtBearerMappings) - { - if (mapping.Value.JwtBearerScheme == name) - { - return mapping.Key; - } - } - - return null; - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOpenIdConnectOptionsConfiguration.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOpenIdConnectOptionsConfiguration.cs deleted file mode 100644 index bea7de448088..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOpenIdConnectOptionsConfiguration.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADOpenIdConnectOptionsConfiguration : IConfigureNamedOptions - { - private readonly IOptions _schemeOptions; - private readonly IOptionsMonitor _azureADOptions; - - public AzureADOpenIdConnectOptionsConfiguration(IOptions schemeOptions, IOptionsMonitor azureADOptions) - { - _schemeOptions = schemeOptions; - _azureADOptions = azureADOptions; - } - - public void Configure(string name, OpenIdConnectOptions options) - { - var azureADScheme = GetAzureADScheme(name); - if (azureADScheme is null) - { - return; - } - - var azureADOptions = _azureADOptions.Get(azureADScheme); - if (name != azureADOptions.OpenIdConnectSchemeName) - { - return; - } - - options.ClientId = azureADOptions.ClientId; - options.ClientSecret = azureADOptions.ClientSecret; - options.Authority = new Uri(new Uri(azureADOptions.Instance), azureADOptions.TenantId).ToString(); - options.CallbackPath = azureADOptions.CallbackPath ?? options.CallbackPath; - options.SignedOutCallbackPath = azureADOptions.SignedOutCallbackPath ?? options.SignedOutCallbackPath; - options.SignInScheme = azureADOptions.CookieSchemeName; - options.UseTokenLifetime = true; - } - - private string GetAzureADScheme(string name) - { - foreach (var mapping in _schemeOptions.Value.OpenIDMappings) - { - if (mapping.Value.OpenIdConnectScheme == name) - { - return mapping.Key; - } - } - - return null; - } - - public void Configure(OpenIdConnectOptions options) - { - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptions.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptions.cs deleted file mode 100644 index e871449927ba..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptions.cs +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI -{ - /// - /// Options for configuring authentication using Azure Active Directory. - /// - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public class AzureADOptions - { - /// - /// Gets or sets the OpenID Connect authentication scheme to use for authentication with this instance - /// of Azure Active Directory authentication. - /// - public string OpenIdConnectSchemeName { get; set; } = OpenIdConnectDefaults.AuthenticationScheme; - - /// - /// Gets or sets the Cookie authentication scheme to use for sign in with this instance of - /// Azure Active Directory authentication. - /// - public string CookieSchemeName { get; set; } = CookieAuthenticationDefaults.AuthenticationScheme; - - /// - /// Gets or sets the Jwt bearer authentication scheme to use for validating access tokens for this - /// instance of Azure Active Directory Bearer authentication. - /// - public string JwtBearerSchemeName { get; internal set; } - - /// - /// Gets or sets the client Id. - /// - public string ClientId { get; set; } - - /// - /// Gets or sets the client secret. - /// - public string ClientSecret { get; set; } - - /// - /// Gets or sets the tenant Id. - /// - public string TenantId { get; set; } - - /// - /// Gets or sets the Azure Active Directory instance. - /// - public string Instance { get; set; } - - /// - /// Gets or sets the domain of the Azure Active Directory tenant. - /// - public string Domain { get; set; } - - /// - /// Gets or sets the sign in callback path. - /// - public string CallbackPath { get; set; } - - /// - /// Gets or sets the sign out callback path. - /// - public string SignedOutCallbackPath { get; set; } - - /// - /// Gets all the underlying authentication schemes. - /// - public string[] AllSchemes => new[] { CookieSchemeName, OpenIdConnectSchemeName }; - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptionsConfiguration.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptionsConfiguration.cs deleted file mode 100644 index ba91b5f59d18..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptionsConfiguration.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADOptionsConfiguration : IConfigureNamedOptions - { - private readonly IOptions _schemeOptions; - - public AzureADOptionsConfiguration(IOptions schemeOptions) - { - _schemeOptions = schemeOptions; - } - - public void Configure(string name, AzureADOptions options) - { - // This can be called because of someone configuring JWT or someone configuring - // Open ID + Cookie. - if (_schemeOptions.Value.OpenIDMappings.TryGetValue(name, out var webMapping)) - { - options.OpenIdConnectSchemeName = webMapping.OpenIdConnectScheme; - options.CookieSchemeName = webMapping.CookieScheme; - return; - } - if (_schemeOptions.Value.JwtBearerMappings.TryGetValue(name, out var mapping)) - { - options.JwtBearerSchemeName = mapping.JwtBearerScheme; - return; - } - } - - public void Configure(AzureADOptions options) - { - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptionsValidation.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptionsValidation.cs deleted file mode 100644 index 5edde29942a5..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADOptionsValidation.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADOptionsValidation : IValidateOptions - { - public ValidateOptionsResult Validate(string name, AzureADOptions options) - { - if (string.IsNullOrEmpty(options.Instance)) - { - return ValidateOptionsResult.Fail($"The '{nameof(AzureADOptions.Instance)}' option must be provided."); - } - - return ValidateOptionsResult.Success; - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADSchemeOptions.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADSchemeOptions.cs deleted file mode 100644 index 79ae769a459d..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/AzureADSchemeOptions.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System.Collections.Generic; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI -{ - internal class AzureADSchemeOptions - { - public IDictionary OpenIDMappings { get; set; } = new Dictionary(); - - public IDictionary JwtBearerMappings { get; set; } = new Dictionary(); - - public class AzureADOpenIDSchemeMapping - { - public string OpenIdConnectScheme { get; set; } - public string CookieScheme { get; set; } - } - - public class JwtBearerSchemeMapping - { - public string JwtBearerScheme { get; set; } - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj deleted file mode 100644 index 86f2ac73d86d..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - ASP.NET Core Azure Active Directory Integration provides components for easily integrating Azure Active Directory authentication within your ASP.NET Core application. - Precompiled views assembly for the ASP.NET Core Azure Active Directory Integration package. - $(DefaultNetCoreTargetFramework) - aspnetcore;authentication;AzureAD - true - Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core - true - - - - - - - - - - diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Properties/AssemblyInfo.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Properties/AssemblyInfo.cs deleted file mode 100644 index aaf76791a3a5..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Authentication.AzureAD.UI.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/PublicAPI.Shipped.txt b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/PublicAPI.Shipped.txt deleted file mode 100644 index c6696c73a02c..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/PublicAPI.Shipped.txt +++ /dev/null @@ -1,47 +0,0 @@ -#nullable enable -Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADDefaults -Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions -Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.AzureADOptions() -> void -Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.AccessDeniedModel -Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.AccessDeniedModel.AccessDeniedModel() -> void -Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.AccessDeniedModel.OnGet() -> void -Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.ErrorModel -Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.ErrorModel.ErrorModel() -> void -Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.ErrorModel.OnGet() -> void -Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.ErrorModel.ShowRequestId.get -> bool -Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.SignedOutModel -Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.SignedOutModel.SignedOutModel() -> void -Microsoft.AspNetCore.Authentication.AzureADAuthenticationBuilderExtensions -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.AllSchemes.get -> string[] -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.CallbackPath.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.CallbackPath.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.ClientId.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.ClientId.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.ClientSecret.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.ClientSecret.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.CookieSchemeName.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.CookieSchemeName.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.Domain.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.Domain.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.Instance.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.Instance.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.JwtBearerSchemeName.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.OpenIdConnectSchemeName.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.OpenIdConnectSchemeName.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.SignedOutCallbackPath.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.SignedOutCallbackPath.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.TenantId.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADOptions.TenantId.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.ErrorModel.RequestId.get -> string -~Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.ErrorModel.RequestId.set -> void -~Microsoft.AspNetCore.Authentication.AzureAD.UI.Internal.SignedOutModel.OnGet() -> Microsoft.AspNetCore.Mvc.IActionResult -~const Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADDefaults.AuthenticationScheme = "AzureAD" -> string -~const Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADDefaults.BearerAuthenticationScheme = "AzureADBearer" -> string -~const Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADDefaults.CookieScheme = "AzureADCookie" -> string -~const Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADDefaults.JwtBearerAuthenticationScheme = "AzureADJwtBearer" -> string -~const Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADDefaults.OpenIdScheme = "AzureADOpenID" -> string -~static Microsoft.AspNetCore.Authentication.AzureADAuthenticationBuilderExtensions.AddAzureAD(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, System.Action configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder -~static Microsoft.AspNetCore.Authentication.AzureADAuthenticationBuilderExtensions.AddAzureAD(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string scheme, string openIdConnectScheme, string cookieScheme, string displayName, System.Action configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder -~static Microsoft.AspNetCore.Authentication.AzureADAuthenticationBuilderExtensions.AddAzureADBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, System.Action configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder -~static Microsoft.AspNetCore.Authentication.AzureADAuthenticationBuilderExtensions.AddAzureADBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string scheme, string jwtBearerScheme, System.Action configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder -~static readonly Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureADDefaults.DisplayName -> string diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/PublicAPI.Unshipped.txt b/src/Azure/AzureAD/Authentication.AzureAD.UI/src/PublicAPI.Unshipped.txt deleted file mode 100644 index 7dc5c58110bf..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/src/PublicAPI.Unshipped.txt +++ /dev/null @@ -1 +0,0 @@ -#nullable enable diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/AzureADAuthenticationBuilderExtensionsTests.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/test/AzureADAuthenticationBuilderExtensionsTests.cs deleted file mode 100644 index 6a31d3477ec2..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/AzureADAuthenticationBuilderExtensionsTests.cs +++ /dev/null @@ -1,509 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.AzureAD.UI; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication -{ - public class AzureADAuthenticationBuilderExtensionsTests - { - [Fact] - public void AddAzureAD_AddsAllAuthenticationHandlers() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureAD(o => { }); - var provider = services.BuildServiceProvider(); - - // Assert - Assert.NotNull(provider.GetService()); - Assert.NotNull(provider.GetService()); - Assert.NotNull(provider.GetService()); - } - - [Fact] - public void AddAzureAD_ConfiguresAllOptions() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureAD(o => - { - o.Instance = "https://login.microsoftonline.com"; - o.ClientId = "ClientId"; - o.ClientSecret = "ClientSecret"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.TenantId = "Common"; - }); - var provider = services.BuildServiceProvider(); - - // Assert - var azureADOptionsMonitor = provider.GetService>(); - Assert.NotNull(azureADOptionsMonitor); - var azureADOptions = azureADOptionsMonitor.Get(AzureADDefaults.AuthenticationScheme); - Assert.Equal(AzureADDefaults.OpenIdScheme, azureADOptions.OpenIdConnectSchemeName); - Assert.Equal(AzureADDefaults.CookieScheme, azureADOptions.CookieSchemeName); - Assert.Equal("https://login.microsoftonline.com", azureADOptions.Instance); - Assert.Equal("ClientId", azureADOptions.ClientId); - Assert.Equal("ClientSecret", azureADOptions.ClientSecret); - Assert.Equal("/signin-oidc", azureADOptions.CallbackPath); - Assert.Equal("domain.onmicrosoft.com", azureADOptions.Domain); - - var openIdOptionsMonitor = provider.GetService>(); - Assert.NotNull(openIdOptionsMonitor); - var openIdOptions = openIdOptionsMonitor.Get(AzureADDefaults.OpenIdScheme); - Assert.Equal("ClientId", openIdOptions.ClientId); - Assert.Equal($"https://login.microsoftonline.com/Common", openIdOptions.Authority); - Assert.True(openIdOptions.UseTokenLifetime); - Assert.Equal("/signin-oidc", openIdOptions.CallbackPath); - Assert.Equal(AzureADDefaults.CookieScheme, openIdOptions.SignInScheme); - - var cookieAuthenticationOptionsMonitor = provider.GetService>(); - Assert.NotNull(cookieAuthenticationOptionsMonitor); - var cookieAuthenticationOptions = cookieAuthenticationOptionsMonitor.Get(AzureADDefaults.CookieScheme); - Assert.Equal("/AzureAD/Account/SignIn/AzureAD", cookieAuthenticationOptions.LoginPath); - Assert.Equal("/AzureAD/Account/SignOut/AzureAD", cookieAuthenticationOptions.LogoutPath); - Assert.Equal("/AzureAD/Account/AccessDenied", cookieAuthenticationOptions.AccessDeniedPath); - Assert.Equal(SameSiteMode.None, cookieAuthenticationOptions.Cookie.SameSite); - } - - [Fact] - public void AddAzureAD_AllowsOverridingCookiesAndOpenIdConnectSettings() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureAD(o => - { - o.Instance = "https://login.microsoftonline.com"; - o.ClientId = "ClientId"; - o.ClientSecret = "ClientSecret"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.TenantId = "Common"; - }); - - services.Configure(AzureADDefaults.OpenIdScheme, o => - { - o.Authority = "https://overriden.com"; - }); - - services.Configure(AzureADDefaults.CookieScheme, o => - { - o.AccessDeniedPath = "/Overriden"; - }); - - var provider = services.BuildServiceProvider(); - - // Assert - var openIdOptionsMonitor = provider.GetService>(); - Assert.NotNull(openIdOptionsMonitor); - var openIdOptions = openIdOptionsMonitor.Get(AzureADDefaults.OpenIdScheme); - Assert.Equal("ClientId", openIdOptions.ClientId); - Assert.Equal($"https://overriden.com", openIdOptions.Authority); - - var cookieAuthenticationOptionsMonitor = provider.GetService>(); - Assert.NotNull(cookieAuthenticationOptionsMonitor); - var cookieAuthenticationOptions = cookieAuthenticationOptionsMonitor.Get(AzureADDefaults.CookieScheme); - Assert.Equal("/AzureAD/Account/SignIn/AzureAD", cookieAuthenticationOptions.LoginPath); - Assert.Equal("/Overriden", cookieAuthenticationOptions.AccessDeniedPath); - } - - [Fact] - public void AddAzureAD_RegisteringAddCookiesAndAddOpenIdConnectHasNoImpactOnAzureAAExtensions() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddOpenIdConnect() - .AddCookie() - .AddAzureAD(o => - { - o.Instance = "https://login.microsoftonline.com"; - o.ClientId = "ClientId"; - o.ClientSecret = "ClientSecret"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.TenantId = "Common"; - }); - - services.Configure(AzureADDefaults.OpenIdScheme, o => - { - o.Authority = "https://overriden.com"; - }); - - services.Configure(AzureADDefaults.CookieScheme, o => - { - o.AccessDeniedPath = "/Overriden"; - }); - - var provider = services.BuildServiceProvider(); - - // Assert - var openIdOptionsMonitor = provider.GetService>(); - Assert.NotNull(openIdOptionsMonitor); - var openIdOptions = openIdOptionsMonitor.Get(AzureADDefaults.OpenIdScheme); - Assert.Equal("ClientId", openIdOptions.ClientId); - Assert.Equal($"https://overriden.com", openIdOptions.Authority); - - var cookieAuthenticationOptionsMonitor = provider.GetService>(); - Assert.NotNull(cookieAuthenticationOptionsMonitor); - var cookieAuthenticationOptions = cookieAuthenticationOptionsMonitor.Get(AzureADDefaults.CookieScheme); - Assert.Equal("/AzureAD/Account/SignIn/AzureAD", cookieAuthenticationOptions.LoginPath); - Assert.Equal("/Overriden", cookieAuthenticationOptions.AccessDeniedPath); - } - - [Fact] - public void AddAzureAD_ThrowsForDuplicatedSchemes() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureAD(o => { }) - .AddAzureAD(o => { }); - - var provider = services.BuildServiceProvider(); - var azureADOptionsMonitor = provider.GetService>(); - - // Act & Assert - var exception = Assert.Throws( - () => azureADOptionsMonitor.Get(AzureADDefaults.AuthenticationScheme)); - - Assert.Equal("A scheme with the name 'AzureAD' was already added.", exception.Message); - } - - [Fact] - public void AddAzureAD_ThrowsWhenOpenIdSchemeIsAlreadyInUse() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureAD(o => { }) - .AddAzureAD("Custom", AzureADDefaults.OpenIdScheme, "Cookie", null, o => { }); - - var provider = services.BuildServiceProvider(); - var azureADOptionsMonitor = provider.GetService>(); - - var expectedMessage = $"The Open ID Connect scheme 'AzureADOpenID' can't be associated with the Azure Active Directory scheme 'Custom'. " + - "The Open ID Connect scheme 'AzureADOpenID' is already mapped to the Azure Active Directory scheme 'AzureAD'"; - - // Act & Assert - var exception = Assert.Throws( - () => azureADOptionsMonitor.Get(AzureADDefaults.AuthenticationScheme)); - - Assert.Equal(expectedMessage, exception.Message); - } - - [Fact] - public void AddAzureAD_ThrowsWhenCookieSchemeIsAlreadyInUse() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureAD(o => { }) - .AddAzureAD("Custom", "OpenID", AzureADDefaults.CookieScheme, null, o => { }); - - var provider = services.BuildServiceProvider(); - var azureADOptionsMonitor = provider.GetService>(); - - var expectedMessage = $"The cookie scheme 'AzureADCookie' can't be associated with the Azure Active Directory scheme 'Custom'. " + - "The cookie scheme 'AzureADCookie' is already mapped to the Azure Active Directory scheme 'AzureAD'"; - - // Act & Assert - var exception = Assert.Throws( - () => azureADOptionsMonitor.Get(AzureADDefaults.AuthenticationScheme)); - - Assert.Equal(expectedMessage, exception.Message); - } - - [Fact] - public void AddAzureAD_ThrowsWhenInstanceIsNotSet() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureAD(o => { }); - - var provider = services.BuildServiceProvider(); - var azureADOptionsMonitor = provider.GetService>(); - - var expectedMessage = "The 'Instance' option must be provided."; - - // Act & Assert - var exception = Assert.Throws( - () => azureADOptionsMonitor.Get(AzureADDefaults.AuthenticationScheme)); - - Assert.Contains(expectedMessage, exception.Failures); - } - - [Fact] - public void AddAzureAD_SkipsOptionsValidationForNonAzureCookies() - { - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureAD(o => { }) - .AddCookie("other"); - - var provider = services.BuildServiceProvider(); - var cookieAuthOptions = provider.GetService>(); - - Assert.NotNull(cookieAuthOptions.Get("other")); - } - - [Fact] - public void AddAzureADBearer_AddsAllAuthenticationHandlers() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureADBearer(o => { }); - var provider = services.BuildServiceProvider(); - - // Assert - Assert.NotNull(provider.GetService()); - Assert.NotNull(provider.GetService()); - } - - [Fact] - public void AddAzureADBearer_ConfiguresAllOptions() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureADBearer(o => - { - o.Instance = "https://login.microsoftonline.com/"; - o.ClientId = "ClientId"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.TenantId = "TenantId"; - }); - var provider = services.BuildServiceProvider(); - - // Assert - var azureADOptionsMonitor = provider.GetService>(); - Assert.NotNull(azureADOptionsMonitor); - var options = azureADOptionsMonitor.Get(AzureADDefaults.BearerAuthenticationScheme); - Assert.Equal(AzureADDefaults.JwtBearerAuthenticationScheme, options.JwtBearerSchemeName); - Assert.Equal("https://login.microsoftonline.com/", options.Instance); - Assert.Equal("ClientId", options.ClientId); - Assert.Equal("domain.onmicrosoft.com", options.Domain); - - var bearerOptionsMonitor = provider.GetService>(); - Assert.NotNull(bearerOptionsMonitor); - var bearerOptions = bearerOptionsMonitor.Get(AzureADDefaults.JwtBearerAuthenticationScheme); - Assert.Equal("ClientId", bearerOptions.Audience); - Assert.Equal($"https://login.microsoftonline.com/TenantId", bearerOptions.Authority); - } - - [Fact] - public void AddAzureADBearer_CanOverrideJwtBearerOptionsConfiguration() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureADBearer(o => - { - o.Instance = "https://login.microsoftonline.com/"; - o.ClientId = "ClientId"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.TenantId = "TenantId"; - }); - - services.Configure(AzureADDefaults.JwtBearerAuthenticationScheme, o => - { - o.Audience = "http://overriden.com"; - }); - - var provider = services.BuildServiceProvider(); - - // Assert - var bearerOptionsMonitor = provider.GetService>(); - Assert.NotNull(bearerOptionsMonitor); - var bearerOptions = bearerOptionsMonitor.Get(AzureADDefaults.JwtBearerAuthenticationScheme); - Assert.Equal("http://overriden.com", bearerOptions.Audience); - Assert.Equal($"https://login.microsoftonline.com/TenantId", bearerOptions.Authority); - } - - [Fact] - public void AddAzureADBearer_RegisteringJwtBearerHasNoImpactOnAzureAAExtensions() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddJwtBearer() - .AddAzureADBearer(o => - { - o.Instance = "https://login.microsoftonline.com/"; - o.ClientId = "ClientId"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.TenantId = "TenantId"; - }); - - services.Configure(AzureADDefaults.JwtBearerAuthenticationScheme, o => - { - o.Audience = "http://overriden.com"; - }); - - var provider = services.BuildServiceProvider(); - - // Assert - var bearerOptionsMonitor = provider.GetService>(); - Assert.NotNull(bearerOptionsMonitor); - var bearerOptions = bearerOptionsMonitor.Get(AzureADDefaults.JwtBearerAuthenticationScheme); - Assert.Equal("http://overriden.com", bearerOptions.Audience); - Assert.Equal($"https://login.microsoftonline.com/TenantId", bearerOptions.Authority); - } - - [Fact] - public void AddAzureADBearer_ThrowsForDuplicatedSchemes() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureADBearer(o => { }) - .AddAzureADBearer(o => { }); - - var provider = services.BuildServiceProvider(); - var azureADOptionsMonitor = provider.GetService>(); - - // Act & Assert - var exception = Assert.Throws( - () => azureADOptionsMonitor.Get(AzureADDefaults.AuthenticationScheme)); - - Assert.Equal("A scheme with the name 'AzureADBearer' was already added.", exception.Message); - } - - [Fact] - public void AddAzureADBearer_ThrowsWhenBearerSchemeIsAlreadyInUse() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureADBearer(o => { }) - .AddAzureADBearer("Custom", AzureADDefaults.JwtBearerAuthenticationScheme, o => { }); - - var provider = services.BuildServiceProvider(); - var azureADOptionsMonitor = provider.GetService>(); - - var expectedMessage = $"The JSON Web Token Bearer scheme 'AzureADJwtBearer' can't be associated with the Azure Active Directory scheme 'Custom'. " + - "The JSON Web Token Bearer scheme 'AzureADJwtBearer' is already mapped to the Azure Active Directory scheme 'AzureADBearer'"; - - // Act & Assert - var exception = Assert.Throws( - () => azureADOptionsMonitor.Get(AzureADDefaults.AuthenticationScheme)); - - Assert.Equal(expectedMessage, exception.Message); - } - - [Fact] - public void AddAzureADBearer_ThrowsWhenInstanceIsNotSet() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureADBearer(o => { }); - - var provider = services.BuildServiceProvider(); - var azureADOptionsMonitor = provider.GetService>(); - - var expectedMessage = "The 'Instance' option must be provided."; - - // Act & Assert - var exception = Assert.Throws( - () => azureADOptionsMonitor.Get(AzureADDefaults.AuthenticationScheme)); - - Assert.Contains(expectedMessage, exception.Failures); - } - - [Fact] - public void AddAzureADBearer_SkipsOptionsValidationForNonAzureCookies() - { - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureADBearer(o => { }) - .AddJwtBearer("other", o => { }); - - var provider = services.BuildServiceProvider(); - var jwtOptions = provider.GetService>(); - - Assert.NotNull(jwtOptions.Get("other")); - } - - [Fact] - public void AddAzureAD_SkipsOptionsValidationForNonAzureOpenIdConnect() - { - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureAD(o => { }) - .AddOpenIdConnect("other", null, o => - { - o.ClientId = "ClientId"; - o.Authority = "https://authority.com"; - }); - - var provider = services.BuildServiceProvider(); - var openIdConnectOptions = provider.GetService>(); - - Assert.NotNull(openIdConnectOptions.Get("other")); - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/Controllers/AccountControllerTests.cs b/src/Azure/AzureAD/Authentication.AzureAD.UI/test/Controllers/AccountControllerTests.cs deleted file mode 100644 index 8d7ab6b3daf5..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/Controllers/AccountControllerTests.cs +++ /dev/null @@ -1,281 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.AspNetCore.Mvc.Routing; -using Microsoft.AspNetCore.Routing; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using Moq; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.UI.AzureAD.Controllers.Internal -{ - public class AccountControllerTests - { - [Fact] - public void SignInNoScheme_ChallengesAADAzureADDefaultScheme() - { - // Arrange - var controller = new AccountController( - new OptionsMonitor(AzureADDefaults.AuthenticationScheme, new AzureADOptions() - { - OpenIdConnectSchemeName = AzureADDefaults.OpenIdScheme, - CookieSchemeName = AzureADDefaults.CookieScheme - })) - { - Url = new TestUrlHelper("~/", "https://localhost/") - }; - - // Act - var result = controller.SignIn(null); - - // Assert - var challenge = Assert.IsAssignableFrom(result); - var challengedScheme = Assert.Single(challenge.AuthenticationSchemes); - Assert.Equal(AzureADDefaults.AuthenticationScheme, challengedScheme); - Assert.NotNull(challenge.Properties.RedirectUri); - Assert.Equal("https://localhost/", challenge.Properties.RedirectUri); - } - - [Fact] - public void SignInProvidedScheme_ChallengesCustomScheme() - { - // Arrange - var controller = new AccountController(new OptionsMonitor("Custom", new AzureADOptions())); - controller.Url = new TestUrlHelper("~/", "https://localhost/"); - - // Act - var result = controller.SignIn("Custom"); - - // Assert - var challenge = Assert.IsAssignableFrom(result); - var challengedScheme = Assert.Single(challenge.AuthenticationSchemes); - Assert.Equal("Custom", challengedScheme); - } - - private ClaimsPrincipal CreateAuthenticatedPrincipal(string scheme) => - new ClaimsPrincipal(new ClaimsIdentity(scheme)); - - private static ControllerContext CreateControllerContext(ClaimsPrincipal principal = null) - { - principal = principal ?? new ClaimsPrincipal(new ClaimsIdentity()); - var mock = new Mock(); - mock.Setup(authS => authS.AuthenticateAsync(It.IsAny(), It.IsAny())) - .ReturnsAsync( - (ctx, scheme) => - { - if (principal.Identity.IsAuthenticated) - { - return AuthenticateResult.Success(new AuthenticationTicket(principal, scheme)); - } - else - { - return AuthenticateResult.NoResult(); - } - }); - return new ControllerContext() - { - HttpContext = new DefaultHttpContext() - { - RequestServices = new ServiceCollection() - .AddSingleton(mock.Object) - .BuildServiceProvider() - } - }; - } - - [Fact] - public void SignOutNoScheme_SignsOutDefaultCookiesAndDefaultOpenIDConnectAADAzureADSchemesAsync() - { - // Arrange - var options = new AzureADOptions() - { - CookieSchemeName = AzureADDefaults.CookieScheme, - OpenIdConnectSchemeName = AzureADDefaults.OpenIdScheme - }; - - var controllerContext = CreateControllerContext( - CreateAuthenticatedPrincipal(AzureADDefaults.AuthenticationScheme)); - - var descriptor = new PageActionDescriptor() - { - AttributeRouteInfo = new AttributeRouteInfo() - { - Template = "/Account/SignedOut" - } - }; - var controller = new AccountController(new OptionsMonitor(AzureADDefaults.AuthenticationScheme, options)) - { - Url = new TestUrlHelper( - controllerContext.HttpContext, - new RouteData(), - descriptor, - "/Account/SignedOut", - "https://localhost/Account/SignedOut"), - ControllerContext = new ControllerContext() - { - HttpContext = controllerContext.HttpContext - } - }; - controller.Request.Scheme = "https"; - - // Act - var result = controller.SignOut(null); - - // Assert - var signOut = Assert.IsAssignableFrom(result); - Assert.Equal(new[] { AzureADDefaults.CookieScheme, AzureADDefaults.OpenIdScheme }, signOut.AuthenticationSchemes); - Assert.NotNull(signOut.Properties.RedirectUri); - Assert.Equal("https://localhost/Account/SignedOut", signOut.Properties.RedirectUri); - } - - [Fact] - public void SignOutProvidedScheme_SignsOutCustomCookiesAndCustomOpenIDConnectAADAzureADSchemesAsync() - { - // Arrange - var options = new AzureADOptions() - { - CookieSchemeName = "Cookie", - OpenIdConnectSchemeName = "OpenID" - }; - - var controllerContext = CreateControllerContext( - CreateAuthenticatedPrincipal(AzureADDefaults.AuthenticationScheme)); - var descriptor = new PageActionDescriptor() - { - AttributeRouteInfo = new AttributeRouteInfo() - { - Template = "/Account/SignedOut" - } - }; - - var controller = new AccountController(new OptionsMonitor("Custom", options)) - { - Url = new TestUrlHelper( - controllerContext.HttpContext, - new RouteData(), - descriptor, - "/Account/SignedOut", - "https://localhost/Account/SignedOut"), - ControllerContext = new ControllerContext() - { - HttpContext = controllerContext.HttpContext - } - }; - controller.Request.Scheme = "https"; - - // Act - var result = controller.SignOut("Custom"); - - // Assert - var signOut = Assert.IsAssignableFrom(result); - Assert.Equal(new[] { "Cookie", "OpenID" }, signOut.AuthenticationSchemes); - } - - private class OptionsMonitor : IOptionsMonitor - { - public OptionsMonitor(string scheme, AzureADOptions options) - { - Scheme = scheme; - Options = options; - } - - public AzureADOptions CurrentValue => throw new NotImplementedException(); - - public string Scheme { get; } - public AzureADOptions Options { get; } - - public AzureADOptions Get(string name) - { - if (name == Scheme) - { - return Options; - } - - return null; - } - - public IDisposable OnChange(Action listener) - { - throw new NotImplementedException(); - } - } - - private class TestUrlHelper : IUrlHelper - { - public TestUrlHelper(string contentPath, string url) - { - ContentPath = contentPath; - Url = url; - } - - public TestUrlHelper( - HttpContext context, - RouteData routeData, - ActionDescriptor descriptor, - string contentPath, - string url) - { - HttpContext = context; - RouteData = routeData; - ActionDescriptor = descriptor; - ContentPath = contentPath; - Url = url; - } - - public ActionContext ActionContext => - new ActionContext(HttpContext, RouteData, ActionDescriptor); - - public string ContentPath { get; } - public string Url { get; } - public HttpContext HttpContext { get; } - public RouteData RouteData { get; } - public ActionDescriptor ActionDescriptor { get; } - - public string Action(UrlActionContext actionContext) - { - throw new NotImplementedException(); - } - - public string Content(string contentPath) - { - if (ContentPath == contentPath) - { - return Url; - } - return ""; - } - - public bool IsLocalUrl(string url) - { - throw new NotImplementedException(); - } - - public string Link(string routeName, object values) - { - throw new NotImplementedException(); - } - - public string RouteUrl(UrlRouteContext routeContext) - { - if (routeContext.Values is RouteValueDictionary dicionary && - dicionary.TryGetValue("page", out var page) && - page is string pagePath && - ContentPath == pagePath) - { - return Url; - } - - return null; - } - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/Microsoft.AspNetCore.Authentication.AzureAD.UI.Test.csproj b/src/Azure/AzureAD/Authentication.AzureAD.UI/test/Microsoft.AspNetCore.Authentication.AzureAD.UI.Test.csproj deleted file mode 100644 index b5daa435a535..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/Microsoft.AspNetCore.Authentication.AzureAD.UI.Test.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - $(DefaultNetCoreTargetFramework) - Microsoft.AspNetCore.Authentication.AzureAD.UI - - $(NoWarn);CS0618 - - - - - PreserveNewest - - - - - - - - diff --git a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/xunit.runner.json b/src/Azure/AzureAD/Authentication.AzureAD.UI/test/xunit.runner.json deleted file mode 100644 index 42db7ef95e94..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureAD.UI/test/xunit.runner.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "shadowCopy": false -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Controllers/AccountController.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Controllers/AccountController.cs deleted file mode 100644 index 387ae4c6b076..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Controllers/AccountController.cs +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2C.Controllers.Internal -{ - [NonController] - [AllowAnonymous] - [Area("AzureADB2C")] - [Route("[area]/[controller]/[action]")] - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AccountController : Controller - { - private readonly IOptionsMonitor _options; - - public AccountController(IOptionsMonitor AzureADB2COptions) - { - _options = AzureADB2COptions; - } - - [HttpGet("{scheme?}")] - public IActionResult SignIn([FromRoute] string scheme) - { - scheme = scheme ?? AzureADB2CDefaults.AuthenticationScheme; - var redirectUrl = Url.Content("~/"); - return Challenge( - new AuthenticationProperties { RedirectUri = redirectUrl }, - scheme); - } - - [HttpGet("{scheme?}")] - public IActionResult ResetPassword([FromRoute] string scheme) - { - scheme = scheme ?? AzureADB2CDefaults.AuthenticationScheme; - var options = _options.Get(scheme); - - var redirectUrl = Url.Content("~/"); - var properties = new AuthenticationProperties { RedirectUri = redirectUrl }; - properties.Items[AzureADB2CDefaults.PolicyKey] = options.ResetPasswordPolicyId; - return Challenge(properties, scheme); - } - - [HttpGet("{scheme?}")] - public async Task EditProfile([FromRoute] string scheme) - { - scheme = scheme ?? AzureADB2CDefaults.AuthenticationScheme; - var authenticated = await HttpContext.AuthenticateAsync(scheme); - if (!authenticated.Succeeded) - { - return Challenge(scheme); - } - - var options = _options.Get(scheme); - - var redirectUrl = Url.Content("~/"); - var properties = new AuthenticationProperties { RedirectUri = redirectUrl }; - properties.Items[AzureADB2CDefaults.PolicyKey] = options.EditProfilePolicyId; - return Challenge(properties, scheme); - } - - [HttpGet("{scheme?}")] - public async Task SignOut([FromRoute] string scheme) - { - scheme = scheme ?? AzureADB2CDefaults.AuthenticationScheme; - var authenticated = await HttpContext.AuthenticateAsync(scheme); - if (!authenticated.Succeeded) - { - return Challenge(scheme); - } - - var options = _options.Get(scheme); - - var callbackUrl = Url.Page("/Account/SignedOut", pageHandler: null, values: null, protocol: Request.Scheme); - return SignOut( - new AuthenticationProperties { RedirectUri = callbackUrl }, - options.AllSchemes); - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/AccessDenied.cshtml b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/AccessDenied.cshtml deleted file mode 100644 index 2084bbf67a41..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/AccessDenied.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@page -@model AccessDeniedModel -@{ - ViewData["Title"] = "Access denied"; -} - -
-

@ViewData["Title"]

-

You do not have access to this resource.

-
diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/AccessDenied.cshtml.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/AccessDenied.cshtml.cs deleted file mode 100644 index 62bae46b08a2..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/AccessDenied.cshtml.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal -{ - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - [AllowAnonymous] - public class AccessDeniedModel : PageModel - { - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public void OnGet() - { - } - } -} \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml deleted file mode 100644 index 046fdddb5695..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml +++ /dev/null @@ -1,23 +0,0 @@ -@page -@model ErrorModel -@{ - ViewData["Title"] = "Error"; -} - -

Error.

-

An error occurred while processing your request.

- -@if (Model.ShowRequestId) -{ -

- Request ID: @Model.RequestId -

-} - -

Development Mode

-

- Swapping to Development environment will display more detailed information about the error that occurred. -

-

- Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application. -

diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml.cs deleted file mode 100644 index 313cb372d363..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/Error.cshtml.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System.Diagnostics; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal -{ - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - [AllowAnonymous] - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] - public class ErrorModel : PageModel - { - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public string RequestId { get; set; } - - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public void OnGet() - { - RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/SignedOut.cshtml b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/SignedOut.cshtml deleted file mode 100644 index 13e90c4216ba..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/SignedOut.cshtml +++ /dev/null @@ -1,10 +0,0 @@ -@page -@model SignedOutModel -@{ - ViewData["Title"] = "Signed out"; -} - -

@ViewData["Title"]

-

- You have successfully signed out. -

diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/SignedOut.cshtml.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/SignedOut.cshtml.cs deleted file mode 100644 index 5d8a011e8b0b..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/SignedOut.cshtml.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal -{ - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - [AllowAnonymous] - public class SignedOutModel : PageModel - { - /// - /// This API supports infrastructure and is not intended to be used - /// directly from your code.This API may change or be removed in future releases - /// - public IActionResult OnGet() - { - if (User.Identity.IsAuthenticated) - { - return LocalRedirect("~/"); - } - - return Page(); - } - } -} \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/_viewImports.cshtml b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/_viewImports.cshtml deleted file mode 100644 index 655317c358af..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/Account/_viewImports.cshtml +++ /dev/null @@ -1,2 +0,0 @@ -@using Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal -@namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Pages.Internal \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/_ViewStart.cshtml b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/_ViewStart.cshtml deleted file mode 100644 index c51721cd4009..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Areas/AzureADB2C/Pages/_ViewStart.cshtml +++ /dev/null @@ -1,13 +0,0 @@ -@using Microsoft.AspNetCore.Hosting -@using Microsoft.AspNetCore.Mvc.ViewEngines - -@inject IWebHostEnvironment Environment -@inject ICompositeViewEngine Engine - -@{ - var result = Engine.FindView(ViewContext, "_Layout", isMainPage: false); - if (result.Success) - { - Layout = "_Layout"; - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CAccountControllerFeatureProvider.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CAccountControllerFeatureProvider.cs deleted file mode 100644 index b6b639a796aa..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CAccountControllerFeatureProvider.cs +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using System.Collections.Generic; -using System.Reflection; -using Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2C.Controllers.Internal; -using Microsoft.AspNetCore.Mvc.ApplicationParts; -using Microsoft.AspNetCore.Mvc.Controllers; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADB2CAccountControllerFeatureProvider : IApplicationFeatureProvider, IApplicationFeatureProvider - { - public void PopulateFeature(IEnumerable parts, ControllerFeature feature) - { - if (!feature.Controllers.Contains(typeof(AccountController).GetTypeInfo())) - { - feature.Controllers.Add(typeof(AccountController).GetTypeInfo()); - } - } - } -} \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CCookieOptionsConfiguration.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CCookieOptionsConfiguration.cs deleted file mode 100644 index 257e809631bd..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CCookieOptionsConfiguration.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADB2CCookieOptionsConfiguration : IConfigureNamedOptions - { - private readonly IOptions _schemeOptions; - private readonly IOptionsMonitor _azureADB2COptions; - - public AzureADB2CCookieOptionsConfiguration(IOptions schemeOptions, IOptionsMonitor azureADB2COptions) - { - _schemeOptions = schemeOptions; - _azureADB2COptions = azureADB2COptions; - } - - public void Configure(string name, CookieAuthenticationOptions options) - { - var azureADB2CScheme = GetAzureADB2CScheme(name); - var azureADB2COptions = _azureADB2COptions.Get(azureADB2CScheme); - if (name != azureADB2COptions.CookieSchemeName) - { - return; - } - - options.LoginPath = $"/AzureADB2C/Account/SignIn/{azureADB2CScheme}"; - options.LogoutPath = $"/AzureADB2C/Account/SignOut/{azureADB2CScheme}"; - options.AccessDeniedPath = "/AzureADB2C/Account/AccessDenied"; - options.Cookie.SameSite = SameSiteMode.None; - } - - public void Configure(CookieAuthenticationOptions options) - { - } - - private string GetAzureADB2CScheme(string name) - { - foreach (var mapping in _schemeOptions.Value.OpenIDMappings) - { - if (mapping.Value.CookieScheme == name) - { - return mapping.Key; - } - } - - return null; - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CJwtBearerOptionsConfiguration.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CJwtBearerOptionsConfiguration.cs deleted file mode 100644 index 2be6706b2845..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2CJwtBearerOptionsConfiguration.cs +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Authentication.AzureADB2C.UI; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADB2CJwtBearerOptionsConfiguration : IConfigureNamedOptions - { - private readonly IOptions _schemeOptions; - private readonly IOptionsMonitor _azureADB2COptions; - - public AzureADB2CJwtBearerOptionsConfiguration( - IOptions schemeOptions, - IOptionsMonitor azureADB2COptions) - { - _schemeOptions = schemeOptions; - _azureADB2COptions = azureADB2COptions; - } - - public void Configure(string name, JwtBearerOptions options) - { - var azureADB2CScheme = GetAzureADB2CScheme(name); - var azureADB2COptions = _azureADB2COptions.Get(azureADB2CScheme); - if (name != azureADB2COptions.JwtBearerSchemeName) - { - return; - } - - options.Audience = azureADB2COptions.ClientId; - options.Authority = AzureADB2COpenIdConnectOptionsConfiguration.BuildAuthority(azureADB2COptions); - } - - public void Configure(JwtBearerOptions options) - { - } - - private string GetAzureADB2CScheme(string name) - { - foreach (var mapping in _schemeOptions.Value.JwtBearerMappings) - { - if (mapping.Value.JwtBearerScheme == name) - { - return mapping.Key; - } - } - - return null; - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2COpenIdConnectOptionsConfiguration.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2COpenIdConnectOptionsConfiguration.cs deleted file mode 100644 index e03badf98183..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureADB2COpenIdConnectOptionsConfiguration.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Options; -using Microsoft.IdentityModel.Tokens; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADB2COpenIdConnectOptionsConfiguration : IConfigureNamedOptions - { - private readonly IOptions _schemeOptions; - private readonly IOptionsMonitor _azureADB2COptions; - - public AzureADB2COpenIdConnectOptionsConfiguration(IOptions schemeOptions, IOptionsMonitor azureADB2COptions) - { - _schemeOptions = schemeOptions; - _azureADB2COptions = azureADB2COptions; - } - - public void Configure(string name, OpenIdConnectOptions options) - { - var azureADB2CScheme = GetAzureADB2CScheme(name); - var azureADB2COptions = _azureADB2COptions.Get(azureADB2CScheme); - if (name != azureADB2COptions.OpenIdConnectSchemeName) - { - return; - } - - options.ClientId = azureADB2COptions.ClientId; - options.ClientSecret = azureADB2COptions.ClientSecret; - options.Authority = BuildAuthority(azureADB2COptions); - options.CallbackPath = azureADB2COptions.CallbackPath ?? options.CallbackPath; - options.SignedOutCallbackPath = azureADB2COptions.SignedOutCallbackPath ?? options.SignedOutCallbackPath; - options.SignInScheme = azureADB2COptions.CookieSchemeName; - options.UseTokenLifetime = true; - options.TokenValidationParameters = new TokenValidationParameters { NameClaimType = "name" }; - - var handlers = new AzureADB2COpenIDConnectEventHandlers(azureADB2CScheme, azureADB2COptions); - options.Events = new OpenIdConnectEvents - { - OnRedirectToIdentityProvider = handlers.OnRedirectToIdentityProvider, - OnRemoteFailure = handlers.OnRemoteFailure - }; - } - - internal static string BuildAuthority(AzureADB2COptions AzureADB2COptions) - { - var baseUri = new Uri(AzureADB2COptions.Instance); - var pathBase = baseUri.PathAndQuery.TrimEnd('/'); - var domain = AzureADB2COptions.Domain; - var policy = AzureADB2COptions.DefaultPolicy; - - return new Uri(baseUri, new PathString($"{pathBase}/{domain}/{policy}/v2.0")).ToString(); - } - - private string GetAzureADB2CScheme(string name) - { - foreach (var mapping in _schemeOptions.Value.OpenIDMappings) - { - if (mapping.Value.OpenIdConnectScheme == name) - { - return mapping.Key; - } - } - - return null; - } - - public void Configure(OpenIdConnectOptions options) - { - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CAuthenticationBuilderExtensions.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CAuthenticationBuilderExtensions.cs deleted file mode 100644 index 2b70aa9b480a..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CAuthenticationBuilderExtensions.cs +++ /dev/null @@ -1,228 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Authentication.AzureADB2C.UI; -using Microsoft.AspNetCore.Mvc.ApplicationParts; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; -using Microsoft.Extensions.Options; -using System.Collections.Generic; - -namespace Microsoft.AspNetCore.Authentication -{ - /// - /// Extension methods to add Azure Active Directory B2C Authentication to your application. - /// - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static class AzureADB2CAuthenticationBuilderExtensions - { - /// - /// Adds JWT Bearer authentication to your app for Azure AD B2C Applications. - /// - /// The . - /// The to configure the - /// . - /// - /// The . - [Obsolete("This is obsolete and will be removed in a future version. Use AddMicrosoftWebApiAuthentication from Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static AuthenticationBuilder AddAzureADB2CBearer(this AuthenticationBuilder builder, Action configureOptions) => - builder.AddAzureADB2CBearer( - AzureADB2CDefaults.BearerAuthenticationScheme, - AzureADB2CDefaults.JwtBearerAuthenticationScheme, - configureOptions); - - /// - /// Adds JWT Bearer authentication to your app for Azure AD B2C Applications. - /// - /// The . - /// The identifier for the virtual scheme. - /// The identifier for the underlying JWT Bearer scheme. - /// The to configure the - /// . - /// - /// The . - [Obsolete("This is obsolete and will be removed in a future version. Use AddMicrosoftWebApiAuthentication from Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static AuthenticationBuilder AddAzureADB2CBearer( - this AuthenticationBuilder builder, - string scheme, - string jwtBearerScheme, - Action configureOptions) - { - builder.AddPolicyScheme(scheme, displayName: null, configureOptions: o => - { - o.ForwardDefault = jwtBearerScheme; - }); - - builder.Services.Configure(TryAddJwtBearerSchemeMapping(scheme, jwtBearerScheme)); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADB2COptionsConfiguration>()); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADB2CJwtBearerOptionsConfiguration>()); - - builder.Services.Configure(scheme, configureOptions); - builder.AddJwtBearer(jwtBearerScheme, o => { }); - - return builder; - } - - /// - /// Adds Azure Active Directory B2C Authentication to your application. - /// - /// The . - /// The to configure the - /// - /// - /// The . - [Obsolete("This is obsolete and will be removed in a future version. Use AddMicrosoftWebApiAuthentication from Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static AuthenticationBuilder AddAzureADB2C(this AuthenticationBuilder builder, Action configureOptions) => - builder.AddAzureADB2C( - AzureADB2CDefaults.AuthenticationScheme, - AzureADB2CDefaults.OpenIdScheme, - AzureADB2CDefaults.CookieScheme, - AzureADB2CDefaults.DisplayName, - configureOptions); - - /// - /// Adds Azure Active Directory B2C Authentication to your application. - /// - /// The . - /// The identifier for the virtual scheme. - /// The identifier for the underlying Open ID Connect scheme. - /// The identifier for the underlying cookie scheme. - /// The display name for the scheme. - /// The to configure the - /// - /// - /// The . - [Obsolete("This is obsolete and will be removed in a future version. Use AddMicrosoftWebApiAuthentication from Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static AuthenticationBuilder AddAzureADB2C( - this AuthenticationBuilder builder, - string scheme, - string openIdConnectScheme, - string cookieScheme, - string displayName, - Action configureOptions) - { - AddAdditionalMvcApplicationParts(builder.Services); - builder.AddPolicyScheme(scheme, displayName, o => - { - o.ForwardDefault = cookieScheme; - o.ForwardChallenge = openIdConnectScheme; - }); - - builder.Services.Configure(TryAddOpenIDCookieSchemeMappings(scheme, openIdConnectScheme, cookieScheme)); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADB2COptionsConfiguration>()); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADB2COpenIdConnectOptionsConfiguration>()); - - builder.Services.TryAddEnumerable(ServiceDescriptor.Singleton, AzureADB2CCookieOptionsConfiguration>()); - - builder.Services.Configure(scheme, configureOptions); - - builder.AddOpenIdConnect(openIdConnectScheme, null, o => { }); - builder.AddCookie(cookieScheme, null, o => { }); - - return builder; - } - - private static Action TryAddJwtBearerSchemeMapping(string scheme, string jwtBearerScheme) - { - return TryAddMapping; - - void TryAddMapping(AzureADB2CSchemeOptions o) - { - if (o.JwtBearerMappings.ContainsKey(scheme)) - { - throw new InvalidOperationException($"A scheme with the name '{scheme}' was already added."); - } - foreach (var mapping in o.JwtBearerMappings) - { - if (mapping.Value.JwtBearerScheme == jwtBearerScheme) - { - throw new InvalidOperationException( - $"The JSON Web Token Bearer scheme '{jwtBearerScheme}' can't be associated with the Azure Active Directory B2C scheme '{scheme}'. " + - $"The JSON Web Token Bearer scheme '{jwtBearerScheme}' is already mapped to the Azure Active Directory B2C scheme '{mapping.Key}'"); - } - } - o.JwtBearerMappings.Add(scheme, new AzureADB2CSchemeOptions.JwtBearerSchemeMapping - { - JwtBearerScheme = jwtBearerScheme - }); - }; - } - - private static Action TryAddOpenIDCookieSchemeMappings(string scheme, string openIdConnectScheme, string cookieScheme) - { - return TryAddMapping; - - void TryAddMapping(AzureADB2CSchemeOptions o) - { - if (o.OpenIDMappings.ContainsKey(scheme)) - { - throw new InvalidOperationException($"A scheme with the name '{scheme}' was already added."); - } - foreach (var mapping in o.OpenIDMappings) - { - if (mapping.Value.CookieScheme == cookieScheme) - { - throw new InvalidOperationException( - $"The cookie scheme '{cookieScheme}' can't be associated with the Azure Active Directory B2C scheme '{scheme}'. " + - $"The cookie scheme '{cookieScheme}' is already mapped to the Azure Active Directory B2C scheme '{mapping.Key}'"); - } - - if (mapping.Value.OpenIdConnectScheme == openIdConnectScheme) - { - throw new InvalidOperationException( - $"The Open ID Connect scheme '{openIdConnectScheme}' can't be associated with the Azure Active Directory B2C scheme '{scheme}'. " + - $"The Open ID Connect scheme '{openIdConnectScheme}' is already mapped to the Azure Active Directory B2C scheme '{mapping.Key}'"); - } - } - o.OpenIDMappings.Add(scheme, new AzureADB2CSchemeOptions.AzureADB2COpenIDSchemeMapping - { - OpenIdConnectScheme = openIdConnectScheme, - CookieScheme = cookieScheme - }); - }; - } - - private static void AddAdditionalMvcApplicationParts(IServiceCollection services) - { - var additionalParts = GetAdditionalParts(); - var mvcBuilder = services - .AddMvc() - .ConfigureApplicationPartManager(apm => - { - foreach (var part in additionalParts) - { - if (!apm.ApplicationParts.Any(ap => HasSameName(ap.Name, part.Name))) - { - apm.ApplicationParts.Add(part); - } - } - - apm.FeatureProviders.Add(new AzureADB2CAccountControllerFeatureProvider()); - }); - - bool HasSameName(string left, string right) => string.Equals(left, right, StringComparison.Ordinal); - } - - private static IEnumerable GetAdditionalParts() - { - var thisAssembly = typeof(AzureADB2CAuthenticationBuilderExtensions).Assembly; - var relatedAssemblies = RelatedAssemblyAttribute.GetRelatedAssemblies(thisAssembly, throwOnError: true); - - foreach (var reference in relatedAssemblies) - { - yield return new CompiledRazorAssemblyPart(reference); - } - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CDefaults.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CDefaults.cs deleted file mode 100644 index 6d95f08d0ebc..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CDefaults.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - /// - /// Constants for different Azure Active Directory B2C authentication components. - /// - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public static class AzureADB2CDefaults - { - /// - /// The key for the policy used in . - /// - public static readonly string PolicyKey = "Policy"; - - /// - /// The scheme name for Open ID Connect when using - /// . - /// - public const string OpenIdScheme = "AzureADB2COpenID"; - - /// - /// The scheme name for cookies when using - /// . - /// - public const string CookieScheme = "AzureADB2CCookie"; - - /// - /// The default scheme for Azure Active Directory B2C Bearer. - /// - public const string BearerAuthenticationScheme = "AzureADB2CBearer"; - - /// - /// The scheme name for JWT Bearer when using - /// . - /// - public const string JwtBearerAuthenticationScheme = "AzureADB2CJwtBearer"; - - /// - /// The default scheme for Azure Active Directory B2C. - /// - public const string AuthenticationScheme = "AzureADB2C"; - - /// - /// The display name for Azure Active Directory B2C. - /// - public static readonly string DisplayName = "Azure Active Directory B2C"; - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COpenIDConnectEventHandlers.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COpenIDConnectEventHandlers.cs deleted file mode 100644 index 5c9a758db7c7..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COpenIDConnectEventHandlers.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADB2COpenIDConnectEventHandlers - { - private IDictionary _policyToIssuerAddress = - new Dictionary(StringComparer.OrdinalIgnoreCase); - - public AzureADB2COpenIDConnectEventHandlers(string schemeName, AzureADB2COptions options) - { - SchemeName = schemeName; - Options = options; - } - - public string SchemeName { get; } - - public AzureADB2COptions Options { get; } - - public Task OnRedirectToIdentityProvider(RedirectContext context) - { - var defaultPolicy = Options.DefaultPolicy; - if (context.Properties.Items.TryGetValue(AzureADB2CDefaults.PolicyKey, out var policy) && - !string.IsNullOrEmpty(policy) && - !string.Equals(policy, defaultPolicy, StringComparison.OrdinalIgnoreCase)) - { - context.ProtocolMessage.Scope = OpenIdConnectScope.OpenIdProfile; - context.ProtocolMessage.ResponseType = OpenIdConnectResponseType.IdToken; - context.ProtocolMessage.IssuerAddress = BuildIssuerAddress(context, defaultPolicy, policy); - context.Properties.Items.Remove(AzureADB2CDefaults.PolicyKey); - } - - return Task.CompletedTask; - } - - private string BuildIssuerAddress(RedirectContext context, string defaultPolicy, string policy) - { - if (!_policyToIssuerAddress.TryGetValue(policy, out var issuerAddress)) - { - _policyToIssuerAddress[policy] = context.ProtocolMessage.IssuerAddress.ToLowerInvariant() - .Replace($"/{defaultPolicy.ToLowerInvariant()}/", $"/{policy.ToLowerInvariant()}/"); - } - - return _policyToIssuerAddress[policy]; - } - - public Task OnRemoteFailure(RemoteFailureContext context) - { - context.HandleResponse(); - // Handle the error code that Azure Active Directory B2C throws when trying to reset a password from the login page - // because password reset is not supported by a "sign-up or sign-in policy". - // Below is a sample error message: - // 'access_denied', error_description: 'AADB2C90118: The user has forgotten their password. - // Correlation ID: f99deff4-f43b-43cc-b4e7-36141dbaf0a0 - // Timestamp: 2018-03-05 02:49:35Z - //', error_uri: 'error_uri is null'. - if (context.Failure is OpenIdConnectProtocolException && context.Failure.Message.Contains("AADB2C90118")) - { - // If the user clicked the reset password link, redirect to the reset password route - context.Response.Redirect($"{context.Request.PathBase}/AzureADB2C/Account/ResetPassword/{SchemeName}"); - } - // Access denied errors happen when a user cancels an action on the Azure Active Directory B2C UI. We just redirect back to - // the main page in that case. - // Message contains error: 'access_denied', error_description: 'AADB2C90091: The user has cancelled entering self-asserted information. - // Correlation ID: d01c8878-0732-4eb2-beb8-da82a57432e0 - // Timestamp: 2018-03-05 02:56:49Z - // ', error_uri: 'error_uri is null'. - else if (context.Failure is OpenIdConnectProtocolException && context.Failure.Message.Contains("access_denied")) - { - context.Response.Redirect($"{context.Request.PathBase}/"); - } - else - { - context.Response.Redirect($"{context.Request.PathBase}/AzureADB2C/Account/Error"); - } - - return Task.CompletedTask; - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COptions.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COptions.cs deleted file mode 100644 index eb0d95d53a68..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COptions.cs +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - /// - /// Options for configuring authentication using Azure Active Directory B2C. - /// - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - public class AzureADB2COptions - { - /// - /// Gets or sets the OpenID Connect authentication scheme to use for authentication with this instance - /// of Azure Active Directory B2C authentication. - /// - public string OpenIdConnectSchemeName { get; set; } = OpenIdConnectDefaults.AuthenticationScheme; - - /// - /// Gets or sets the Cookie authentication scheme to use for sign in with this instance of - /// Azure Active Directory B2C authentication. - /// - public string CookieSchemeName { get; set; } = CookieAuthenticationDefaults.AuthenticationScheme; - - /// - /// Gets or sets the Jwt bearer authentication scheme to use for validating access tokens for this - /// instance of Azure Active Directory B2C Bearer authentication. - /// - public string JwtBearerSchemeName { get; internal set; } - - - /// - /// Gets or sets the client Id. - /// - public string ClientId { get; set; } - - /// - /// Gets or sets the client secret. - /// - public string ClientSecret { get; set; } - - /// - /// Gets or sets the Azure Active Directory B2C instance. - /// - public string Instance { get; set; } - - /// - /// Gets or sets the domain of the Azure Active Directory B2C tenant. - /// - public string Domain { get; set; } - - /// - /// Gets or sets the edit profile policy name. - /// - public string EditProfilePolicyId { get; set; } - - /// - /// Gets or sets the sign up or sign in policy name. - /// - public string SignUpSignInPolicyId { get; set; } - - /// - /// Gets or sets the reset password policy id. - /// - public string ResetPasswordPolicyId { get; set; } - - /// - /// Gets or sets the sign in callback path. - /// - public string CallbackPath { get; set; } - - /// - /// Gets or sets the sign out callback path. - /// - public string SignedOutCallbackPath { get; set; } - - /// - /// Gets or sets the default policy. - /// - public string DefaultPolicy => SignUpSignInPolicyId; - - /// - /// Gets all the underlying authentication schemes. - /// - public string[] AllSchemes => new[] { CookieSchemeName, OpenIdConnectSchemeName }; - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COptionsConfiguration.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COptionsConfiguration.cs deleted file mode 100644 index bad360b960ae..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2COptionsConfiguration.cs +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - [Obsolete("This is obsolete and will be removed in a future version. Use Microsoft.Identity.Web instead. See https://aka.ms/ms-identity-web.")] - internal class AzureADB2COptionsConfiguration : IConfigureNamedOptions - { - private readonly IOptions _schemeOptions; - - public AzureADB2COptionsConfiguration(IOptions schemeOptions) - { - _schemeOptions = schemeOptions; - } - - public void Configure(string name, AzureADB2COptions options) - { - // This can be called because of someone configuring JWT or someone configuring - // Open ID + Cookie. - if (_schemeOptions.Value.OpenIDMappings.TryGetValue(name, out var webMapping)) - { - options.OpenIdConnectSchemeName = webMapping.OpenIdConnectScheme; - options.CookieSchemeName = webMapping.CookieScheme; - return; - } - if (_schemeOptions.Value.JwtBearerMappings.TryGetValue(name, out var mapping)) - { - options.JwtBearerSchemeName = mapping.JwtBearerScheme; - return; - } - } - - public void Configure(AzureADB2COptions options) - { - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CSchemeOptions.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CSchemeOptions.cs deleted file mode 100644 index 991e5fc5b680..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/AzureAdB2CSchemeOptions.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System.Collections.Generic; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - internal class AzureADB2CSchemeOptions - { - public IDictionary OpenIDMappings { get; set; } = new Dictionary(); - - public IDictionary JwtBearerMappings { get; set; } = new Dictionary(); - - public class AzureADB2COpenIDSchemeMapping - { - public string OpenIdConnectScheme { get; set; } - public string CookieScheme { get; set; } - } - - public class JwtBearerSchemeMapping - { - public string JwtBearerScheme { get; set; } - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj deleted file mode 100644 index e92ddfff11d7..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - ASP.NET Core Azure Active Directory B2C Integration provides components for easily integrating Azure Active Directory B2C authentication within your ASP.NET Core application. - Precompiled views assembly for the ASP.NET Core Azure Active Directory B2C Integration package. - $(DefaultNetCoreTargetFramework) - aspnetcore;authentication;AzureADB2C - true - Microsoft.AspNetCore.Mvc.ApplicationParts.NullApplicationPartFactory, Microsoft.AspNetCore.Mvc.Core - true - - - - - - - - - - diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Properties/AssemblyInfo.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Properties/AssemblyInfo.cs deleted file mode 100644 index 1269fbc713f6..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f33a29044fa9d740c9b3213a93e57c84b472c84e0b8a0e1ae48e67a9f8f6de9d5f7f3d52ac23e48ac51801f1dc950abe901da34d2a9e3baadb141a17c77ef3c565dd5ee5054b91cf63bb3c6ab83f72ab3aafe93d0fc3c2348b764fafb0b1c0733de51459aeab46580384bf9d74c4e28164b7cde247f891ba07891c9d872ad2bb")] \ No newline at end of file diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/PublicAPI.Shipped.txt b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/PublicAPI.Shipped.txt deleted file mode 100644 index dc774f64eeb5..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/PublicAPI.Shipped.txt +++ /dev/null @@ -1,53 +0,0 @@ -#nullable enable -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2CDefaults -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.AzureADB2COptions() -> void -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.AccessDeniedModel -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.AccessDeniedModel.AccessDeniedModel() -> void -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.AccessDeniedModel.OnGet() -> void -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.ErrorModel -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.ErrorModel.ErrorModel() -> void -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.ErrorModel.OnGet() -> void -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.ErrorModel.ShowRequestId.get -> bool -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.SignedOutModel -Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.SignedOutModel.SignedOutModel() -> void -Microsoft.AspNetCore.Authentication.AzureADB2CAuthenticationBuilderExtensions -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.AllSchemes.get -> string[] -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.CallbackPath.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.CallbackPath.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.ClientId.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.ClientId.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.ClientSecret.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.ClientSecret.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.CookieSchemeName.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.CookieSchemeName.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.DefaultPolicy.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.Domain.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.Domain.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.EditProfilePolicyId.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.EditProfilePolicyId.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.Instance.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.Instance.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.JwtBearerSchemeName.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.OpenIdConnectSchemeName.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.OpenIdConnectSchemeName.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.ResetPasswordPolicyId.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.ResetPasswordPolicyId.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.SignUpSignInPolicyId.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.SignUpSignInPolicyId.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.SignedOutCallbackPath.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2COptions.SignedOutCallbackPath.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.ErrorModel.RequestId.get -> string -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.ErrorModel.RequestId.set -> void -~Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Internal.SignedOutModel.OnGet() -> Microsoft.AspNetCore.Mvc.IActionResult -~const Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2CDefaults.AuthenticationScheme = "AzureADB2C" -> string -~const Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2CDefaults.BearerAuthenticationScheme = "AzureADB2CBearer" -> string -~const Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2CDefaults.CookieScheme = "AzureADB2CCookie" -> string -~const Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2CDefaults.JwtBearerAuthenticationScheme = "AzureADB2CJwtBearer" -> string -~const Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2CDefaults.OpenIdScheme = "AzureADB2COpenID" -> string -~static Microsoft.AspNetCore.Authentication.AzureADB2CAuthenticationBuilderExtensions.AddAzureADB2C(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, System.Action configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder -~static Microsoft.AspNetCore.Authentication.AzureADB2CAuthenticationBuilderExtensions.AddAzureADB2C(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string scheme, string openIdConnectScheme, string cookieScheme, string displayName, System.Action configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder -~static Microsoft.AspNetCore.Authentication.AzureADB2CAuthenticationBuilderExtensions.AddAzureADB2CBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, System.Action configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder -~static Microsoft.AspNetCore.Authentication.AzureADB2CAuthenticationBuilderExtensions.AddAzureADB2CBearer(this Microsoft.AspNetCore.Authentication.AuthenticationBuilder builder, string scheme, string jwtBearerScheme, System.Action configureOptions) -> Microsoft.AspNetCore.Authentication.AuthenticationBuilder -~static readonly Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2CDefaults.DisplayName -> string -~static readonly Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2CDefaults.PolicyKey -> string diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/PublicAPI.Unshipped.txt b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/PublicAPI.Unshipped.txt deleted file mode 100644 index 7dc5c58110bf..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/src/PublicAPI.Unshipped.txt +++ /dev/null @@ -1 +0,0 @@ -#nullable enable diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/AzureAdB2CAuthenticationBuilderExtensionsTests.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/AzureAdB2CAuthenticationBuilderExtensionsTests.cs deleted file mode 100644 index cd7dde32f668..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/AzureAdB2CAuthenticationBuilderExtensionsTests.cs +++ /dev/null @@ -1,426 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using Microsoft.AspNetCore.Authentication.AzureADB2C.UI; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Logging.Abstractions; -using Microsoft.Extensions.Options; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication -{ - public class AzureADB2CAuthenticationBuilderExtensionsTests - { - [Fact] - public void AddAzureADB2C_AddsAllAuthenticationHandlers() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureADB2C(o => { }); - var provider = services.BuildServiceProvider(); - - // Assert - Assert.NotNull(provider.GetService()); - Assert.NotNull(provider.GetService()); - Assert.NotNull(provider.GetService()); - } - - [Fact] - public void AddAzureADB2C_ConfiguresAllOptions() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureADB2C(o => - { - o.Instance = "https://login.microsoftonline.com/tfp"; - o.ClientId = "ClientId"; - o.ClientSecret = "ClientSecret"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.SignUpSignInPolicyId = "B2C_1_SiUpIn"; - o.ResetPasswordPolicyId = "B2C_1_SSPR"; - o.EditProfilePolicyId = "B2C_1_SiPe"; - }); - var provider = services.BuildServiceProvider(); - - // Assert - var azureADB2COptionsMonitor = provider.GetService>(); - Assert.NotNull(azureADB2COptionsMonitor); - var azureADB2COptions = azureADB2COptionsMonitor.Get(AzureADB2CDefaults.AuthenticationScheme); - Assert.Equal(AzureADB2CDefaults.OpenIdScheme, azureADB2COptions.OpenIdConnectSchemeName); - Assert.Equal(AzureADB2CDefaults.CookieScheme, azureADB2COptions.CookieSchemeName); - Assert.Equal("https://login.microsoftonline.com/tfp", azureADB2COptions.Instance); - Assert.Equal("ClientId", azureADB2COptions.ClientId); - Assert.Equal("ClientSecret", azureADB2COptions.ClientSecret); - Assert.Equal("/signin-oidc", azureADB2COptions.CallbackPath); - Assert.Equal("domain.onmicrosoft.com", azureADB2COptions.Domain); - Assert.Equal("B2C_1_SiUpIn", azureADB2COptions.SignUpSignInPolicyId); - Assert.Equal("B2C_1_SSPR", azureADB2COptions.ResetPasswordPolicyId); - Assert.Equal("B2C_1_SiPe", azureADB2COptions.EditProfilePolicyId); - - var openIdOptionsMonitor = provider.GetService>(); - Assert.NotNull(openIdOptionsMonitor); - var openIdOptions = openIdOptionsMonitor.Get(AzureADB2CDefaults.OpenIdScheme); - Assert.Equal("ClientId", openIdOptions.ClientId); - Assert.Equal($"https://login.microsoftonline.com/tfp/domain.onmicrosoft.com/B2C_1_SiUpIn/v2.0", openIdOptions.Authority); - Assert.True(openIdOptions.UseTokenLifetime); - Assert.Equal("/signin-oidc", openIdOptions.CallbackPath); - Assert.Equal(AzureADB2CDefaults.CookieScheme, openIdOptions.SignInScheme); - Assert.NotNull(openIdOptions.TokenValidationParameters); - Assert.Equal("name", openIdOptions.TokenValidationParameters.NameClaimType); - Assert.NotNull(openIdOptions.Events); - var redirectHandler = openIdOptions.Events.OnRedirectToIdentityProvider; - Assert.NotNull(redirectHandler); - Assert.IsType(redirectHandler.Target); - var remoteFailureHanlder = openIdOptions.Events.OnRemoteFailure; - Assert.NotNull(remoteFailureHanlder); - Assert.IsType(redirectHandler.Target); - - var cookieAuthenticationOptionsMonitor = provider.GetService>(); - Assert.NotNull(cookieAuthenticationOptionsMonitor); - var cookieAuthenticationOptions = cookieAuthenticationOptionsMonitor.Get(AzureADB2CDefaults.CookieScheme); - Assert.Equal("/AzureADB2C/Account/SignIn/AzureADB2C", cookieAuthenticationOptions.LoginPath); - Assert.Equal("/AzureADB2C/Account/SignOut/AzureADB2C", cookieAuthenticationOptions.LogoutPath); - Assert.Equal("/AzureADB2C/Account/AccessDenied", cookieAuthenticationOptions.AccessDeniedPath); - Assert.Equal(SameSiteMode.None, cookieAuthenticationOptions.Cookie.SameSite); - } - - [Fact] - public void AddAzureADB2C_AllowsOverridingCookiesAndOpenIdConnectSettings() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureADB2C(o => - { - o.Instance = "https://login.microsoftonline.com"; - o.ClientId = "ClientId"; - o.ClientSecret = "ClientSecret"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - }); - - services.Configure(AzureADB2CDefaults.OpenIdScheme, o => - { - o.Authority = "https://overriden.com"; - }); - - services.Configure(AzureADB2CDefaults.CookieScheme, o => - { - o.AccessDeniedPath = "/Overriden"; - }); - - var provider = services.BuildServiceProvider(); - - // Assert - var openIdOptionsMonitor = provider.GetService>(); - Assert.NotNull(openIdOptionsMonitor); - var openIdOptions = openIdOptionsMonitor.Get(AzureADB2CDefaults.OpenIdScheme); - Assert.Equal("ClientId", openIdOptions.ClientId); - Assert.Equal($"https://overriden.com", openIdOptions.Authority); - - var cookieAuthenticationOptionsMonitor = provider.GetService>(); - Assert.NotNull(cookieAuthenticationOptionsMonitor); - var cookieAuthenticationOptions = cookieAuthenticationOptionsMonitor.Get(AzureADB2CDefaults.CookieScheme); - Assert.Equal("/AzureADB2C/Account/SignIn/AzureADB2C", cookieAuthenticationOptions.LoginPath); - Assert.Equal("/Overriden", cookieAuthenticationOptions.AccessDeniedPath); - } - - [Fact] - public void AddAzureADB2C_RegisteringAddCookiesAndAddOpenIdConnectHasNoImpactOnAzureAAExtensions() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddCookie() - .AddOpenIdConnect() - .AddAzureADB2C(o => - { - o.Instance = "https://login.microsoftonline.com"; - o.ClientId = "ClientId"; - o.ClientSecret = "ClientSecret"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - }); - - services.Configure(AzureADB2CDefaults.OpenIdScheme, o => - { - o.Authority = "https://overriden.com"; - }); - - services.Configure(AzureADB2CDefaults.CookieScheme, o => - { - o.AccessDeniedPath = "/Overriden"; - }); - - var provider = services.BuildServiceProvider(); - - // Assert - var openIdOptionsMonitor = provider.GetService>(); - Assert.NotNull(openIdOptionsMonitor); - var openIdOptions = openIdOptionsMonitor.Get(AzureADB2CDefaults.OpenIdScheme); - Assert.Equal("ClientId", openIdOptions.ClientId); - Assert.Equal($"https://overriden.com", openIdOptions.Authority); - - var cookieAuthenticationOptionsMonitor = provider.GetService>(); - Assert.NotNull(cookieAuthenticationOptionsMonitor); - var cookieAuthenticationOptions = cookieAuthenticationOptionsMonitor.Get(AzureADB2CDefaults.CookieScheme); - Assert.Equal("/AzureADB2C/Account/SignIn/AzureADB2C", cookieAuthenticationOptions.LoginPath); - Assert.Equal("/Overriden", cookieAuthenticationOptions.AccessDeniedPath); - } - - [Fact] - public void AddAzureADB2C_ThrowsForDuplicatedSchemes() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureADB2C(o => { }) - .AddAzureADB2C(o => { }); - - var provider = services.BuildServiceProvider(); - var azureADB2COptionsMonitor = provider.GetService>(); - - // Act & Assert - var exception = Assert.Throws( - () => azureADB2COptionsMonitor.Get(AzureADB2CDefaults.AuthenticationScheme)); - - Assert.Equal("A scheme with the name 'AzureADB2C' was already added.", exception.Message); - } - - [Fact] - public void AddAzureADB2C_ThrowsWhenOpenIdSchemeIsAlreadyInUse() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureADB2C(o => { }) - .AddAzureADB2C("Custom", AzureADB2CDefaults.OpenIdScheme, "Cookie", null, o => { }); - - var provider = services.BuildServiceProvider(); - var azureADB2COptionsMonitor = provider.GetService>(); - - var expectedMessage = $"The Open ID Connect scheme 'AzureADB2COpenID' can't be associated with the Azure Active Directory B2C scheme 'Custom'. " + - "The Open ID Connect scheme 'AzureADB2COpenID' is already mapped to the Azure Active Directory B2C scheme 'AzureADB2C'"; - - // Act & Assert - var exception = Assert.Throws( - () => azureADB2COptionsMonitor.Get(AzureADB2CDefaults.AuthenticationScheme)); - - Assert.Equal(expectedMessage, exception.Message); - } - - [Fact] - public void AddAzureADB2C_ThrowsWhenCookieSchemeIsAlreadyInUse() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureADB2C(o => { }) - .AddAzureADB2C("Custom", "OpenID", AzureADB2CDefaults.CookieScheme, null, o => { }); - - var provider = services.BuildServiceProvider(); - var azureADB2COptionsMonitor = provider.GetService>(); - - var expectedMessage = $"The cookie scheme 'AzureADB2CCookie' can't be associated with the Azure Active Directory B2C scheme 'Custom'. " + - "The cookie scheme 'AzureADB2CCookie' is already mapped to the Azure Active Directory B2C scheme 'AzureADB2C'"; - - // Act & Assert - var exception = Assert.Throws( - () => azureADB2COptionsMonitor.Get(AzureADB2CDefaults.AuthenticationScheme)); - - Assert.Equal(expectedMessage, exception.Message); - } - - [Fact] - public void AddAzureADB2CBearer_AddsAllAuthenticationHandlers() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureADB2CBearer(o => { }); - var provider = services.BuildServiceProvider(); - - // Assert - Assert.NotNull(provider.GetService()); - Assert.NotNull(provider.GetService()); - } - - [Fact] - public void AddAzureADB2CBearer_ConfiguresAllOptions() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureADB2CBearer(o => - { - o.Instance = "https://login.microsoftonline.com/tfp"; - o.ClientId = "ClientId"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.SignUpSignInPolicyId = "B2C_1_SiUpIn"; - }); - var provider = services.BuildServiceProvider(); - - // Assert - var azureADB2COptionsMonitor = provider.GetService>(); - Assert.NotNull(azureADB2COptionsMonitor); - var options = azureADB2COptionsMonitor.Get(AzureADB2CDefaults.BearerAuthenticationScheme); - Assert.Equal(AzureADB2CDefaults.JwtBearerAuthenticationScheme, options.JwtBearerSchemeName); - Assert.Equal("https://login.microsoftonline.com/tfp", options.Instance); - Assert.Equal("ClientId", options.ClientId); - Assert.Equal("domain.onmicrosoft.com", options.Domain); - Assert.Equal("B2C_1_SiUpIn", options.DefaultPolicy); - - var bearerOptionsMonitor = provider.GetService>(); - Assert.NotNull(bearerOptionsMonitor); - var bearerOptions = bearerOptionsMonitor.Get(AzureADB2CDefaults.JwtBearerAuthenticationScheme); - Assert.Equal("ClientId", bearerOptions.Audience); - Assert.Equal($"https://login.microsoftonline.com/tfp/domain.onmicrosoft.com/B2C_1_SiUpIn/v2.0", bearerOptions.Authority); - } - - [Fact] - public void AddAzureADB2CBearer_CanOverrideJwtBearerOptionsConfiguration() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddAzureADB2CBearer(o => - { - o.Instance = "https://login.microsoftonline.com/"; - o.ClientId = "ClientId"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.SignUpSignInPolicyId = "B2C_1_SiUpIn"; - }); - - services.Configure(AzureADB2CDefaults.JwtBearerAuthenticationScheme, o => - { - o.Audience = "http://overriden.com"; - }); - - var provider = services.BuildServiceProvider(); - - // Assert - var bearerOptionsMonitor = provider.GetService>(); - Assert.NotNull(bearerOptionsMonitor); - var bearerOptions = bearerOptionsMonitor.Get(AzureADB2CDefaults.JwtBearerAuthenticationScheme); - Assert.Equal("https://login.microsoftonline.com/domain.onmicrosoft.com/B2C_1_SiUpIn/v2.0", bearerOptions.Authority); - Assert.Equal("http://overriden.com", bearerOptions.Audience); - } - - [Fact] - public void AddAzureADB2CBearer_RegisteringJwtBearerHasNoImpactOnAzureAAExtensions() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - // Act - services.AddAuthentication() - .AddJwtBearer() - .AddAzureADB2CBearer(o => - { - o.Instance = "https://login.microsoftonline.com/"; - o.ClientId = "ClientId"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "domain.onmicrosoft.com"; - o.SignUpSignInPolicyId = "B2C_1_SiUpIn"; - }); - - services.Configure(AzureADB2CDefaults.JwtBearerAuthenticationScheme, o => - { - o.Audience = "http://overriden.com"; - }); - - var provider = services.BuildServiceProvider(); - - // Assert - var bearerOptionsMonitor = provider.GetService>(); - Assert.NotNull(bearerOptionsMonitor); - var bearerOptions = bearerOptionsMonitor.Get(AzureADB2CDefaults.JwtBearerAuthenticationScheme); - Assert.Equal("https://login.microsoftonline.com/domain.onmicrosoft.com/B2C_1_SiUpIn/v2.0", bearerOptions.Authority); - Assert.Equal("http://overriden.com", bearerOptions.Audience); - } - - [Fact] - public void AddAzureADB2CBearer_ThrowsForDuplicatedSchemes() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureADB2CBearer(o => { }) - .AddAzureADB2CBearer(o => { }); - - var provider = services.BuildServiceProvider(); - var azureADB2COptionsMonitor = provider.GetService>(); - - // Act & Assert - var exception = Assert.Throws( - () => azureADB2COptionsMonitor.Get(AzureADB2CDefaults.AuthenticationScheme)); - - Assert.Equal("A scheme with the name 'AzureADB2CBearer' was already added.", exception.Message); - } - - [Fact] - public void AddAzureADB2CBearer_ThrowsWhenBearerSchemeIsAlreadyInUse() - { - // Arrange - var services = new ServiceCollection(); - services.AddSingleton(new NullLoggerFactory()); - - services.AddAuthentication() - .AddAzureADB2CBearer(o => { }) - .AddAzureADB2CBearer("Custom", AzureADB2CDefaults.JwtBearerAuthenticationScheme, o => { }); - - var provider = services.BuildServiceProvider(); - var azureADB2COptionsMonitor = provider.GetService>(); - - var expectedMessage = $"The JSON Web Token Bearer scheme 'AzureADB2CJwtBearer' can't be associated with the Azure Active Directory B2C scheme 'Custom'. " + - "The JSON Web Token Bearer scheme 'AzureADB2CJwtBearer' is already mapped to the Azure Active Directory B2C scheme 'AzureADB2CBearer'"; - - // Act & Assert - var exception = Assert.Throws( - () => azureADB2COptionsMonitor.Get(AzureADB2CDefaults.AuthenticationScheme)); - - Assert.Equal(expectedMessage, exception.Message); - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/AzureAdB2COpenIDConnectEventHandlersTests.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/AzureAdB2COpenIDConnectEventHandlersTests.cs deleted file mode 100644 index 7a9a4367f3e9..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/AzureAdB2COpenIDConnectEventHandlersTests.cs +++ /dev/null @@ -1,175 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System.Collections.Generic; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Http; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; -using Microsoft.Net.Http.Headers; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI -{ - public class AzureADB2COpenIDConnectEventHandlersTests - { - [Fact] - public async Task OnRedirectToIdentityProviderHandler_DoesNothingForTheDefaultPolicy() - { - // Arrange - var handlers = new AzureADB2COpenIDConnectEventHandlers( - AzureADB2CDefaults.AuthenticationScheme, - new AzureADB2COptions() { SignUpSignInPolicyId = "B2C_1_SiUpIn" }); - - var authenticationProperties = new AuthenticationProperties(new Dictionary - { - [AzureADB2CDefaults.PolicyKey] = "B2C_1_SiUpIn" - }); - var redirectContext = new RedirectContext( - new DefaultHttpContext(), - new AuthenticationScheme(AzureADB2CDefaults.AuthenticationScheme, "", typeof(OpenIdConnectHandler)), - new OpenIdConnectOptions(), - authenticationProperties) - { - ProtocolMessage = new OpenIdConnectMessage - { - Scope = OpenIdConnectScope.OpenId, - ResponseType = OpenIdConnectResponseType.Code, - IssuerAddress = "https://login.microsoftonline.com/tfp/domain.onmicrosoft.com/B2C_1_SiUpIn/v2.0" - } - }; - - // Act - await handlers.OnRedirectToIdentityProvider(redirectContext); - - // Assert - Assert.Equal(OpenIdConnectScope.OpenId, redirectContext.ProtocolMessage.Scope); - Assert.Equal(OpenIdConnectResponseType.Code, redirectContext.ProtocolMessage.ResponseType); - Assert.Equal( - "https://login.microsoftonline.com/tfp/domain.onmicrosoft.com/B2C_1_SiUpIn/v2.0", - redirectContext.ProtocolMessage.IssuerAddress); - Assert.True(authenticationProperties.Items.ContainsKey(AzureADB2CDefaults.PolicyKey)); - } - - [Fact] - public async Task OnRedirectToIdentityProviderHandler_UpdatesRequestForOtherPolicies() - { - // Arrange - - var handlers = new AzureADB2COpenIDConnectEventHandlers( - AzureADB2CDefaults.AuthenticationScheme, - new AzureADB2COptions() { SignUpSignInPolicyId = "B2C_1_SiUpIn" }); - - var authenticationProperties = new AuthenticationProperties(new Dictionary - { - [AzureADB2CDefaults.PolicyKey] = "B2C_1_EP" - }); - var redirectContext = new RedirectContext( - new DefaultHttpContext(), - new AuthenticationScheme(AzureADB2CDefaults.AuthenticationScheme, "", typeof(OpenIdConnectHandler)), - new OpenIdConnectOptions(), - authenticationProperties) - { - ProtocolMessage = new OpenIdConnectMessage - { - Scope = OpenIdConnectScope.OpenId, - ResponseType = OpenIdConnectResponseType.Code, - IssuerAddress = "https://login.microsoftonline.com/tfp/domain.onmicrosoft.com/B2C_1_EP/v2.0" - } - }; - - // Act - await handlers.OnRedirectToIdentityProvider(redirectContext); - - // Assert - Assert.Equal(OpenIdConnectScope.OpenIdProfile, redirectContext.ProtocolMessage.Scope); - Assert.Equal(OpenIdConnectResponseType.IdToken, redirectContext.ProtocolMessage.ResponseType); - Assert.Equal( - "https://login.microsoftonline.com/tfp/domain.onmicrosoft.com/b2c_1_ep/v2.0", - redirectContext.ProtocolMessage.IssuerAddress); - Assert.False(authenticationProperties.Items.ContainsKey(AzureADB2CDefaults.PolicyKey)); - } - - [Fact] - public async Task OnRemoteError_HandlesResponseWhenTryingToResetPasswordFromTheLoginPage() - { - // Arrange - - var handlers = new AzureADB2COpenIDConnectEventHandlers( - AzureADB2CDefaults.AuthenticationScheme, - new AzureADB2COptions() { SignUpSignInPolicyId = "B2C_1_SiUpIn" }); - - var remoteFailureContext = new RemoteFailureContext( - new DefaultHttpContext(), - new AuthenticationScheme( - AzureADB2CDefaults.AuthenticationScheme, - displayName: null, - handlerType: typeof(OpenIdConnectHandler)), - new OpenIdConnectOptions(), - new OpenIdConnectProtocolException("AADB2C90118")); - - // Act - await handlers.OnRemoteFailure(remoteFailureContext); - - // Assert - Assert.Equal(StatusCodes.Status302Found, remoteFailureContext.Response.StatusCode); - Assert.Equal("/AzureADB2C/Account/ResetPassword/AzureADB2C", remoteFailureContext.Response.Headers[HeaderNames.Location]); - Assert.True(remoteFailureContext.Result.Handled); - } - - [Fact] - public async Task OnRemoteError_HandlesResponseWhenUserCancelsFlowFromTheAzureADB2CUserInterface() - { - // Arrange - - var handlers = new AzureADB2COpenIDConnectEventHandlers( - AzureADB2CDefaults.AuthenticationScheme, - new AzureADB2COptions() { SignUpSignInPolicyId = "B2C_1_SiUpIn" }); - - var remoteFailureContext = new RemoteFailureContext( - new DefaultHttpContext(), - new AuthenticationScheme( - AzureADB2CDefaults.AuthenticationScheme, - displayName: null, - handlerType: typeof(OpenIdConnectHandler)), - new OpenIdConnectOptions(), - new OpenIdConnectProtocolException("access_denied")); - - // Act - await handlers.OnRemoteFailure(remoteFailureContext); - - // Assert - Assert.Equal(StatusCodes.Status302Found, remoteFailureContext.Response.StatusCode); - Assert.Equal("/", remoteFailureContext.Response.Headers[HeaderNames.Location]); - Assert.True(remoteFailureContext.Result.Handled); - } - - [Fact] - public async Task OnRemoteError_HandlesResponseWhenErrorIsUnknown() - { - // Arrange - - var handlers = new AzureADB2COpenIDConnectEventHandlers( - AzureADB2CDefaults.AuthenticationScheme, - new AzureADB2COptions() { SignUpSignInPolicyId = "B2C_1_SiUpIn" }); - - var remoteFailureContext = new RemoteFailureContext( - new DefaultHttpContext(), - new AuthenticationScheme( - AzureADB2CDefaults.AuthenticationScheme, - displayName: null, - handlerType: typeof(OpenIdConnectHandler)), - new OpenIdConnectOptions(), - new OpenIdConnectProtocolException("some_other_error")); - - // Act - await handlers.OnRemoteFailure(remoteFailureContext); - - // Assert - Assert.Equal(StatusCodes.Status302Found, remoteFailureContext.Response.StatusCode); - Assert.Equal("/AzureADB2C/Account/Error", remoteFailureContext.Response.Headers[HeaderNames.Location]); - Assert.True(remoteFailureContext.Result.Handled); - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/Controllers/AccountControllerTests.cs b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/Controllers/AccountControllerTests.cs deleted file mode 100644 index 5585ed30d19c..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/Controllers/AccountControllerTests.cs +++ /dev/null @@ -1,388 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System; -using System.Security.Claims; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.AspNetCore.Mvc.Routing; -using Microsoft.AspNetCore.Routing; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using Moq; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication.AzureADB2C.UI.AzureADB2C.Controllers.Internal -{ - public class AccountControllerTests - { - [Fact] - public void SignInNoScheme_ChallengesAADAzureADB2CDefaultScheme() - { - // Arrange - var controller = new AccountController( - new OptionsMonitor(AzureADB2CDefaults.AuthenticationScheme, new AzureADB2COptions() - { - OpenIdConnectSchemeName = AzureADB2CDefaults.OpenIdScheme, - CookieSchemeName = AzureADB2CDefaults.CookieScheme - })) - { - Url = new TestUrlHelper("~/", "https://localhost/") - }; - - // Act - var result = controller.SignIn(null); - - // Assert - var challenge = Assert.IsAssignableFrom(result); - var challengedScheme = Assert.Single(challenge.AuthenticationSchemes); - Assert.Equal(AzureADB2CDefaults.AuthenticationScheme, challengedScheme); - Assert.NotNull(challenge.Properties.RedirectUri); - Assert.Equal("https://localhost/", challenge.Properties.RedirectUri); - } - - [Fact] - public void SignInProvidedScheme_ChallengesCustomScheme() - { - // Arrange - var controller = new AccountController(new OptionsMonitor("Custom", new AzureADB2COptions())); - controller.Url = new TestUrlHelper("~/", "https://localhost/"); - - // Act - var result = controller.SignIn("Custom"); - - // Assert - var challenge = Assert.IsAssignableFrom(result); - var challengedScheme = Assert.Single(challenge.AuthenticationSchemes); - Assert.Equal("Custom", challengedScheme); - } - - [Fact] - public void ResetPasswordNoScheme_ChallengesAADAzureADB2CDefaultSchemeWithResetPassworPolicyAsync() - { - // Arrange - var controller = new AccountController( - new OptionsMonitor( - AzureADB2CDefaults.AuthenticationScheme, - new AzureADB2COptions() { ResetPasswordPolicyId = "Reset" })) - { - Url = new TestUrlHelper("~/", "https://localhost/") - }; - controller.ControllerContext = CreateControllerContext( - CreateAuthenticatedPrincipal(AzureADB2CDefaults.AuthenticationScheme)); - - // Act - var result = controller.ResetPassword(null); - - // Assert - var challenge = Assert.IsAssignableFrom(result); - var challengedScheme = Assert.Single(challenge.AuthenticationSchemes); - Assert.Equal(AzureADB2CDefaults.AuthenticationScheme, challengedScheme); - Assert.NotNull(challenge.Properties.RedirectUri); - Assert.Equal("https://localhost/", challenge.Properties.RedirectUri); - Assert.NotNull(challenge.Properties.Items[AzureADB2CDefaults.PolicyKey]); - Assert.Equal("Reset", challenge.Properties.Items[AzureADB2CDefaults.PolicyKey]); - } - - [Fact] - public void ResetPasswordCustomScheme_ChallengesAADAzureADB2CDefaultSchemeWithResetPassworPolicyFromCustomSchemeAsync() - { - // Arrange - var controller = new AccountController( - new OptionsMonitor( - "Custom", - new AzureADB2COptions() { ResetPasswordPolicyId = "CustomReset" })) - { - Url = new TestUrlHelper("~/", "https://localhost/") - }; - controller.ControllerContext = CreateControllerContext( - CreateAuthenticatedPrincipal("Custom")); - - // Act - var result = controller.ResetPassword("Custom"); - - // Assert - var challenge = Assert.IsAssignableFrom(result); - var challengedScheme = Assert.Single(challenge.AuthenticationSchemes); - Assert.Equal("Custom", challengedScheme); - Assert.NotNull(challenge.Properties.RedirectUri); - Assert.Equal("https://localhost/", challenge.Properties.RedirectUri); - Assert.NotNull(challenge.Properties.Items[AzureADB2CDefaults.PolicyKey]); - Assert.Equal("CustomReset", challenge.Properties.Items[AzureADB2CDefaults.PolicyKey]); - } - - [Fact] - public async Task EditProfileNoScheme_ChallengesAADAzureADB2CCustomSchemeWithEditProfilePolicyAsync() - { - // Arrange - var controller = new AccountController( - new OptionsMonitor( - AzureADB2CDefaults.AuthenticationScheme, - new AzureADB2COptions() { EditProfilePolicyId = "EditProfile" })) - { - Url = new TestUrlHelper("~/", "https://localhost/") - }; - controller.ControllerContext = CreateControllerContext( - CreateAuthenticatedPrincipal(AzureADB2CDefaults.AuthenticationScheme)); - - // Act - var result = await controller.EditProfile(null); - - // Assert - var challenge = Assert.IsAssignableFrom(result); - var challengedScheme = Assert.Single(challenge.AuthenticationSchemes); - Assert.Equal(AzureADB2CDefaults.AuthenticationScheme, challengedScheme); - Assert.NotNull(challenge.Properties.RedirectUri); - Assert.Equal("https://localhost/", challenge.Properties.RedirectUri); - Assert.NotNull(challenge.Properties.Items[AzureADB2CDefaults.PolicyKey]); - Assert.Equal("EditProfile", challenge.Properties.Items[AzureADB2CDefaults.PolicyKey]); - } - - private ClaimsPrincipal CreateAuthenticatedPrincipal(string scheme) => - new ClaimsPrincipal(new ClaimsIdentity(scheme)); - - private static ControllerContext CreateControllerContext(ClaimsPrincipal principal = null) - { - principal = principal ?? new ClaimsPrincipal(new ClaimsIdentity()); - var mock = new Mock(); - mock.Setup(authS => authS.AuthenticateAsync(It.IsAny(), It.IsAny())) - .ReturnsAsync( - (ctx, scheme) => - { - if (principal.Identity.IsAuthenticated) - { - return AuthenticateResult.Success(new AuthenticationTicket(principal, scheme)); - } - else - { - return AuthenticateResult.NoResult(); - } - }); - return new ControllerContext() - { - HttpContext = new DefaultHttpContext() - { - RequestServices = new ServiceCollection() - .AddSingleton(mock.Object) - .BuildServiceProvider() - } - }; - } - - [Fact] - public async Task EditProfileCustomScheme_ChallengesAADAzureADB2CCustomSchemeWithEditProfilePolicyFromCustomSchemeAsync() - { - // Arrange - var controller = new AccountController( - new OptionsMonitor( - "Custom", - new AzureADB2COptions() { EditProfilePolicyId = "CustomEditProfile" })) - { - Url = new TestUrlHelper("~/", "https://localhost/") - }; - controller.ControllerContext = CreateControllerContext( - CreateAuthenticatedPrincipal("Custom")); - // Act - var result = await controller.EditProfile("Custom"); - - // Assert - var challenge = Assert.IsAssignableFrom(result); - var challengedScheme = Assert.Single(challenge.AuthenticationSchemes); - Assert.Equal("Custom", challengedScheme); - Assert.NotNull(challenge.Properties.RedirectUri); - Assert.Equal("https://localhost/", challenge.Properties.RedirectUri); - Assert.NotNull(challenge.Properties.Items[AzureADB2CDefaults.PolicyKey]); - Assert.Equal("CustomEditProfile", challenge.Properties.Items[AzureADB2CDefaults.PolicyKey]); - } - - [Fact] - public async Task SignOutNoScheme_SignsOutDefaultCookiesAndDefaultOpenIDConnectAADAzureADB2CSchemesAsync() - { - // Arrange - var options = new AzureADB2COptions() - { - CookieSchemeName = AzureADB2CDefaults.CookieScheme, - OpenIdConnectSchemeName = AzureADB2CDefaults.OpenIdScheme - }; - - var controllerContext = CreateControllerContext( - CreateAuthenticatedPrincipal(AzureADB2CDefaults.AuthenticationScheme)); - - var descriptor = new PageActionDescriptor() - { - AttributeRouteInfo = new AttributeRouteInfo() - { - Template = "/Account/SignedOut" - } - }; - var controller = new AccountController(new OptionsMonitor(AzureADB2CDefaults.AuthenticationScheme, options)) - { - Url = new TestUrlHelper( - controllerContext.HttpContext, - new RouteData(), - descriptor, - "/Account/SignedOut", - "https://localhost/Account/SignedOut"), - ControllerContext = new ControllerContext() - { - HttpContext = controllerContext.HttpContext - } - }; - controller.Request.Scheme = "https"; - - // Act - var result = await controller.SignOut(null); - - // Assert - var signOut = Assert.IsAssignableFrom(result); - Assert.Equal(new[] { AzureADB2CDefaults.CookieScheme, AzureADB2CDefaults.OpenIdScheme }, signOut.AuthenticationSchemes); - Assert.NotNull(signOut.Properties.RedirectUri); - Assert.Equal("https://localhost/Account/SignedOut", signOut.Properties.RedirectUri); - } - - [Fact] - public async Task SignOutProvidedScheme_SignsOutCustomCookiesAndCustomOpenIDConnectAADAzureADB2CSchemesAsync() - { - // Arrange - var options = new AzureADB2COptions() - { - CookieSchemeName = "Cookie", - OpenIdConnectSchemeName = "OpenID" - }; - - var controllerContext = CreateControllerContext( - CreateAuthenticatedPrincipal(AzureADB2CDefaults.AuthenticationScheme)); - var descriptor = new PageActionDescriptor() - { - AttributeRouteInfo = new AttributeRouteInfo() - { - Template = "/Account/SignedOut" - } - }; - - var controller = new AccountController(new OptionsMonitor("Custom", options)) - { - Url = new TestUrlHelper( - controllerContext.HttpContext, - new RouteData(), - descriptor, - "/Account/SignedOut", - "https://localhost/Account/SignedOut"), - ControllerContext = new ControllerContext() - { - HttpContext = controllerContext.HttpContext - } - }; - controller.Request.Scheme = "https"; - - // Act - var result = await controller.SignOut("Custom"); - - // Assert - var signOut = Assert.IsAssignableFrom(result); - Assert.Equal(new[] { "Cookie", "OpenID" }, signOut.AuthenticationSchemes); - } - - private class OptionsMonitor : IOptionsMonitor - { - public OptionsMonitor(string scheme, AzureADB2COptions options) - { - Scheme = scheme; - Options = options; - } - - public AzureADB2COptions CurrentValue => throw new NotImplementedException(); - - public string Scheme { get; } - public AzureADB2COptions Options { get; } - - public AzureADB2COptions Get(string name) - { - if (name == Scheme) - { - return Options; - } - - return null; - } - - public IDisposable OnChange(Action listener) - { - throw new NotImplementedException(); - } - } - - private class TestUrlHelper : IUrlHelper - { - public TestUrlHelper(string contentPath, string url) - { - ContentPath = contentPath; - Url = url; - } - - public TestUrlHelper( - HttpContext context, - RouteData routeData, - ActionDescriptor descriptor, - string contentPath, - string url) - { - HttpContext = context; - RouteData = routeData; - ActionDescriptor = descriptor; - ContentPath = contentPath; - Url = url; - } - - public ActionContext ActionContext => - new ActionContext(HttpContext, RouteData, ActionDescriptor); - - public string ContentPath { get; } - public string Url { get; } - public HttpContext HttpContext { get; } - public RouteData RouteData { get; } - public ActionDescriptor ActionDescriptor { get; } - - public string Action(UrlActionContext actionContext) - { - throw new NotImplementedException(); - } - - public string Content(string contentPath) - { - if (ContentPath == contentPath) - { - return Url; - } - return ""; - } - - public bool IsLocalUrl(string url) - { - throw new NotImplementedException(); - } - - public string Link(string routeName, object values) - { - throw new NotImplementedException(); - } - - public string RouteUrl(UrlRouteContext routeContext) - { - if (routeContext.Values is RouteValueDictionary dicionary && - dicionary.TryGetValue("page", out var page) && - page is string pagePath && - ContentPath == pagePath) - { - return Url; - } - - return null; - } - } - } -} diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test.csproj b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test.csproj deleted file mode 100644 index 65c330077b0e..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test.csproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - $(DefaultNetCoreTargetFramework) - Microsoft.AspNetCore.Authentication.AzureADB2C.UI - - $(NoWarn);CS0618 - - - - - PreserveNewest - - - - - - - - diff --git a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/xunit.runner.json b/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/xunit.runner.json deleted file mode 100644 index 42db7ef95e94..000000000000 --- a/src/Azure/AzureAD/Authentication.AzureADB2C.UI/test/xunit.runner.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "shadowCopy": false -} diff --git a/src/Azure/AzureAD/AzureAD.ruleset b/src/Azure/AzureAD/AzureAD.ruleset deleted file mode 100644 index 6b6c71d044e0..000000000000 --- a/src/Azure/AzureAD/AzureAD.ruleset +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/Azure/AzureAD/Directory.Build.props b/src/Azure/AzureAD/Directory.Build.props deleted file mode 100644 index 647d706b5aad..000000000000 --- a/src/Azure/AzureAD/Directory.Build.props +++ /dev/null @@ -1,8 +0,0 @@ - - - - - xUnit1026:$(WarningsNotAsErrors) - $(MSBuildThisFileDirectory)AzureAD.ruleset - - diff --git a/src/Azure/AzureAD/README.md b/src/Azure/AzureAD/README.md deleted file mode 100644 index 6086294419d5..000000000000 --- a/src/Azure/AzureAD/README.md +++ /dev/null @@ -1,4 +0,0 @@ -Azure Active Directory Integration -================================== - -ASP.NET Core Azure Active Directory Integration provides seamless authentication integration with different Azure Active Directory services like Azure Active Directory and Azure Active Directory B2C for ASP.NET Core applications. \ No newline at end of file diff --git a/src/Azure/AzureAD/test/FunctionalTests/ApiAuthenticationTests.cs b/src/Azure/AzureAD/test/FunctionalTests/ApiAuthenticationTests.cs deleted file mode 100644 index 1bd9718ac3c5..000000000000 --- a/src/Azure/AzureAD/test/FunctionalTests/ApiAuthenticationTests.cs +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System.Net; -using System.Threading.Tasks; -using AzureAD.WebSite; -using Microsoft.AspNetCore.Authentication.AzureAD.UI; -using Microsoft.AspNetCore.Authentication.AzureADB2C.UI; -using Microsoft.AspNetCore.Authentication.JwtBearer; -using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.AspNetCore.TestHost; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests -{ - public class ApiAuthenticationTests : IClassFixture> - { - public ApiAuthenticationTests(WebApplicationFactory fixture) - { - Factory = fixture; - } - - public WebApplicationFactory Factory { get; } - - [Fact] - public async Task BearerAzureAD_Challenges_UnauthorizedRequests() - { - // Arrange - var client = Factory.WithWebHostBuilder(builder => builder.ConfigureTestServices( - services => - { - services.AddAuthentication(AzureADDefaults.BearerAuthenticationScheme) - .AddAzureADBearer(o => - { - o.Instance = "https://login.microsoftonline.com/"; - o.Domain = "test.onmicrosoft.com"; - o.ClientId = "ClientId"; - o.TenantId = "TenantId"; - }); - - services.Configure(AzureADDefaults.JwtBearerAuthenticationScheme, o => - { - o.Configuration = new OpenIdConnectConfiguration() - { - Issuer = "https://www.example.com", - }; - }); - })).CreateDefaultClient(); - - // Act - var response = await client.GetAsync("/api/get"); - - // Assert - Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); - } - - [Fact] - public async Task BearerAzureADB2C_Challenges_UnauthorizedRequests() - { - // Arrange - var client = Factory.WithWebHostBuilder(builder => builder.ConfigureTestServices( - services => - { - services.AddAuthentication(AzureADB2CDefaults.BearerAuthenticationScheme) - .AddAzureADB2CBearer(o => - { - o.Instance = "https://login.microsoftonline.com/"; - o.Domain = "test.onmicrosoft.com"; - o.ClientId = "ClientId"; - o.SignUpSignInPolicyId = "B2c_1_SiSu"; - }); - - services.Configure(AzureADB2CDefaults.JwtBearerAuthenticationScheme, o => - { - o.Configuration = new OpenIdConnectConfiguration() - { - Issuer = "https://www.example.com", - }; - }); - })).CreateDefaultClient(); - - // Act - var response = await client.GetAsync("/api/get"); - - // Assert - Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); - } - } -} \ No newline at end of file diff --git a/src/Azure/AzureAD/test/FunctionalTests/Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj b/src/Azure/AzureAD/test/FunctionalTests/Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj deleted file mode 100644 index c577b2b9c7d5..000000000000 --- a/src/Azure/AzureAD/test/FunctionalTests/Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj +++ /dev/null @@ -1,44 +0,0 @@ - - - - $(DefaultNetCoreTargetFramework) - - true - - $(NoWarn);CS0618 - - - - - - - - - - - - - - - - - <_PublishFiles Include="$(ArtifactsBinDir)AzureAD.WebSite\$(Configuration)\$(DefaultNetCoreTargetFramework)\AzureAD.WebSite.deps.json" /> - - - - - - - - - diff --git a/src/Azure/AzureAD/test/FunctionalTests/WebAuthenticationTests.cs b/src/Azure/AzureAD/test/FunctionalTests/WebAuthenticationTests.cs deleted file mode 100644 index d724ee2561fd..000000000000 --- a/src/Azure/AzureAD/test/FunctionalTests/WebAuthenticationTests.cs +++ /dev/null @@ -1,219 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using System.Net; -using System.Threading.Tasks; -using AzureAD.WebSite; -using Microsoft.AspNetCore.Authentication.AzureAD.UI; -using Microsoft.AspNetCore.Authentication.AzureADB2C.UI; -using Microsoft.AspNetCore.Authentication.OpenIdConnect; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc.Authorization; -using Microsoft.AspNetCore.Mvc.Testing; -using Microsoft.AspNetCore.TestHost; -using Microsoft.AspNetCore.WebUtilities; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Primitives; -using Microsoft.IdentityModel.Protocols.OpenIdConnect; -using Xunit; - -namespace Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests -{ - public class WebAuthenticationTests : IClassFixture> - { - public WebAuthenticationTests(WebApplicationFactory fixture) - { - Factory = fixture; - } - - public WebApplicationFactory Factory { get; } - - public static TheoryData NotAddedEndpoints => - new TheoryData() - { - "/AzureAD/Account/AccessDenied", - "/AzureAD/Account/Error", - "/AzureAD/Account/SignedOut", - "/AzureAD/Account/SignIn", - "/AzureAD/Account/SignOut", - "/AzureADB2C/Account/AccessDenied", - "/AzureADB2C/Account/Error", - "/AzureADB2C/Account/SignedOut", - "/AzureADB2C/Account/SignIn", - "/AzureADB2C/Account/ResetPassword", - "/AzureADB2C/Account/EditProfile", - "/AzureADB2C/Account/SignOut", - }; - - [Theory] - [MemberData(nameof(NotAddedEndpoints))] - public async Task Endpoints_NotAvailable_When_Authentication_NotAdded(string endpoint) - { - // Act & Assert - var response = await Factory.CreateDefaultClient().GetAsync(endpoint); - - // Assert - Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); - } - - public static TheoryData AddedEndpointsStatusCodesAD => - new TheoryData() - { - { "/AzureAD/Account/AccessDenied", HttpStatusCode.OK }, - { "/AzureAD/Account/Error", HttpStatusCode.OK }, - { "/AzureAD/Account/SignedOut", HttpStatusCode.OK }, - { "/AzureAD/Account/SignIn", HttpStatusCode.Redirect }, - { "/AzureAD/Account/SignOut", HttpStatusCode.Redirect }, - }; - - [Theory] - [MemberData(nameof(AddedEndpointsStatusCodesAD))] - public async Task ADEndpoints_AreAvailable_When_Authentication_IsAdded(string endpoint, HttpStatusCode expectedStatusCode) - { - // Act & Assert - var client = Factory.WithWebHostBuilder(builder => builder.ConfigureTestServices( - services => - { - services - .AddAuthentication(AzureADDefaults.AuthenticationScheme) - .AddAzureAD(o => - { - o.Instance = "https://login.microsoftonline.com/"; - o.Domain = "test.onmicrosoft.com"; - o.ClientId = "ClientId"; - o.TenantId = "TenantId"; - }); - - services.Configure(AzureADDefaults.OpenIdScheme, o => - { - o.Configuration = new OpenIdConnectConfiguration() - { - Issuer = "https://www.example.com", - TokenEndpoint = "https://www.example.com/token", - AuthorizationEndpoint = "https://www.example.com/authorize", - EndSessionEndpoint = "https://www.example.com/logout" - }; - }); - - services.AddMvc(o => o.Filters.Add( - new AuthorizeFilter(new AuthorizationPolicyBuilder(new[] { AzureADDefaults.AuthenticationScheme }) - .RequireAuthenticatedUser().Build()))); - })).CreateDefaultClient(); - - var response = await client.GetAsync(endpoint); - - // Assert - Assert.Equal(expectedStatusCode, response.StatusCode); - } - - public static TheoryData AddedEndpointsStatusCodesADB2C => - new TheoryData() - { - { "/AzureADB2C/Account/AccessDenied", HttpStatusCode.OK }, - { "/AzureADB2C/Account/Error", HttpStatusCode.OK }, - { "/AzureADB2C/Account/SignedOut", HttpStatusCode.OK }, - { "/AzureADB2C/Account/SignIn", HttpStatusCode.Redirect }, - { "/AzureADB2C/Account/ResetPassword", HttpStatusCode.Redirect }, - { "/AzureADB2C/Account/EditProfile", HttpStatusCode.Redirect }, - { "/AzureADB2C/Account/SignOut", HttpStatusCode.Redirect } - }; - - [Theory] - [MemberData(nameof(AddedEndpointsStatusCodesADB2C))] - public async Task ADB2CEndpoints_AreAvailable_When_Authentication_IsAdded(string endpoint, HttpStatusCode expectedStatusCode) - { - // Act & Assert - var client = Factory.WithWebHostBuilder(builder => builder.ConfigureTestServices( - services => - { - services - .AddAuthentication(AzureADB2CDefaults.AuthenticationScheme) - .AddAzureADB2C(o => - { - o.Instance = "https://login.microsoftonline.com/tfp/"; - o.ClientId = "ClientId"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "test.onmicrosoft.com"; - o.SignUpSignInPolicyId = "B2C_1_SiUpIn"; - o.ResetPasswordPolicyId = "B2C_1_SSPR"; - o.EditProfilePolicyId = "B2C_1_SiPe"; - }); - - services.Configure(AzureADB2CDefaults.OpenIdScheme, o => - { - o.Configuration = new OpenIdConnectConfiguration() - { - Issuer = "https://www.example.com", - TokenEndpoint = "https://www.example.com/token", - AuthorizationEndpoint = "https://www.example.com/authorize", - EndSessionEndpoint = "https://www.example.com/logout" - }; - }); - - services.AddMvc(o => o.Filters.Add( - new AuthorizeFilter(new AuthorizationPolicyBuilder(new[] { AzureADB2CDefaults.AuthenticationScheme }) - .RequireAuthenticatedUser().Build()))); - })).CreateDefaultClient(); - - var response = await client.GetAsync(endpoint); - - // Assert - Assert.Equal(expectedStatusCode, response.StatusCode); - } - - [Fact] - public async Task ADB2C_EndToEnd_PasswordReset() - { - var client = Factory.WithWebHostBuilder(builder => builder.ConfigureTestServices( - services => - { - services - .AddAuthentication(AzureADB2CDefaults.AuthenticationScheme) - .AddAzureADB2C(o => - { - o.Instance = "https://login.microsoftonline.com/tfp/"; - o.ClientId = "ClientId"; - o.CallbackPath = "/signin-oidc"; - o.Domain = "test.onmicrosoft.com"; - o.SignUpSignInPolicyId = "B2C_1_SiUpIn"; - o.ResetPasswordPolicyId = "B2C_1_SSPR"; - o.EditProfilePolicyId = "B2C_1_SiPe"; - }); - - services.Configure(AzureADB2CDefaults.OpenIdScheme, o => - { - o.Configuration = new OpenIdConnectConfiguration() - { - Issuer = "https://www.example.com", - TokenEndpoint = "https://www.example.com/token", - AuthorizationEndpoint = "https://www.example.com/authorize", - EndSessionEndpoint = "https://www.example.com/logout" - }; - // CookieContainer doesn't allow cookies from other paths - o.CorrelationCookie.Path = "/"; - o.NonceCookie.Path = "/"; - }); - - services.AddMvc(o => o.Filters.Add( - new AuthorizeFilter(new AuthorizationPolicyBuilder(new[] { AzureADB2CDefaults.AuthenticationScheme }) - .RequireAuthenticatedUser().Build()))); - })).CreateClient(new WebApplicationFactoryClientOptions() { AllowAutoRedirect = false }); - - var response = await client.GetAsync("/api/get"); - Assert.Equal(HttpStatusCode.Redirect, response.StatusCode); - - var location = response.Headers.Location; - Assert.StartsWith("https://www.example.com/authorize", location.AbsoluteUri); - var queryString = location.Query; - var query = QueryHelpers.ParseQuery(queryString); - var state = query["state"]; - Assert.False(StringValues.IsNullOrEmpty(state)); - - // Mock Authorization response - response = await client.GetAsync($"/signin-oidc?error=access_denied&error_description=AADB2C90118&state={state}"); - - Assert.Equal(HttpStatusCode.Redirect, response.StatusCode); - Assert.Equal("/AzureADB2C/Account/ResetPassword/AzureADB2C", response.Headers.Location.OriginalString); - } - } -} diff --git a/src/Azure/AzureAD/test/FunctionalTests/xunit.runner.json b/src/Azure/AzureAD/test/FunctionalTests/xunit.runner.json deleted file mode 100644 index 42db7ef95e94..000000000000 --- a/src/Azure/AzureAD/test/FunctionalTests/xunit.runner.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "shadowCopy": false -} diff --git a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/AzureAD.WebSite.csproj b/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/AzureAD.WebSite.csproj deleted file mode 100644 index c00bf75a2e80..000000000000 --- a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/AzureAD.WebSite.csproj +++ /dev/null @@ -1,16 +0,0 @@ - - - - $(DefaultNetCoreTargetFramework) - - - - - - - - - - - - diff --git a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Controllers/TestController.cs b/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Controllers/TestController.cs deleted file mode 100644 index 5340cd1a1657..000000000000 --- a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Controllers/TestController.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.using Microsoft.AspNetCore.Authorization; - -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace AzureAD.WebSite.Controllers -{ - public class TestController : Controller - { - [Authorize] - [HttpGet("/api/get")] - public IActionResult Get() => Ok(); - } -} diff --git a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Program.cs b/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Program.cs deleted file mode 100644 index 998a9ab3243b..000000000000 --- a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Program.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Reflection; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; - -namespace AzureAD.WebSite -{ - public class Program - { - public static void Main(string[] args) - { - CreateWebHostBuilder(args).Build().Run(); - } - - public static IWebHostBuilder CreateWebHostBuilder(string[] args) - { - return WebHost.CreateDefaultBuilder() - .UseStartup(); - } - } -} diff --git a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Startup.cs b/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Startup.cs deleted file mode 100644 index d59b400ae46a..000000000000 --- a/src/Azure/AzureAD/test/testassets/AzureAD.WebSite/Startup.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.Extensions.DependencyInjection; - -namespace AzureAD.WebSite -{ - public class Startup - { - public void ConfigureServices(IServiceCollection services) - { - services.AddMvc(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseRouting(); - - app.UseAuthentication(); - app.UseAuthorization(); - - app.UseEndpoints(endpoints => - { - endpoints.MapDefaultControllerRoute(); - endpoints.MapRazorPages(); - }); - } - } -} From 8bc71de9d8757cfa2bb8684215fe42fa5ee5484a Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 18 Nov 2020 11:22:36 -0800 Subject: [PATCH 2/7] Update Microsoft.DotNet.Web.ProjectTemplates.csproj --- .../Microsoft.DotNet.Web.ProjectTemplates.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj b/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj index c470339dc3fa..516b2c56fdc8 100644 --- a/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj +++ b/src/ProjectTemplates/Web.ProjectTemplates/Microsoft.DotNet.Web.ProjectTemplates.csproj @@ -30,8 +30,6 @@ - - From 7bf7c2e959e1d9a1f81277383af65dcf64d1075d Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 18 Nov 2020 11:23:27 -0800 Subject: [PATCH 3/7] Update ProjectReferences.props --- eng/ProjectReferences.props | 2 -- 1 file changed, 2 deletions(-) diff --git a/eng/ProjectReferences.props b/eng/ProjectReferences.props index a02777218241..32bf447126f2 100644 --- a/eng/ProjectReferences.props +++ b/eng/ProjectReferences.props @@ -119,8 +119,6 @@ - - From 138d7e8bcae07114faece6d11ad2311738367a89 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 18 Nov 2020 11:23:59 -0800 Subject: [PATCH 4/7] Update Baseline.xml --- eng/Baseline.xml | 2 -- 1 file changed, 2 deletions(-) diff --git a/eng/Baseline.xml b/eng/Baseline.xml index 6c63e0b86c92..51c665574bcb 100644 --- a/eng/Baseline.xml +++ b/eng/Baseline.xml @@ -20,8 +20,6 @@ Update this list when preparing for a new patch. - - From 018d6e93ece3a4ddb3e8265c02578c1da5b2b634 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 18 Nov 2020 11:24:47 -0800 Subject: [PATCH 5/7] Update Baseline.Designer.props --- eng/Baseline.Designer.props | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/eng/Baseline.Designer.props b/eng/Baseline.Designer.props index fa0cfea3db10..bcf42164253e 100644 --- a/eng/Baseline.Designer.props +++ b/eng/Baseline.Designer.props @@ -75,22 +75,6 @@ 5.0.0 - - - 5.0.0 - - - - - - - - 5.0.0 - - - - - 5.0.0 @@ -898,4 +882,4 @@ 5.0.0 - \ No newline at end of file + From 740996b3c2a999cbbc33e28410c17c037967e7e8 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 18 Nov 2020 12:40:33 -0800 Subject: [PATCH 6/7] Clean up sln --- AspNetCore.sln | 131 +------------------------------------------------ 1 file changed, 1 insertion(+), 130 deletions(-) diff --git a/AspNetCore.sln b/AspNetCore.sln index 15bd7d93fa0b..07d6ee38a92c 100644 --- a/AspNetCore.sln +++ b/AspNetCore.sln @@ -249,24 +249,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Antifo EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Azure", "Azure", "{DFDEED51-6B9B-41B9-A684-9F3FFC07C9B4}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AzureAD", "AzureAD", "{2757D342-5E89-4C4B-9659-714AC8536FD4}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Authentication.AzureAD.UI", "Authentication.AzureAD.UI", "{CE6853C2-73AE-42EB-AD8C-2A094B2A4A36}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.AzureAD.UI", "src\Azure\AzureAD\Authentication.AzureAD.UI\src\Microsoft.AspNetCore.Authentication.AzureAD.UI.csproj", "{42E30C98-1358-497F-960B-E1AA17F46704}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.AzureAD.UI.Test", "src\Azure\AzureAD\Authentication.AzureAD.UI\test\Microsoft.AspNetCore.Authentication.AzureAD.UI.Test.csproj", "{4870B11E-7F67-4757-BC9A-45E5895AC712}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Authentication.AzureADB2C.UI", "Authentication.AzureADB2C.UI", "{B95A22C8-71B7-49DE-94B2-16402A36B914}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.AzureADB2C.UI", "src\Azure\AzureAD\Authentication.AzureADB2C.UI\src\Microsoft.AspNetCore.Authentication.AzureADB2C.UI.csproj", "{600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test", "src\Azure\AzureAD\Authentication.AzureADB2C.UI\test\Microsoft.AspNetCore.Authentication.AzureADB2C.UI.Test.csproj", "{27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{16653D2A-AC79-44ED-B908-2EEB58684C50}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests", "src\Azure\AzureAD\test\FunctionalTests\Microsoft.AspNetCore.Authentication.AzureAD.FunctionalTests.csproj", "{B70B1843-4360-4731-9D5C-599189CC1198}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kestrel", "Kestrel", "{4FDDC525-4E60-4CAF-83A3-261C5B43721F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Kestrel", "Kestrel", "{89472057-8BB2-44A8-B0FC-D9F3ADB1181C}" @@ -1539,7 +1521,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Sdk", "Sdk", "{E83B0BCC-A8E EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HostingStartup", "src\SiteExtensions\Sdk\HostingStartup\HostingStartup.csproj", "{5D6F99C5-D292-4459-B8BD-8E4AD42E1B21}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IgnitorSample", "src\Components\Samples\IgnitorSample\IgnitorSample.csproj", "{CAFD1885-B87B-4A7A-8BE6-86B0C238C2B1}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IgnitorSample", "src\Components\Samples\IgnitorSample\IgnitorSample.csproj", "{CAFD1885-B87B-4A7A-8BE6-86B0C238C2B1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.SignalR.Tests.Utils", "src\SignalR\common\testassets\Tests.Utils\Microsoft.AspNetCore.SignalR.Tests.Utils.csproj", "{C1CDD339-B51B-42BE-99F2-F39A4EC0D404}" EndProject @@ -2205,66 +2187,6 @@ Global {78C5ACC3-6718-4682-B350-737EDA1E4F35}.Release|x64.Build.0 = Release|Any CPU {78C5ACC3-6718-4682-B350-737EDA1E4F35}.Release|x86.ActiveCfg = Release|Any CPU {78C5ACC3-6718-4682-B350-737EDA1E4F35}.Release|x86.Build.0 = Release|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Debug|Any CPU.Build.0 = Debug|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Debug|x64.ActiveCfg = Debug|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Debug|x64.Build.0 = Debug|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Debug|x86.ActiveCfg = Debug|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Debug|x86.Build.0 = Debug|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Release|Any CPU.ActiveCfg = Release|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Release|Any CPU.Build.0 = Release|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Release|x64.ActiveCfg = Release|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Release|x64.Build.0 = Release|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Release|x86.ActiveCfg = Release|Any CPU - {42E30C98-1358-497F-960B-E1AA17F46704}.Release|x86.Build.0 = Release|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Debug|Any CPU.Build.0 = Debug|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Debug|x64.ActiveCfg = Debug|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Debug|x64.Build.0 = Debug|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Debug|x86.ActiveCfg = Debug|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Debug|x86.Build.0 = Debug|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Release|Any CPU.ActiveCfg = Release|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Release|Any CPU.Build.0 = Release|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Release|x64.ActiveCfg = Release|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Release|x64.Build.0 = Release|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Release|x86.ActiveCfg = Release|Any CPU - {4870B11E-7F67-4757-BC9A-45E5895AC712}.Release|x86.Build.0 = Release|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Debug|x64.ActiveCfg = Debug|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Debug|x64.Build.0 = Debug|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Debug|x86.ActiveCfg = Debug|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Debug|x86.Build.0 = Debug|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Release|Any CPU.Build.0 = Release|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Release|x64.ActiveCfg = Release|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Release|x64.Build.0 = Release|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Release|x86.ActiveCfg = Release|Any CPU - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A}.Release|x86.Build.0 = Release|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Debug|Any CPU.Build.0 = Debug|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Debug|x64.ActiveCfg = Debug|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Debug|x64.Build.0 = Debug|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Debug|x86.ActiveCfg = Debug|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Debug|x86.Build.0 = Debug|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Release|Any CPU.ActiveCfg = Release|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Release|Any CPU.Build.0 = Release|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Release|x64.ActiveCfg = Release|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Release|x64.Build.0 = Release|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Release|x86.ActiveCfg = Release|Any CPU - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0}.Release|x86.Build.0 = Release|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Debug|x64.ActiveCfg = Debug|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Debug|x64.Build.0 = Debug|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Debug|x86.ActiveCfg = Debug|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Debug|x86.Build.0 = Debug|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Release|Any CPU.Build.0 = Release|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Release|x64.ActiveCfg = Release|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Release|x64.Build.0 = Release|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Release|x86.ActiveCfg = Release|Any CPU - {B70B1843-4360-4731-9D5C-599189CC1198}.Release|x86.Build.0 = Release|Any CPU {D40C86C9-0E5D-4974-84D8-A835B58B2A8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D40C86C9-0E5D-4974-84D8-A835B58B2A8F}.Debug|Any CPU.Build.0 = Debug|Any CPU {D40C86C9-0E5D-4974-84D8-A835B58B2A8F}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -4437,42 +4359,6 @@ Global {8A745E35-8098-4EB4-AC55-587B9F0DC4BE}.Release|x64.Build.0 = Release|Any CPU {8A745E35-8098-4EB4-AC55-587B9F0DC4BE}.Release|x86.ActiveCfg = Release|Any CPU {8A745E35-8098-4EB4-AC55-587B9F0DC4BE}.Release|x86.Build.0 = Release|Any CPU - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Debug|Any CPU.ActiveCfg = Debug|x64 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Debug|Any CPU.Build.0 = Debug|x64 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Debug|x64.ActiveCfg = Debug|x64 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Debug|x64.Build.0 = Debug|x64 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Debug|x86.ActiveCfg = Debug|x86 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Debug|x86.Build.0 = Debug|x86 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Release|Any CPU.ActiveCfg = Release|x64 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Release|Any CPU.Build.0 = Release|x64 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Release|x64.ActiveCfg = Release|x64 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Release|x64.Build.0 = Release|x64 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Release|x86.ActiveCfg = Release|x86 - {4BCF2228-159D-4547-8D54-CDD2252D076A}.Release|x86.Build.0 = Release|x86 - {A7802482-55BA-4D95-BE79-8A601131F527}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Debug|x64.ActiveCfg = Debug|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Debug|x64.Build.0 = Debug|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Debug|x86.ActiveCfg = Debug|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Debug|x86.Build.0 = Debug|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Release|Any CPU.Build.0 = Release|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Release|x64.ActiveCfg = Release|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Release|x64.Build.0 = Release|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Release|x86.ActiveCfg = Release|Any CPU - {A7802482-55BA-4D95-BE79-8A601131F527}.Release|x86.Build.0 = Release|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Debug|x64.ActiveCfg = Debug|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Debug|x64.Build.0 = Debug|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Debug|x86.ActiveCfg = Debug|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Debug|x86.Build.0 = Debug|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Release|Any CPU.Build.0 = Release|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Release|x64.ActiveCfg = Release|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Release|x64.Build.0 = Release|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Release|x86.ActiveCfg = Release|Any CPU - {81947277-035F-41F6-A1D4-8EA362CB46D2}.Release|x86.Build.0 = Release|Any CPU {F5C54062-B19C-4291-A816-F1B5A167369A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {F5C54062-B19C-4291-A816-F1B5A167369A}.Debug|Any CPU.Build.0 = Debug|Any CPU {F5C54062-B19C-4291-A816-F1B5A167369A}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -7573,15 +7459,6 @@ Global {C73F3203-4E8C-46BC-A299-1A5BB81DA2C3} = {021E9BF3-2D3D-4169-834E-718ABE0E5B68} {78C5ACC3-6718-4682-B350-737EDA1E4F35} = {B55A5DE1-5AF3-4B18-AF04-C1735B071DA6} {DFDEED51-6B9B-41B9-A684-9F3FFC07C9B4} = {017429CC-C5FB-48B4-9C46-034E29EE2F06} - {2757D342-5E89-4C4B-9659-714AC8536FD4} = {DFDEED51-6B9B-41B9-A684-9F3FFC07C9B4} - {CE6853C2-73AE-42EB-AD8C-2A094B2A4A36} = {2757D342-5E89-4C4B-9659-714AC8536FD4} - {42E30C98-1358-497F-960B-E1AA17F46704} = {CE6853C2-73AE-42EB-AD8C-2A094B2A4A36} - {4870B11E-7F67-4757-BC9A-45E5895AC712} = {CE6853C2-73AE-42EB-AD8C-2A094B2A4A36} - {B95A22C8-71B7-49DE-94B2-16402A36B914} = {2757D342-5E89-4C4B-9659-714AC8536FD4} - {600BF48B-F5DF-4C9D-A5A7-635A8DD6C32A} = {B95A22C8-71B7-49DE-94B2-16402A36B914} - {27DF3ACF-F3ED-4D76-BFCB-57251892ABC0} = {B95A22C8-71B7-49DE-94B2-16402A36B914} - {16653D2A-AC79-44ED-B908-2EEB58684C50} = {2757D342-5E89-4C4B-9659-714AC8536FD4} - {B70B1843-4360-4731-9D5C-599189CC1198} = {16653D2A-AC79-44ED-B908-2EEB58684C50} {4FDDC525-4E60-4CAF-83A3-261C5B43721F} = {0ACCEDA7-339C-4B4D-8DD4-1AC271F31C04} {89472057-8BB2-44A8-B0FC-D9F3ADB1181C} = {4FDDC525-4E60-4CAF-83A3-261C5B43721F} {D40C86C9-0E5D-4974-84D8-A835B58B2A8F} = {89472057-8BB2-44A8-B0FC-D9F3ADB1181C} @@ -7879,12 +7756,6 @@ Global {EE65018D-FA12-461D-B2C5-44CA6E385530} = {E5963C9F-20A6-4385-B364-814D2581FADF} {A8E1962B-688E-44B3-81F3-BBB9891534CE} = {EE65018D-FA12-461D-B2C5-44CA6E385530} {8A745E35-8098-4EB4-AC55-587B9F0DC4BE} = {EE65018D-FA12-461D-B2C5-44CA6E385530} - {884AED21-7931-42A3-B08A-E58F7B0D6E7F} = {017429CC-C5FB-48B4-9C46-034E29EE2F06} - {8DA88110-5A13-41A9-9F9D-674D921EB442} = {884AED21-7931-42A3-B08A-E58F7B0D6E7F} - {4BCF2228-159D-4547-8D54-CDD2252D076A} = {8DA88110-5A13-41A9-9F9D-674D921EB442} - {2D347127-3B13-47B1-84EC-770A9C1E11B0} = {884AED21-7931-42A3-B08A-E58F7B0D6E7F} - {A7802482-55BA-4D95-BE79-8A601131F527} = {2D347127-3B13-47B1-84EC-770A9C1E11B0} - {81947277-035F-41F6-A1D4-8EA362CB46D2} = {2D347127-3B13-47B1-84EC-770A9C1E11B0} {8C4006DF-FF48-46B6-A124-10B1EEAA266E} = {822D1519-77F0-484A-B9AB-F694C2CC25F1} {F5C54062-B19C-4291-A816-F1B5A167369A} = {8C4006DF-FF48-46B6-A124-10B1EEAA266E} {056535BC-3E30-49E2-BE3B-630C62E641A5} = {1A0EFF9F-E699-4303-AE50-BFAF9804EEB6} From 574182b74b40ae00fff041c293fac700469a3855 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Wed, 18 Nov 2020 13:42:05 -0800 Subject: [PATCH 7/7] Update Baseline.Designer.props --- eng/Baseline.Designer.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/Baseline.Designer.props b/eng/Baseline.Designer.props index bcf42164253e..cd6dd31dfd28 100644 --- a/eng/Baseline.Designer.props +++ b/eng/Baseline.Designer.props @@ -882,4 +882,4 @@ 5.0.0 - + \ No newline at end of file