Skip to content

Commit 216bb56

Browse files
authored
Default to security warning INCLUDE
1 parent f275bd5 commit 216bb56

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

aspnetcore/blazor/progressive-web-app/push-notifications.md

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn how to issue push notifications in Blazor Progressive Web App
55
monikerRange: '>= aspnetcore-3.1'
66
ms.author: wpickett
77
ms.custom: mvc
8-
ms.date: 07/07/2025
8+
ms.date: 07/30/2025
99
uid: blazor/progressive-web-app/push-notifications
1010
---
1111
# Push notifications for ASP.NET Core Blazor Progressive Web Applications (PWAs)
@@ -30,24 +30,15 @@ The example in this article uses push notifications to provide order status upda
3030

3131
Generate the cryptographic public and private keys for securing push notifications either locally, for example with PowerShell or IIS, or using an online tool.
3232

33-
> [!CAUTION]
34-
> This article's use of a unencrypted, insecure private key in the app's code ***is for demonstration purposes and local testing only.*** We recommend using a secure approach for supplying a private key to an ASP.NET Core app at all stages of development. When working locally in the Development environment, a private key can be provided to the app using the [Secret Manager](xref:security/app-secrets#secret-manager) tool. In Development, Staging, and Production environments, [Azure Key Vault](/azure/key-vault/) with [Azure Managed Identities](/entra/identity/managed-identities-azure-resources/overview) can be used, noting in passing that to obtain a certificate's private key from a key vault that the certificate must have an exportable private key.
35-
36-
<!-- We'll expand this article to include explicit guidance on key management with AKV. A
37-
Google search with 'get certificate private key from azure key vault for use in c# code'
38-
generates a decent code sample. I didn't see such a good starting point in AKV Learn
39-
articles, so we'll use the AI-generated code as a starting point.
40-
41-
The preceding CAUTION statement also appears in the 'Send a notification' section.
42-
-->
43-
4433
Placeholders used in this article's example code:
4534

4635
* `{PUBLIC KEY}`: The public key.
4736
* `{PRIVATE KEY}`: The private key.
4837

4938
For this article's C# examples, update the `[email protected]` email address to match the address used when creating the custom key pair.
5039

40+
[!INCLUDE[](~/blazor/security/includes/secure-authentication-flows.md)]
41+
5142
## Create a subscription
5243

5344
Before sending push notifications to a user, the app must ask the user for permission. If they grant permission to receive notifications, their browser generates a *subscription*, which includes a set of tokens the app can use to route notifications to the user.
@@ -257,8 +248,7 @@ Sending a notification involves performing some complex cryptographic operations
257248

258249
The `SendNotificationAsync` method dispatches order notifications using the captured subscription. The following code makes uses of `WebPush` APIs for dispatching the notification. The payload of the notification is JSON serialized and includes a message and a URL. The message is displayed to the user, and the URL allows the user to reach the pizza order associated with the notification. Additional parameters can be serialized as required for other notification scenarios.
259250

260-
> [!CAUTION]
261-
> This article's use of a unencrypted, insecure private key in the app's code ***is for demonstration purposes and local testing only.*** We recommend using a secure approach for supplying a private key to an ASP.NET Core app at all stages of development. When working locally in the Development environment, a private key can be provided to the app using the [Secret Manager](xref:security/app-secrets#secret-manager) tool. In Development, Staging, and Production environments, [Azure Key Vault](/azure/key-vault/) with [Azure Managed Identities](/entra/identity/managed-identities-azure-resources/overview) can be used, noting in passing that to obtain a certificate's private key from a key vault that the certificate must have an exportable private key.
251+
[!INCLUDE[](~/blazor/security/includes/secure-authentication-flows.md)]
262252

263253
```csharp
264254
private static async Task SendNotificationAsync(Order order,

0 commit comments

Comments
 (0)