From a32be4ed984b00e92bbfaffeb3c742f87e10037e Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 10:31:57 +0100 Subject: [PATCH 01/13] CR feedback left over from #10227 --- .../Components/src/Auth/AuthenticationState.cs | 10 +++++----- .../Components/src/Auth/AuthenticationStateProvider.cs | 7 ++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/Components/Components/src/Auth/AuthenticationState.cs b/src/Components/Components/src/Auth/AuthenticationState.cs index 2a145d44f350..d90090c7c817 100644 --- a/src/Components/Components/src/Auth/AuthenticationState.cs +++ b/src/Components/Components/src/Auth/AuthenticationState.cs @@ -11,11 +11,6 @@ namespace Microsoft.AspNetCore.Components /// public class AuthenticationState { - /// - /// Gets a that describes the current user. - /// - public ClaimsPrincipal User { get; } - /// /// Constructs an instance of . /// @@ -24,5 +19,10 @@ public AuthenticationState(ClaimsPrincipal user) { User = user ?? throw new ArgumentNullException(nameof(user)); } + + /// + /// Gets a that describes the current user. + /// + public ClaimsPrincipal User { get; } } } diff --git a/src/Components/Components/src/Auth/AuthenticationStateProvider.cs b/src/Components/Components/src/Auth/AuthenticationStateProvider.cs index ffd2fc252a5d..e9e3e3c7728b 100644 --- a/src/Components/Components/src/Auth/AuthenticationStateProvider.cs +++ b/src/Components/Components/src/Auth/AuthenticationStateProvider.cs @@ -12,19 +12,16 @@ namespace Microsoft.AspNetCore.Components public abstract class AuthenticationStateProvider { /// - /// Gets an instance that describes - /// the current user. + /// Asynchronously gets an that describes the current user. /// - /// An instance that describes the current user. + /// A task that, when resolved, gives an instance that describes the current user. public abstract Task GetAuthenticationStateAsync(); /// /// An event that provides notification when the /// has changed. For example, this event may be raised if a user logs in or out. /// -#pragma warning disable 0067 // "Never used" (it's only raised by subclasses) public event AuthenticationStateChangedHandler AuthenticationStateChanged; -#pragma warning restore 0067 /// /// Raises the event. From d3ff322737a8e1a02276753250883e7aab07ea10 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 11:03:44 +0100 Subject: [PATCH 02/13] Begin adding E2E test case --- .../CascadingAuthenticationStateChild.razor | 44 +++++++++++++++++++ .../CascadingAuthenticationStateParent.razor | 3 ++ .../test/testassets/BasicTestApp/Index.razor | 1 + 3 files changed, 48 insertions(+) create mode 100644 src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor create mode 100644 src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateParent.razor diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor new file mode 100644 index 000000000000..947872d9009b --- /dev/null +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor @@ -0,0 +1,44 @@ +@using System.Security.Claims + +@if (user == null) +{ + Requesting authentication state... +} +else +{ +

+ Authenticated: + @user.Identity.IsAuthenticated +

+ +

+ Name: + @user.Identity.Name +

+ +

+ Test claim: + @if (user.HasClaim(TestClaimPredicate) == true) + { + @user.Claims.Single(c => TestClaimPredicate(c)).Value + } + else + { + (none) + } +

+} + +@functions +{ + static Predicate TestClaimPredicate = c => c.Type == "test-claim"; + + ClaimsPrincipal user; + + [CascadingParameter] Task AuthenticationStateTask { get; set; } + + protected override async Task OnParametersSetAsync() + { + user = (await AuthenticationStateTask).User; + } +} diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateParent.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateParent.razor new file mode 100644 index 000000000000..c32d8a92ef0c --- /dev/null +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateParent.razor @@ -0,0 +1,3 @@ + + + diff --git a/src/Components/test/testassets/BasicTestApp/Index.razor b/src/Components/test/testassets/BasicTestApp/Index.razor index 7348a5626fdb..a7cc3e053984 100644 --- a/src/Components/test/testassets/BasicTestApp/Index.razor +++ b/src/Components/test/testassets/BasicTestApp/Index.razor @@ -54,6 +54,7 @@ + @if (SelectedComponentType != null) From e58a6ac348cfbe5415ff971396507f7aa7326aac Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 12:40:19 +0100 Subject: [PATCH 03/13] Add cookie auth and test login page --- .../CascadingAuthenticationStateChild.razor | 12 ++-- .../TestServer/Components.TestServer.csproj | 3 +- .../TestServer/Pages/Authentication.cshtml | 72 +++++++++++++++++++ .../test/testassets/TestServer/Startup.cs | 4 ++ 4 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 src/Components/test/testassets/TestServer/Pages/Authentication.cshtml diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor index 947872d9009b..fb49cea39f29 100644 --- a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor @@ -8,27 +8,31 @@ else {

Authenticated: - @user.Identity.IsAuthenticated + @user.Identity.IsAuthenticated

Name: - @user.Identity.Name + @user.Identity.Name

Test claim: @if (user.HasClaim(TestClaimPredicate) == true) { - @user.Claims.Single(c => TestClaimPredicate(c)).Value + @user.Claims.Single(c => TestClaimPredicate(c)).Value } else { - (none) + (none) }

} +
+ +

To change the underlying authentication state, go here.

