Skip to content

Commit 48b93bd

Browse files
authored
Enhance Blazor WASM unauth endpoint access (#18937)
1 parent 9a9858c commit 48b93bd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

aspnetcore/blazor/security/webassembly/additional-scenarios.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to configure Blazor WebAssembly for additional security s
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: riande
77
ms.custom: mvc
8-
ms.date: 06/10/2020
8+
ms.date: 06/24/2020
99
no-loc: [Blazor, "Identity", "Let's Encrypt", Razor, SignalR]
1010
uid: blazor/security/webassembly/additional-scenarios
1111
---
@@ -244,7 +244,7 @@ builder.Services.AddHttpClient("ServerAPI.NoAuthenticationClient",
244244

245245
The preceding registration is in addition to the existing secure default <xref:System.Net.Http.HttpClient> registration.
246246

247-
A component creates the <xref:System.Net.Http.HttpClient> from the <xref:System.Net.Http.IHttpClientFactory> ([`Microsoft.Extensions.Http`](https://www.nuget.org/packages/Microsoft.Extensions.Http/) package) to make unauthenticated or unauthorized requests:
247+
A component creates the <xref:System.Net.Http.HttpClient> from the <xref:System.Net.Http.IHttpClientFactory> ([`Microsoft.Extensions.Http`](https://www.nuget.org/packages/Microsoft.Extensions.Http) package) to make unauthenticated or unauthorized requests:
248248

249249
```razor
250250
@inject IHttpClientFactory ClientFactory
@@ -267,6 +267,10 @@ A component creates the <xref:System.Net.Http.HttpClient> from the <xref:System.
267267
> [!NOTE]
268268
> The controller in the server API, `WeatherForecastNoAuthenticationController` for the preceding example, isn't marked with the [`[Authorize]`](xref:Microsoft.AspNetCore.Authorization.AuthorizeAttribute) attribute.
269269
270+
The decision whether to use a secure client or an insecure client as the default <xref:System.Net.Http.HttpClient> instance is up to the developer. One way to make this decision is to consider the number of authenticated versus unauthenticated endpoints that the app contacts. If the majority of the app's requests are to secure API endpoints, use the authenticated <xref:System.Net.Http.HttpClient> instance as the default. Otherwise, register the unauthenticated <xref:System.Net.Http.HttpClient> instance as the default.
271+
272+
An alternative approach to using the <xref:System.Net.Http.IHttpClientFactory> is to create a [typed client](#typed-httpclient) for unauthenticated access to anonymous endpoints.
273+
270274
## Request additional access tokens
271275

272276
Access tokens can be manually obtained by calling `IAccessTokenProvider.RequestAccessToken`.

0 commit comments

Comments
 (0)