+ @functions { static Predicate TestClaimPredicate = c => c.Type == "test-claim"; diff --git a/src/Components/test/testassets/TestServer/Components.TestServer.csproj b/src/Components/test/testassets/TestServer/Components.TestServer.csproj index 3566f065b3cd..bf0a093d111c 100644 --- a/src/Components/test/testassets/TestServer/Components.TestServer.csproj +++ b/src/Components/test/testassets/TestServer/Components.TestServer.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.0 @@ -6,6 +6,7 @@ + diff --git a/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml b/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml new file mode 100644 index 000000000000..f3314230570e --- /dev/null +++ b/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml @@ -0,0 +1,72 @@ +@page +@using Microsoft.AspNetCore.Authentication +@using System.Security.Claims + + + + Authentication + + +

Authentication

+

+ This is a completely fake login mechanism for automated test purposes. + It accepts any username, with no password. +

+

+ Obviously you should not do this in real applications. + See also: documentation on configuring a real login system. +

+ +
+

Sign in

+ + @* Do not use method="get" for real login forms. This is just to simplify E2E tests. *@ +
+

+ User name: + +

+

+ +

+
+
+ +
+

Status

+

+ Authenticated: @User.Identity.IsAuthenticated + Username: @User.Identity.Name +

+ Sign out +
+ + + +@functions { + public async Task OnGet() + { + if (Request.Query["signout"] == "true") + { + await HttpContext.SignOutAsync(); + return Redirect("Authentication"); + } + + var username = Request.Query["username"]; + if (!string.IsNullOrEmpty(username)) + { + var claims = new List + { + new Claim(ClaimTypes.Name, username), + new Claim("test-claim", "Test claim value"), + }; + + await HttpContext.SignInAsync( + new ClaimsPrincipal(new ClaimsIdentity(claims, "FakeAuthenticationType"))); + + return Redirect("Authentication"); + } + + return Page(); + } +} diff --git a/src/Components/test/testassets/TestServer/Startup.cs b/src/Components/test/testassets/TestServer/Startup.cs index cf7ea69d32e2..26da1af8e05b 100644 --- a/src/Components/test/testassets/TestServer/Startup.cs +++ b/src/Components/test/testassets/TestServer/Startup.cs @@ -1,4 +1,5 @@ using BasicTestApp; +using Microsoft.AspNetCore.Authentication.Cookies; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Components.Server; using Microsoft.AspNetCore.Hosting; @@ -28,6 +29,7 @@ public void ConfigureServices(IServiceCollection services) options.AddPolicy("AllowAll", _ => { /* Controlled below */ }); }); services.AddServerSideBlazor(); + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -50,6 +52,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) .AllowCredentials(); }); + app.UseAuthentication(); // Mount the server-side Blazor app on /subdir app.Map("/subdir", subdirApp => @@ -70,6 +73,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env) app.UseEndpoints(endpoints => { endpoints.MapControllers(); + endpoints.MapRazorPages(); }); // Separately, mount a prerendered server-side Blazor app on /prerendered From 2e0567bb6f2d6a1687af81875c0542fca39501d4 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 13:12:13 +0100 Subject: [PATCH 04/13] Make E2E auth component work client-side too --- .../ClientSideAuthenticationStateData.cs | 17 ++++++++ .../ServerAuthenticationStateProvider.cs | 43 +++++++++++++++++++ .../test/testassets/BasicTestApp/Startup.cs | 3 ++ .../TestServer/Controllers/UserController.cs | 28 ++++++++++++ 4 files changed, 91 insertions(+) create mode 100644 src/Components/test/testassets/BasicTestApp/AuthTest/ClientSideAuthenticationStateData.cs create mode 100644 src/Components/test/testassets/BasicTestApp/AuthTest/ServerAuthenticationStateProvider.cs create mode 100644 src/Components/test/testassets/TestServer/Controllers/UserController.cs diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/ClientSideAuthenticationStateData.cs b/src/Components/test/testassets/BasicTestApp/AuthTest/ClientSideAuthenticationStateData.cs new file mode 100644 index 000000000000..15178b5d8203 --- /dev/null +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/ClientSideAuthenticationStateData.cs @@ -0,0 +1,17 @@ +// 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.Collections.Generic; + +namespace BasicTestApp.AuthTest +{ + // DTO shared between server and client + public class ClientSideAuthenticationStateData + { + public bool IsAuthenticated { get; set; } + + public string UserName { get; set; } + + public Dictionary ExposedClaims { get; set; } + } +} diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/ServerAuthenticationStateProvider.cs b/src/Components/test/testassets/BasicTestApp/AuthTest/ServerAuthenticationStateProvider.cs new file mode 100644 index 000000000000..08639f9254fe --- /dev/null +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/ServerAuthenticationStateProvider.cs @@ -0,0 +1,43 @@ +// 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.Linq; +using System.Net.Http; +using System.Security.Claims; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; + +namespace BasicTestApp.AuthTest +{ + // This is intended to be similar to the authentication stateprovider included by default + // with the client-side Blazor "Hosted in ASP.NET Core" template + public class ServerAuthenticationStateProvider : AuthenticationStateProvider + { + private readonly HttpClient _httpClient; + + public ServerAuthenticationStateProvider(HttpClient httpClient) + { + _httpClient = httpClient; + } + + public override async Task GetAuthenticationStateAsync() + { + var uri = new Uri(_httpClient.BaseAddress, "/api/User"); + var data = await _httpClient.GetJsonAsync(uri.AbsoluteUri); + ClaimsIdentity identity; + if (data.IsAuthenticated) + { + var claims = new[] { new Claim(ClaimTypes.Name, data.UserName) } + .Concat(data.ExposedClaims.Select(c => new Claim(c.Key, c.Value))); + identity = new ClaimsIdentity(claims, "Server authentication"); + } + else + { + identity = new ClaimsIdentity(); + } + + return new AuthenticationState(new ClaimsPrincipal(identity)); + } + } +} diff --git a/src/Components/test/testassets/BasicTestApp/Startup.cs b/src/Components/test/testassets/BasicTestApp/Startup.cs index 0f509b98e837..73084e0260a0 100644 --- a/src/Components/test/testassets/BasicTestApp/Startup.cs +++ b/src/Components/test/testassets/BasicTestApp/Startup.cs @@ -2,7 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Runtime.InteropServices; +using BasicTestApp.AuthTest; using Microsoft.AspNetCore.Blazor.Http; +using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Builder; using Microsoft.Extensions.DependencyInjection; @@ -12,6 +14,7 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { + services.AddSingleton(); } public void Configure(IComponentsApplicationBuilder app) diff --git a/src/Components/test/testassets/TestServer/Controllers/UserController.cs b/src/Components/test/testassets/TestServer/Controllers/UserController.cs new file mode 100644 index 000000000000..16764e4080a3 --- /dev/null +++ b/src/Components/test/testassets/TestServer/Controllers/UserController.cs @@ -0,0 +1,28 @@ +using System.Linq; +using BasicTestApp.AuthTest; +using Microsoft.AspNetCore.Mvc; + +namespace Components.TestServer.Controllers +{ + [Route("api/[controller]")] + public class UserController : Controller + { + // GET api/user + [HttpGet] + public ClientSideAuthenticationStateData Get() + { + // Servers are not expected to expose everything from the server-side ClaimsPrincipal + // to the client. It's up to the developer to choose what kind of authentication state + // data is needed on the client so it can display suitable options in the UI. + + return new ClientSideAuthenticationStateData + { + IsAuthenticated = User.Identity.IsAuthenticated, + UserName = User.Identity.Name, + ExposedClaims = User.Claims + .Where(c => c.Type == "test-claim") + .ToDictionary(c => c.Type, c => c.Value) + }; + } + } +} From a5033937b51193ea187f76fa35e82b3f9fbaeb55 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 13:36:35 +0100 Subject: [PATCH 05/13] Restructure auth E2E tests around a router so there can easily be multiple such test components --- .../BasicTestApp/AuthTest/AuthHome.razor | 3 ++ .../BasicTestApp/AuthTest/AuthRouter.razor | 29 +++++++++++++++++++ ...ascadingAuthenticationStateConsumer.razor} | 3 ++ .../CascadingAuthenticationStateParent.razor | 3 -- .../BasicTestApp/AuthTest/Links.razor | 5 ++++ .../test/testassets/BasicTestApp/Index.razor | 1 + 6 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 src/Components/test/testassets/BasicTestApp/AuthTest/AuthHome.razor create mode 100644 src/Components/test/testassets/BasicTestApp/AuthTest/AuthRouter.razor rename src/Components/test/testassets/BasicTestApp/AuthTest/{CascadingAuthenticationStateChild.razor => CascadingAuthenticationStateConsumer.razor} (92%) delete mode 100644 src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateParent.razor create mode 100644 src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/AuthHome.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthHome.razor new file mode 100644 index 000000000000..863f865a9844 --- /dev/null +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthHome.razor @@ -0,0 +1,3 @@ +@page "/AuthHome" + +Select an auth test below. diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/AuthRouter.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthRouter.razor new file mode 100644 index 000000000000..0af1028b5c3c --- /dev/null +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthRouter.razor @@ -0,0 +1,29 @@ +@using Microsoft.AspNetCore.Components.Routing +@inject IUriHelper UriHelper + +@* + This router is independent of any other router that may exist within the same project. + It exists so that (1) we can easily have multiple test cases that depend on the + CascadingAuthenticationState, and (2) we can test the integration between the router + and @page authorization rules. +*@ + + + + + +
+ + +@functions { + protected override void OnInit() + { + // Start at AuthHome, not at any other component in the same app that happens to + // register itself for the route "" + var relativeUri = UriHelper.ToBaseRelativePath(UriHelper.GetBaseUri(), UriHelper.GetAbsoluteUri()); + if (relativeUri == string.Empty) + { + UriHelper.NavigateTo("AuthHome"); + } + } +} diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateConsumer.razor similarity index 92% rename from src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor rename to src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateConsumer.razor index fb49cea39f29..b8ce9336ba6d 100644 --- a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateChild.razor +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateConsumer.razor @@ -1,5 +1,8 @@ +@page "/CascadingAuthenticationStateConsumer" @using System.Security.Claims +

Cascading authentication state

+ @if (user == null) { Requesting authentication state... diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateParent.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateParent.razor deleted file mode 100644 index c32d8a92ef0c..000000000000 --- a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateParent.razor +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor new file mode 100644 index 000000000000..63672555fa80 --- /dev/null +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor @@ -0,0 +1,5 @@ +@using Microsoft.AspNetCore.Components.Routing +
    +
  • Home
  • +
  • Cascading authentication state
  • +
diff --git a/src/Components/test/testassets/BasicTestApp/Index.razor b/src/Components/test/testassets/BasicTestApp/Index.razor index a7cc3e053984..7570d92e9996 100644 --- a/src/Components/test/testassets/BasicTestApp/Index.razor +++ b/src/Components/test/testassets/BasicTestApp/Index.razor @@ -55,6 +55,7 @@ + @if (SelectedComponentType != null) From 4b9fb035ef499282b970920482ffc61ea9789e8f Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 14:50:04 +0100 Subject: [PATCH 06/13] Add E2E test case for AuthorizeView --- .../BasicTestApp/AuthTest/AuthRouter.razor | 3 ++- .../AuthTest/AuthorizeViewCases.razor | 17 +++++++++++++++++ .../CascadingAuthenticationStateConsumer.razor | 4 ---- .../BasicTestApp/AuthTest/Links.razor | 11 +++++++---- 4 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 src/Components/test/testassets/BasicTestApp/AuthTest/AuthorizeViewCases.razor diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/AuthRouter.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthRouter.razor index 0af1028b5c3c..299a5beb8740 100644 --- a/src/Components/test/testassets/BasicTestApp/AuthTest/AuthRouter.razor +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthRouter.razor @@ -20,7 +20,8 @@ { // Start at AuthHome, not at any other component in the same app that happens to // register itself for the route "" - var relativeUri = UriHelper.ToBaseRelativePath(UriHelper.GetBaseUri(), UriHelper.GetAbsoluteUri()); + var absoluteUriPath = new Uri(UriHelper.GetAbsoluteUri()).GetLeftPart(UriPartial.Path); + var relativeUri = UriHelper.ToBaseRelativePath(UriHelper.GetBaseUri(), absoluteUriPath); if (relativeUri == string.Empty) { UriHelper.NavigateTo("AuthHome"); diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/AuthorizeViewCases.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthorizeViewCases.razor new file mode 100644 index 000000000000..6f40dac90894 --- /dev/null +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthorizeViewCases.razor @@ -0,0 +1,17 @@ +@page "/AuthorizeViewCases" + +
+

Scenario: No authorization rules

+ + + +

Authorizing...

+
+ +

Welcome, @context.User.Identity.Name!

+
+ +

You're not logged in.

+
+
+
diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateConsumer.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateConsumer.razor index b8ce9336ba6d..8113e1080f5b 100644 --- a/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateConsumer.razor +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/CascadingAuthenticationStateConsumer.razor @@ -32,10 +32,6 @@ else

} -
- -

To change the underlying authentication state, go here.

- @functions { static Predicate TestClaimPredicate = c => c.Type == "test-claim"; diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor index 63672555fa80..ae8b00217d5a 100644 --- a/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor @@ -1,5 +1,8 @@ @using Microsoft.AspNetCore.Components.Routing -
    -
  • Home
  • -
  • Cascading authentication state
  • -
+
    +
  • Home
  • +
  • Cascading authentication state
  • +
  • AuthorizeView cases
  • +
+ +

To change the underlying authentication state, go here.

From 216b2f037098c84df63c13e56ec2481f1c3d066c Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 15:52:11 +0100 Subject: [PATCH 07/13] Prepare for E2E test implementations --- .../test/testassets/BasicTestApp/AuthTest/Links.razor | 10 +++++----- .../testassets/TestServer/Pages/Authentication.cshtml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor index ae8b00217d5a..70f524a76393 100644 --- a/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/Links.razor @@ -1,8 +1,8 @@ @using Microsoft.AspNetCore.Components.Routing -
    -
  • Home
  • -
  • Cascading authentication state
  • -
  • AuthorizeView cases
  • -
+

To change the underlying authentication state, go here.

diff --git a/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml b/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml index f3314230570e..3f6cbdefd58c 100644 --- a/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml +++ b/src/Components/test/testassets/TestServer/Pages/Authentication.cshtml @@ -7,7 +7,7 @@ Authentication -

Authentication

+

Authentication

This is a completely fake login mechanism for automated test purposes. It accepts any username, with no password. From 17813bcb3cb957ef67938febe9f12ab6dff69691 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 16:07:16 +0100 Subject: [PATCH 08/13] Fix ToBaseRelativePath handling of hashes ... otherwise E2E test will fail, because we're using the hash to control server-or-client execution --- .../Blazor/Blazor/test/WebAssemblyUriHelperTest.cs | 3 +++ src/Components/Components/src/UriHelperBase.cs | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Components/Blazor/Blazor/test/WebAssemblyUriHelperTest.cs b/src/Components/Blazor/Blazor/test/WebAssemblyUriHelperTest.cs index 45c94a71d2fb..2903d7fcd3e3 100644 --- a/src/Components/Blazor/Blazor/test/WebAssemblyUriHelperTest.cs +++ b/src/Components/Blazor/Blazor/test/WebAssemblyUriHelperTest.cs @@ -29,6 +29,9 @@ public void ComputesCorrectBaseUri(string baseUri, string expectedResult) [InlineData("scheme://host/path/", "scheme://host/path/", "")] [InlineData("scheme://host/path/", "scheme://host/path/more", "more")] [InlineData("scheme://host/path/", "scheme://host/path", "")] + [InlineData("scheme://host/path/", "scheme://host/path#hash", "#hash")] + [InlineData("scheme://host/path/", "scheme://host/path/#hash", "#hash")] + [InlineData("scheme://host/path/", "scheme://host/path/more#hash", "more#hash")] public void ComputesCorrectValidBaseRelativePaths(string baseUri, string absoluteUri, string expectedResult) { var actualResult = _uriHelper.ToBaseRelativePath(baseUri, absoluteUri); diff --git a/src/Components/Components/src/UriHelperBase.cs b/src/Components/Components/src/UriHelperBase.cs index 41af519eca0a..3b8f0910452f 100644 --- a/src/Components/Components/src/UriHelperBase.cs +++ b/src/Components/Components/src/UriHelperBase.cs @@ -154,7 +154,10 @@ public string ToBaseRelativePath(string baseUri, string locationAbsolute) // baseUri ends with a slash), and from that we return "something" return locationAbsolute.Substring(baseUri.Length); } - else if ($"{locationAbsolute}/".Equals(baseUri, StringComparison.Ordinal)) + + var hashIndex = locationAbsolute.IndexOf('#'); + var locationAbsoluteNoHash = hashIndex < 0 ? locationAbsolute : locationAbsolute.Substring(0, hashIndex); + if ($"{locationAbsoluteNoHash}/".Equals(baseUri, StringComparison.Ordinal)) { // Special case: for the base URI "/something/", if you're at // "/something" then treat it as if you were at "/something/" (i.e., @@ -162,7 +165,7 @@ public string ToBaseRelativePath(string baseUri, string locationAbsolute) // whether the server would return the same page whether or not the // slash is present, but ASP.NET Core at least does by default when // using PathBase. - return string.Empty; + return locationAbsolute.Substring(baseUri.Length - 1); } var message = $"The URI '{locationAbsolute}' is not contained by the base URI '{baseUri}'."; From 3e00ee90393262ed940b22fa101ff8bd20c149ca Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 16:28:17 +0100 Subject: [PATCH 09/13] Decouple E2E execution mode from hosting mode --- .../test/E2ETest/Infrastructure/BasicTestAppTestBase.cs | 2 +- .../ServerFixtures/ToggleExecutionModeServerFixture.cs | 6 ++++-- .../ServerExecutionTests/ServerExecutionTestExtensions.cs | 1 + src/Components/test/E2ETest/Tests/BindTest.cs | 2 +- src/Components/test/E2ETest/Tests/CascadingValueTest.cs | 2 +- src/Components/test/E2ETest/Tests/ComponentRenderingTest.cs | 2 +- src/Components/test/E2ETest/Tests/EventBubblingTest.cs | 2 +- src/Components/test/E2ETest/Tests/EventCallbackTest.cs | 2 +- src/Components/test/E2ETest/Tests/FormsTest.cs | 2 +- src/Components/test/E2ETest/Tests/InteropTest.cs | 2 +- src/Components/test/E2ETest/Tests/KeyTest.cs | 2 +- 11 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs b/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs index d4933b858edb..62d62f0d6878 100644 --- a/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs +++ b/src/Components/test/E2ETest/Infrastructure/BasicTestAppTestBase.cs @@ -15,7 +15,7 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Infrastructure public class BasicTestAppTestBase : ServerTestBase> { public string ServerPathBase - => "/subdir" + (_serverFixture.UsingAspNetHost ? "#server" : ""); + => "/subdir" + (_serverFixture.ExecutionMode == ExecutionMode.Server ? "#server" : ""); public BasicTestAppTestBase( BrowserFixture browserFixture, diff --git a/src/Components/test/E2ETest/Infrastructure/ServerFixtures/ToggleExecutionModeServerFixture.cs b/src/Components/test/E2ETest/Infrastructure/ServerFixtures/ToggleExecutionModeServerFixture.cs index 9fb9863f6024..759b87185228 100644 --- a/src/Components/test/E2ETest/Infrastructure/ServerFixtures/ToggleExecutionModeServerFixture.cs +++ b/src/Components/test/E2ETest/Infrastructure/ServerFixtures/ToggleExecutionModeServerFixture.cs @@ -9,7 +9,8 @@ public class ToggleExecutionModeServerFixture : ServerFixture { public string PathBase { get; set; } - public bool UsingAspNetHost { get; private set; } + + public ExecutionMode ExecutionMode { get; set; } = ExecutionMode.Client; private AspNetSiteServerFixture.BuildWebHost _buildWebHostMethod; private IDisposable _serverToDispose; @@ -18,7 +19,6 @@ public void UseAspNetHost(AspNetSiteServerFixture.BuildWebHost buildWebHostMetho { _buildWebHostMethod = buildWebHostMethod ?? throw new ArgumentNullException(nameof(buildWebHostMethod)); - UsingAspNetHost = true; } protected override string StartAndGetRootUri() @@ -46,4 +46,6 @@ public override void Dispose() _serverToDispose?.Dispose(); } } + + public enum ExecutionMode { Client, Server } } diff --git a/src/Components/test/E2ETest/ServerExecutionTests/ServerExecutionTestExtensions.cs b/src/Components/test/E2ETest/ServerExecutionTests/ServerExecutionTestExtensions.cs index e867e03a9b9b..c8e34f36cda1 100644 --- a/src/Components/test/E2ETest/ServerExecutionTests/ServerExecutionTestExtensions.cs +++ b/src/Components/test/E2ETest/ServerExecutionTests/ServerExecutionTestExtensions.cs @@ -10,6 +10,7 @@ internal static class ServerExecutionTestExtensions public static ToggleExecutionModeServerFixture WithServerExecution(this ToggleExecutionModeServerFixture serverFixture) { serverFixture.UseAspNetHost(TestServer.Program.BuildWebHost); + serverFixture.ExecutionMode = ExecutionMode.Server; return serverFixture; } } diff --git a/src/Components/test/E2ETest/Tests/BindTest.cs b/src/Components/test/E2ETest/Tests/BindTest.cs index b08a315441ce..51fcc9ea9d1d 100644 --- a/src/Components/test/E2ETest/Tests/BindTest.cs +++ b/src/Components/test/E2ETest/Tests/BindTest.cs @@ -25,7 +25,7 @@ public BindTest( protected override void InitializeAsyncCore() { // On WebAssembly, page reloads are expensive so skip if possible - Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost); + Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); MountTestComponent(); WaitUntilExists(By.Id("bind-cases")); } diff --git a/src/Components/test/E2ETest/Tests/CascadingValueTest.cs b/src/Components/test/E2ETest/Tests/CascadingValueTest.cs index 8102be1e58d8..e4642fa98c1f 100644 --- a/src/Components/test/E2ETest/Tests/CascadingValueTest.cs +++ b/src/Components/test/E2ETest/Tests/CascadingValueTest.cs @@ -24,7 +24,7 @@ public CascadingValueTest( protected override void InitializeAsyncCore() { - Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost); + Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); MountTestComponent(); } diff --git a/src/Components/test/E2ETest/Tests/ComponentRenderingTest.cs b/src/Components/test/E2ETest/Tests/ComponentRenderingTest.cs index 5c8e194cac28..c88d2997c6d5 100644 --- a/src/Components/test/E2ETest/Tests/ComponentRenderingTest.cs +++ b/src/Components/test/E2ETest/Tests/ComponentRenderingTest.cs @@ -31,7 +31,7 @@ public ComponentRenderingTest( protected override void InitializeAsyncCore() { - Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost); + Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); } [Fact] diff --git a/src/Components/test/E2ETest/Tests/EventBubblingTest.cs b/src/Components/test/E2ETest/Tests/EventBubblingTest.cs index a15d1b31d42b..f45e3d106a75 100644 --- a/src/Components/test/E2ETest/Tests/EventBubblingTest.cs +++ b/src/Components/test/E2ETest/Tests/EventBubblingTest.cs @@ -31,7 +31,7 @@ public EventBubblingTest( protected override void InitializeAsyncCore() { - Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost); + Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); MountTestComponent(); WaitUntilExists(By.Id("event-bubbling")); } diff --git a/src/Components/test/E2ETest/Tests/EventCallbackTest.cs b/src/Components/test/E2ETest/Tests/EventCallbackTest.cs index 4e5472a88a78..01d53d6b20a1 100644 --- a/src/Components/test/E2ETest/Tests/EventCallbackTest.cs +++ b/src/Components/test/E2ETest/Tests/EventCallbackTest.cs @@ -25,7 +25,7 @@ public EventCallbackTest( protected override void InitializeAsyncCore() { // On WebAssembly, page reloads are expensive so skip if possible - Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost); + Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); MountTestComponent(); } diff --git a/src/Components/test/E2ETest/Tests/FormsTest.cs b/src/Components/test/E2ETest/Tests/FormsTest.cs index 88f2a0d9fbf9..9f1083af204b 100644 --- a/src/Components/test/E2ETest/Tests/FormsTest.cs +++ b/src/Components/test/E2ETest/Tests/FormsTest.cs @@ -31,7 +31,7 @@ public FormsTest( protected override void InitializeAsyncCore() { // On WebAssembly, page reloads are expensive so skip if possible - Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost); + Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); } [Fact] diff --git a/src/Components/test/E2ETest/Tests/InteropTest.cs b/src/Components/test/E2ETest/Tests/InteropTest.cs index 4b82c9809685..7ab262c46518 100644 --- a/src/Components/test/E2ETest/Tests/InteropTest.cs +++ b/src/Components/test/E2ETest/Tests/InteropTest.cs @@ -104,7 +104,7 @@ public void CanInvokeDotNetMethods() // Include the sync assertions only when running under WebAssembly var expectedValues = expectedAsyncValues; - if (!_serverFixture.UsingAspNetHost) + if (_serverFixture.ExecutionMode == ExecutionMode.Client) { foreach (var kvp in expectedSyncValues) { diff --git a/src/Components/test/E2ETest/Tests/KeyTest.cs b/src/Components/test/E2ETest/Tests/KeyTest.cs index b7a55196949e..2cb0e58d1827 100644 --- a/src/Components/test/E2ETest/Tests/KeyTest.cs +++ b/src/Components/test/E2ETest/Tests/KeyTest.cs @@ -30,7 +30,7 @@ public KeyTest( protected override void InitializeAsyncCore() { // On WebAssembly, page reloads are expensive so skip if possible - Navigate(ServerPathBase, noReload: !_serverFixture.UsingAspNetHost); + Navigate(ServerPathBase, noReload: _serverFixture.ExecutionMode == ExecutionMode.Client); } [Fact] From ec218ef7d07e7f4c09d0ba901db6d37dedd3ad5e Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 16:36:36 +0100 Subject: [PATCH 10/13] Actual E2E tests for cascading authentication state --- .../ServerExecutionTests/TestSubclasses.cs | 8 ++ src/Components/test/E2ETest/Tests/AuthTest.cs | 73 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/Components/test/E2ETest/Tests/AuthTest.cs diff --git a/src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs b/src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs index 9265718d5492..1f16095af57c 100644 --- a/src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs +++ b/src/Components/test/E2ETest/ServerExecutionTests/TestSubclasses.cs @@ -81,4 +81,12 @@ public ServerKeyTest(BrowserFixture browserFixture, ToggleExecutionModeServerFix { } } + + public class ServerAuthTest : AuthTest + { + public ServerAuthTest(BrowserFixture browserFixture, ToggleExecutionModeServerFixture serverFixture, ITestOutputHelper output) + : base(browserFixture, serverFixture.WithServerExecution(), output) + { + } + } } diff --git a/src/Components/test/E2ETest/Tests/AuthTest.cs b/src/Components/test/E2ETest/Tests/AuthTest.cs new file mode 100644 index 000000000000..fe0dcb9af921 --- /dev/null +++ b/src/Components/test/E2ETest/Tests/AuthTest.cs @@ -0,0 +1,73 @@ +// 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 BasicTestApp; +using Microsoft.AspNetCore.Components.E2ETest.Infrastructure; +using Microsoft.AspNetCore.Components.E2ETest.Infrastructure.ServerFixtures; +using Microsoft.AspNetCore.E2ETesting; +using OpenQA.Selenium; +using Xunit; +using Xunit.Abstractions; + +namespace Microsoft.AspNetCore.Components.E2ETest.Tests +{ + public class AuthTest : BasicTestAppTestBase + { + const string CascadingAuthenticationStateLink = "Cascading authentication state"; + + public AuthTest( + BrowserFixture browserFixture, + ToggleExecutionModeServerFixture serverFixture, + ITestOutputHelper output) + : base(browserFixture, serverFixture, output) + { + // Normally, the E2E tests use the Blazor dev server if they are testing + // client-side execution. But for the auth tests, we always have to run + // in "hosted on ASP.NET Core" mode, because we get the auth state from it. + serverFixture.UseAspNetHost(TestServer.Program.BuildWebHost); + } + + [Fact] + public void CascadingAuthenticationState_Unauthenticated() + { + SignInAs(null); + + var appElement = MountAndNavigateToAuthTest(CascadingAuthenticationStateLink); + + Browser.Equal("False", () => appElement.FindElement(By.Id("identity-authenticated")).Text); + Browser.Equal(string.Empty, () => appElement.FindElement(By.Id("identity-name")).Text); + Browser.Equal("(none)", () => appElement.FindElement(By.Id("test-claim")).Text); + } + + [Fact] + public void CascadingAuthenticationState_Authenticated() + { + SignInAs("someone cool"); + + var appElement = MountAndNavigateToAuthTest(CascadingAuthenticationStateLink); + + Browser.Equal("True", () => appElement.FindElement(By.Id("identity-authenticated")).Text); + Browser.Equal("someone cool", () => appElement.FindElement(By.Id("identity-name")).Text); + Browser.Equal("Test claim value", () => appElement.FindElement(By.Id("test-claim")).Text); + } + + IWebElement MountAndNavigateToAuthTest(string authLinkText) + { + Navigate(ServerPathBase); + var appElement = MountTestComponent(); + WaitUntilExists(By.Id("auth-links")); + appElement.FindElement(By.LinkText(authLinkText)).Click(); + return appElement; + } + + void SignInAs(string usernameOrNull) + { + const string authenticationPageUrl = "/Authentication"; + var baseRelativeUri = usernameOrNull == null + ? $"{authenticationPageUrl}?signout=true" + : $"{authenticationPageUrl}?username={usernameOrNull}"; + Navigate(baseRelativeUri); + WaitUntilExists(By.CssSelector("h1#authentication")); + } + } +} From 746f2c90f501498af7fa6aac97b9ec4eed88434d Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 16:50:31 +0100 Subject: [PATCH 11/13] Actual E2E tests for AuthorizeView (in "no authentication rule" mode) --- src/Components/test/E2ETest/Tests/AuthTest.cs | 19 +++++++++++++++++++ .../AuthTest/AuthorizeViewCases.razor | 4 ++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/Components/test/E2ETest/Tests/AuthTest.cs b/src/Components/test/E2ETest/Tests/AuthTest.cs index fe0dcb9af921..cc3139b6abde 100644 --- a/src/Components/test/E2ETest/Tests/AuthTest.cs +++ b/src/Components/test/E2ETest/Tests/AuthTest.cs @@ -13,7 +13,9 @@ namespace Microsoft.AspNetCore.Components.E2ETest.Tests { public class AuthTest : BasicTestAppTestBase { + // These strings correspond to the links in BasicTestApp\AuthTest\Links.razor const string CascadingAuthenticationStateLink = "Cascading authentication state"; + const string AuthorizeViewCases = "AuthorizeView cases"; public AuthTest( BrowserFixture browserFixture, @@ -51,6 +53,23 @@ public void CascadingAuthenticationState_Authenticated() Browser.Equal("Test claim value", () => appElement.FindElement(By.Id("test-claim")).Text); } + [Fact] + public void AuthorizeViewCases_NoAuthorizationRule_Unauthenticated() + { + SignInAs(null); + MountAndNavigateToAuthTest(AuthorizeViewCases); + WaitUntilExists(By.CssSelector("#no-authorization-rule .not-authorized")); + } + + [Fact] + public void AuthorizeViewCases_NoAuthorizationRule_Authenticated() + { + SignInAs("Some User"); + var appElement = MountAndNavigateToAuthTest(AuthorizeViewCases); + Browser.Equal("Welcome, Some User!", () => + appElement.FindElement(By.CssSelector("#no-authorization-rule .authorized")).Text); + } + IWebElement MountAndNavigateToAuthTest(string authLinkText) { Navigate(ServerPathBase); diff --git a/src/Components/test/testassets/BasicTestApp/AuthTest/AuthorizeViewCases.razor b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthorizeViewCases.razor index 6f40dac90894..d78c70f72a08 100644 --- a/src/Components/test/testassets/BasicTestApp/AuthTest/AuthorizeViewCases.razor +++ b/src/Components/test/testassets/BasicTestApp/AuthTest/AuthorizeViewCases.razor @@ -1,7 +1,7 @@ @page "/AuthorizeViewCases" -

-

Scenario: No authorization rules

+
+

Scenario: No authorization rule

From 933a45b240acec3998f1c89e1e4a34c9a41915af Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 16:55:55 +0100 Subject: [PATCH 12/13] Fix inconsistent namespace --- .../test/E2ETest/ServerExecutionTests/PrerenderingTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Components/test/E2ETest/ServerExecutionTests/PrerenderingTest.cs b/src/Components/test/E2ETest/ServerExecutionTests/PrerenderingTest.cs index be5e99619680..b7b6d361c805 100644 --- a/src/Components/test/E2ETest/ServerExecutionTests/PrerenderingTest.cs +++ b/src/Components/test/E2ETest/ServerExecutionTests/PrerenderingTest.cs @@ -8,7 +8,7 @@ using Xunit; using Xunit.Abstractions; -namespace Microsoft.AspNetCore.Components.E2ETests.ServerExecutionTests +namespace Microsoft.AspNetCore.Components.E2ETest.ServerExecutionTests { public class PrerenderingTest : ServerTestBase { From bd25b9b43a8eb1b72707d1bf1d350e753c5d3211 Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Thu, 16 May 2019 17:02:54 +0100 Subject: [PATCH 13/13] CR: Manual ref assembly definitions for AuthorizeView/CascadingAuthenticationState --- eng/GenAPI.exclusions.txt | 2 ++ ...etCore.Components.netstandard2.0.Manual.cs | 26 +++++++++++++++++++ ...ft.AspNetCore.Components.netstandard2.0.cs | 24 ----------------- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/eng/GenAPI.exclusions.txt b/eng/GenAPI.exclusions.txt index 61d8c412b296..4595fc772a0c 100644 --- a/eng/GenAPI.exclusions.txt +++ b/eng/GenAPI.exclusions.txt @@ -4,6 +4,8 @@ T:Microsoft.AspNetCore.Components.RenderTree.RenderTreeFrame T:Microsoft.AspNetCore.Mvc.ApplicationModels.PageParameterModel T:Microsoft.AspNetCore.Mvc.ApplicationModels.PagePropertyModel # Manually implemented - https://github.com/aspnet/AspNetCore/issues/8825 +T:Microsoft.AspNetCore.Components.AuthorizeView +T:Microsoft.AspNetCore.Components.CascadingAuthenticationState T:Microsoft.AspNetCore.Components.CascadingValue`1 T:Microsoft.AspNetCore.Components.Forms.DataAnnotationsValidator T:Microsoft.AspNetCore.Components.Forms.EditForm diff --git a/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.Manual.cs b/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.Manual.cs index 19c9249e47cb..72db875d4874 100644 --- a/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.Manual.cs +++ b/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.Manual.cs @@ -49,6 +49,32 @@ public readonly partial struct RenderTreeFrame // Built-in components: https://github.com/aspnet/AspNetCore/issues/8825 namespace Microsoft.AspNetCore.Components { + public partial class AuthorizeView : Microsoft.AspNetCore.Components.ComponentBase + { + public AuthorizeView() { } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public Microsoft.AspNetCore.Components.RenderFragment Authorized { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public Microsoft.AspNetCore.Components.RenderFragment Authorizing { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public Microsoft.AspNetCore.Components.RenderFragment ChildContent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public Microsoft.AspNetCore.Components.RenderFragment NotAuthorized { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) { } + [System.Diagnostics.DebuggerStepThroughAttribute] + protected override System.Threading.Tasks.Task OnParametersSetAsync() { throw null; } + } + + public partial class CascadingAuthenticationState : Microsoft.AspNetCore.Components.ComponentBase, System.IDisposable + { + public CascadingAuthenticationState() { } + [Microsoft.AspNetCore.Components.ParameterAttribute] + public Microsoft.AspNetCore.Components.RenderFragment ChildContent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } private set { throw null; } } + protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) { } + protected override void OnInit() { } + void System.IDisposable.Dispose() { } + } + public partial class CascadingValue : Microsoft.AspNetCore.Components.IComponent { public CascadingValue() { } diff --git a/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs b/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs index 1729a18ed154..a1b3d1e2f8c4 100644 --- a/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs +++ b/src/Components/Components/ref/Microsoft.AspNetCore.Components.netstandard2.0.cs @@ -16,21 +16,6 @@ public event Microsoft.AspNetCore.Components.AuthenticationStateChangedHandler A public abstract System.Threading.Tasks.Task GetAuthenticationStateAsync(); protected void NotifyAuthenticationStateChanged(System.Threading.Tasks.Task task) { } } - public partial class AuthorizeView : Microsoft.AspNetCore.Components.ComponentBase - { - public AuthorizeView() { } - [Microsoft.AspNetCore.Components.ParameterAttribute] - public Microsoft.AspNetCore.Components.RenderFragment Authorized { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } - [Microsoft.AspNetCore.Components.ParameterAttribute] - public Microsoft.AspNetCore.Components.RenderFragment Authorizing { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } - [Microsoft.AspNetCore.Components.ParameterAttribute] - public Microsoft.AspNetCore.Components.RenderFragment ChildContent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } - [Microsoft.AspNetCore.Components.ParameterAttribute] - public Microsoft.AspNetCore.Components.RenderFragment NotAuthorized { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } - protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) { } - [System.Diagnostics.DebuggerStepThroughAttribute] - protected override System.Threading.Tasks.Task OnParametersSetAsync() { throw null; } - } [Microsoft.AspNetCore.Components.BindElementAttribute("select", null, "value", "onchange")] [Microsoft.AspNetCore.Components.BindElementAttribute("textarea", null, "value", "onchange")] [Microsoft.AspNetCore.Components.BindInputElementAttribute("checkbox", null, "checked", "onchange")] @@ -85,15 +70,6 @@ public static partial class BindMethods public static System.Action SetValueHandler(System.Action setter, string existingValue) { throw null; } public static System.Action SetValueHandler(System.Action setter, T existingValue) { throw null; } } - public partial class CascadingAuthenticationState : Microsoft.AspNetCore.Components.ComponentBase, System.IDisposable - { - public CascadingAuthenticationState() { } - [Microsoft.AspNetCore.Components.ParameterAttribute] - public Microsoft.AspNetCore.Components.RenderFragment ChildContent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } - protected override void BuildRenderTree(Microsoft.AspNetCore.Components.RenderTree.RenderTreeBuilder builder) { } - protected override void OnInit() { } - void System.IDisposable.Dispose() { } - } [System.AttributeUsageAttribute(System.AttributeTargets.Property, AllowMultiple=false, Inherited=false)] public sealed partial class CascadingParameterAttribute : System.Attribute {