From 64505d71e59d0452df7b80c1059ffcb98d696d68 Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Mon, 7 Oct 2024 15:41:33 -0700 Subject: [PATCH 01/11] address ropc issue --- aspnetcore/fundamentals/use-http-context.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aspnetcore/fundamentals/use-http-context.md b/aspnetcore/fundamentals/use-http-context.md index e5c63f2fa052..1df8bb4ccf65 100644 --- a/aspnetcore/fundamentals/use-http-context.md +++ b/aspnetcore/fundamentals/use-http-context.md @@ -4,9 +4,11 @@ author: jamesnk description: How to use HttpContext in ASP.NET Core. monikerRange: '>= aspnetcore-3.1' ms.author: wpickett -ms.date: 01/31/2022 +ms.date: 10/07/2024 uid: fundamentals/use-httpcontext --- + + # Use HttpContext in ASP.NET Core [!INCLUDE[](~/includes/not-latest-version.md)] @@ -28,9 +30,11 @@ Commonly used members on `HttpRequest` include: ||A collection of request headers.|`user-agent=Edge`
`x-custom-header=MyValue`| ||A collection of route values. The collection is set when the request is matched to a route.|`language=en`
`article=getstarted`| ||A collection of query values parsed from .|`filter=hello`
`page=1`| -|[HttpRequest.ReadFormAsync()](xref:Microsoft.AspNetCore.Http.HttpRequest.ReadFormAsync(System.Threading.CancellationToken))|A method that reads the request body as a form and returns a form values collection. For information about why `ReadFormAsync` should be used to access form data, see [Prefer ReadFormAsync over Request.Form](xref:fundamentals/best-practices#prefer-readformasync-over-requestform).|`email=user@contoso.com`
`password=TNkt4taM`| +|[HttpRequest.ReadFormAsync()](xref:Microsoft.AspNetCore.Http.HttpRequest.ReadFormAsync(System.Threading.CancellationToken))|A method that reads the request body as a form and returns a form values collection. For information about why `ReadFormAsync` should be used to access form data, see [Prefer ReadFormAsync over Request.Form](xref:fundamentals/best-practices#prefer-readformasync-over-requestform).|`email=user@contoso.com`| ||A for reading the request body.|UTF-8 JSON payload| +[!INCLUDE [managed-identities](~/includes/managed-identities-test-non-production.md)] + ### Get request headers provides access to the request headers sent with the HTTP request. There are two ways to access headers using this collection: From 63ca30c4008797075373354b52c631e5483dbe03 Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Tue, 8 Oct 2024 11:41:06 -0700 Subject: [PATCH 02/11] delete unneeded include --- aspnetcore/fundamentals/use-http-context.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/aspnetcore/fundamentals/use-http-context.md b/aspnetcore/fundamentals/use-http-context.md index 1df8bb4ccf65..05266eb35304 100644 --- a/aspnetcore/fundamentals/use-http-context.md +++ b/aspnetcore/fundamentals/use-http-context.md @@ -33,8 +33,6 @@ Commonly used members on `HttpRequest` include: |[HttpRequest.ReadFormAsync()](xref:Microsoft.AspNetCore.Http.HttpRequest.ReadFormAsync(System.Threading.CancellationToken))|A method that reads the request body as a form and returns a form values collection. For information about why `ReadFormAsync` should be used to access form data, see [Prefer ReadFormAsync over Request.Form](xref:fundamentals/best-practices#prefer-readformasync-over-requestform).|`email=user@contoso.com`| ||A for reading the request body.|UTF-8 JSON payload| -[!INCLUDE [managed-identities](~/includes/managed-identities-test-non-production.md)] - ### Get request headers provides access to the request headers sent with the HTTP request. There are two ways to access headers using this collection: From 294b9d5c718b3f30cbfeec8751878f5bc3a308ee Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Wed, 16 Oct 2024 15:32:54 -0700 Subject: [PATCH 03/11] ropc changes --- aspnetcore/fundamentals/configuration/index.md | 8 ++++++-- .../fundamentals/configuration/index/includes/index3-5.md | 2 ++ .../fundamentals/configuration/index/includes/index6.md | 5 +++++ .../fundamentals/configuration/index/includes/index7.md | 5 +++++ aspnetcore/fundamentals/configuration/options.md | 3 ++- aspnetcore/includes/managed-identities-conn-string.md | 8 ++++++++ 6 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 aspnetcore/includes/managed-identities-conn-string.md diff --git a/aspnetcore/fundamentals/configuration/index.md b/aspnetcore/fundamentals/configuration/index.md index 785f46db77a5..3d7350c816c2 100644 --- a/aspnetcore/fundamentals/configuration/index.md +++ b/aspnetcore/fundamentals/configuration/index.md @@ -158,6 +158,7 @@ Configuration data guidelines: * Never store passwords or other sensitive data in configuration provider code or in plain text configuration files. The [Secret Manager](xref:security/app-secrets) tool can be used to store secrets in development. * Don't use production secrets in development or test environments. * Specify secrets outside of the project so that they can't be accidentally committed to a source code repository. +* Avoid the use of passwords in production apps; for more information, see [Secure authentication flows](xref:security/index#secure-authentication-flows). By [default](#default), the user secrets configuration source is registered after the JSON configuration sources. Therefore, user secrets keys take precedence over keys in `appsettings.json` and `appsettings.{Environment}.json`. @@ -165,8 +166,7 @@ For more information on storing passwords or other sensitive data: * * : Includes advice on using environment variables to store sensitive data. The Secret Manager tool uses the [File configuration provider](#fcp) to store user secrets in a JSON file on the local system. - -[Azure Key Vault](https://azure.microsoft.com/services/key-vault/) safely stores app secrets for ASP.NET Core apps. For more information, see . +* [Azure Key Vault](https://azure.microsoft.com/services/key-vault/) safely stores app secrets for ASP.NET Core apps. For more information, see . @@ -408,6 +408,8 @@ The preferred way to read hierarchical configuration data is using the options p ## Configuration keys and values +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + Configuration keys: * Are case-insensitive. For example, `ConnectionString` and `connectionstring` are treated as equivalent keys. @@ -459,6 +461,8 @@ The preceding sequence of providers is used in the [default configuration](#defa ### Connection string prefixes +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + The Configuration API has special processing rules for four connection string environment variables. These connection strings are involved in configuring Azure connection strings for the app environment. Environment variables with the prefixes shown in the table are loaded into the app with the [default configuration](#default) or when no prefix is supplied to `AddEnvironmentVariables`. | Connection string prefix | Provider | diff --git a/aspnetcore/fundamentals/configuration/index/includes/index3-5.md b/aspnetcore/fundamentals/configuration/index/includes/index3-5.md index afb6669b5f05..bc62dc09c444 100644 --- a/aspnetcore/fundamentals/configuration/index/includes/index3-5.md +++ b/aspnetcore/fundamentals/configuration/index/includes/index3-5.md @@ -149,6 +149,8 @@ Custom configuration providers aren't required to implement array binding. ## Custom configuration provider +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + The sample app demonstrates how to create a basic configuration provider that reads configuration key-value pairs from a database using [Entity Framework (EF)](/ef/core/). The provider has the following characteristics: diff --git a/aspnetcore/fundamentals/configuration/index/includes/index6.md b/aspnetcore/fundamentals/configuration/index/includes/index6.md index 906ebb7913d5..e23683ea1012 100644 --- a/aspnetcore/fundamentals/configuration/index/includes/index6.md +++ b/aspnetcore/fundamentals/configuration/index/includes/index6.md @@ -135,6 +135,7 @@ Configuration data guidelines: * Never store passwords or other sensitive data in configuration provider code or in plain text configuration files. The [Secret Manager](xref:security/app-secrets) tool can be used to store secrets in development. * Don't use production secrets in development or test environments. * Specify secrets outside of the project so that they can't be accidentally committed to a source code repository. +* Avoid the use of passwords in production apps; for more information, see [Secure authentication flows](xref:security/index#secure-authentication-flows). By [default](#default), the user secrets configuration source is registered after the JSON configuration sources. Therefore, user secrets keys take precedence over keys in `appsettings.json` and `appsettings.{Environment}.json`. @@ -385,6 +386,8 @@ The preferred way to read hierarchical configuration data is using the options p ## Configuration keys and values +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + Configuration keys: * Are case-insensitive. For example, `ConnectionString` and `connectionstring` are treated as equivalent keys. @@ -436,6 +439,8 @@ The preceding sequence of providers is used in the [default configuration](#defa ### Connection string prefixes +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + The Configuration API has special processing rules for four connection string environment variables. These connection strings are involved in configuring Azure connection strings for the app environment. Environment variables with the prefixes shown in the table are loaded into the app with the [default configuration](#default) or when no prefix is supplied to `AddEnvironmentVariables`. | Connection string prefix | Provider | diff --git a/aspnetcore/fundamentals/configuration/index/includes/index7.md b/aspnetcore/fundamentals/configuration/index/includes/index7.md index 76fce7e30b64..3fcad1e10426 100644 --- a/aspnetcore/fundamentals/configuration/index/includes/index7.md +++ b/aspnetcore/fundamentals/configuration/index/includes/index7.md @@ -140,6 +140,7 @@ Configuration data guidelines: * Never store passwords or other sensitive data in configuration provider code or in plain text configuration files. The [Secret Manager](xref:security/app-secrets) tool can be used to store secrets in development. * Don't use production secrets in development or test environments. * Specify secrets outside of the project so that they can't be accidentally committed to a source code repository. +* Avoid the use of passwords in production apps; for more information, see [Secure authentication flows](xref:security/index#secure-authentication-flows). By [default](#default), the user secrets configuration source is registered after the JSON configuration sources. Therefore, user secrets keys take precedence over keys in `appsettings.json` and `appsettings.{Environment}.json`. @@ -390,6 +391,8 @@ The preferred way to read hierarchical configuration data is using the options p ## Configuration keys and values +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + Configuration keys: * Are case-insensitive. For example, `ConnectionString` and `connectionstring` are treated as equivalent keys. @@ -441,6 +444,8 @@ The preceding sequence of providers is used in the [default configuration](#defa ### Connection string prefixes +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + The Configuration API has special processing rules for four connection string environment variables. These connection strings are involved in configuring Azure connection strings for the app environment. Environment variables with the prefixes shown in the table are loaded into the app with the [default configuration](#default) or when no prefix is supplied to `AddEnvironmentVariables`. | Connection string prefix | Provider | diff --git a/aspnetcore/fundamentals/configuration/options.md b/aspnetcore/fundamentals/configuration/options.md index 373e594d3da4..7e05404883c1 100644 --- a/aspnetcore/fundamentals/configuration/options.md +++ b/aspnetcore/fundamentals/configuration/options.md @@ -17,7 +17,8 @@ when updating this article --> :::moniker range=">= aspnetcore-7.0" -By [Rick Anderson](https://twitter.com/RickAndMSFT). +By [Rick Anderson](https://twitter.com/RickAndMSFT) + The options pattern uses classes to provide strongly typed access to groups of related settings. When [configuration settings](xref:fundamentals/configuration/index) are isolated by scenario into separate classes, the app adheres to two important software engineering principles: diff --git a/aspnetcore/includes/managed-identities-conn-string.md b/aspnetcore/includes/managed-identities-conn-string.md new file mode 100644 index 000000000000..1a5fac47e7c4 --- /dev/null +++ b/aspnetcore/includes/managed-identities-conn-string.md @@ -0,0 +1,8 @@ +--- +author: tdykstra +ms.author: tdykstra +ms.date: 10/16/2024 +ms.topic: include +--- +> [!WARNING] +> This article shows the use of connection strings. With a local database the user doesn't have to be authenticated, but in production, connection strings sometimes include a password to authenticate. A resource owner password credential (ROPC) is a security risk that should be avoided in production databases. Production apps should use the most secure authentication flow available. For more information on authentication for apps deployed to test or production non-local environments, see [Secure authentication flows](xref:security/index#secure-authentication-flows). From e43b2ceaf590d71beda99517f0da1d489074286f Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Wed, 16 Oct 2024 16:24:51 -0700 Subject: [PATCH 04/11] rename string to strings --- ...entities-conn-string.md => managed-identities-conn-strings.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename aspnetcore/includes/{managed-identities-conn-string.md => managed-identities-conn-strings.md} (100%) diff --git a/aspnetcore/includes/managed-identities-conn-string.md b/aspnetcore/includes/managed-identities-conn-strings.md similarity index 100% rename from aspnetcore/includes/managed-identities-conn-string.md rename to aspnetcore/includes/managed-identities-conn-strings.md From 6a2ddcfbffb3db52043eed774fa35acaf7d8e4df Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Wed, 16 Oct 2024 16:32:10 -0700 Subject: [PATCH 05/11] markdownlint --- aspnetcore/fundamentals/configuration/options.md | 1 - 1 file changed, 1 deletion(-) diff --git a/aspnetcore/fundamentals/configuration/options.md b/aspnetcore/fundamentals/configuration/options.md index 7e05404883c1..4c0ab6a01228 100644 --- a/aspnetcore/fundamentals/configuration/options.md +++ b/aspnetcore/fundamentals/configuration/options.md @@ -19,7 +19,6 @@ when updating this article --> By [Rick Anderson](https://twitter.com/RickAndMSFT) - The options pattern uses classes to provide strongly typed access to groups of related settings. When [configuration settings](xref:fundamentals/configuration/index) are isolated by scenario into separate classes, the app adheres to two important software engineering principles: * [Encapsulation](/dotnet/standard/modern-web-apps-azure-architecture/architectural-principles#encapsulation): From a363bd6d18c431ea0b52dac288b08109fb11815f Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Wed, 16 Oct 2024 16:38:42 -0700 Subject: [PATCH 06/11] delete unneeded word --- aspnetcore/includes/managed-identities-conn-strings.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/includes/managed-identities-conn-strings.md b/aspnetcore/includes/managed-identities-conn-strings.md index 1a5fac47e7c4..47f14d30d7aa 100644 --- a/aspnetcore/includes/managed-identities-conn-strings.md +++ b/aspnetcore/includes/managed-identities-conn-strings.md @@ -5,4 +5,4 @@ ms.date: 10/16/2024 ms.topic: include --- > [!WARNING] -> This article shows the use of connection strings. With a local database the user doesn't have to be authenticated, but in production, connection strings sometimes include a password to authenticate. A resource owner password credential (ROPC) is a security risk that should be avoided in production databases. Production apps should use the most secure authentication flow available. For more information on authentication for apps deployed to test or production non-local environments, see [Secure authentication flows](xref:security/index#secure-authentication-flows). +> This article shows the use of connection strings. With a local database the user doesn't have to be authenticated, but in production, connection strings sometimes include a password to authenticate. A resource owner password credential (ROPC) is a security risk that should be avoided in production databases. Production apps should use the most secure authentication flow available. For more information on authentication for apps deployed to test or production environments, see [Secure authentication flows](xref:security/index#secure-authentication-flows). From f1bf60d67d7f7d2590f791861e00e5e247e6ec83 Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Wed, 16 Oct 2024 18:48:26 -0700 Subject: [PATCH 07/11] mark ropc done --- aspnetcore/fundamentals/configuration/index.md | 1 + .../fundamentals/configuration/index/includes/index3-5.md | 2 +- aspnetcore/fundamentals/configuration/index/includes/index6.md | 2 +- aspnetcore/fundamentals/configuration/index/includes/index7.md | 2 +- aspnetcore/includes/managed-identities-conn-strings.md | 1 + 5 files changed, 5 insertions(+), 3 deletions(-) diff --git a/aspnetcore/fundamentals/configuration/index.md b/aspnetcore/fundamentals/configuration/index.md index 3d7350c816c2..33ac26d8f0f0 100644 --- a/aspnetcore/fundamentals/configuration/index.md +++ b/aspnetcore/fundamentals/configuration/index.md @@ -8,6 +8,7 @@ ms.custom: mvc ms.date: 04/26/2024 uid: fundamentals/configuration/index --- + # Configuration in ASP.NET Core By [Rick Anderson](https://twitter.com/RickAndMSFT) and [Kirk Larkin](https://twitter.com/serpent5) diff --git a/aspnetcore/fundamentals/configuration/index/includes/index3-5.md b/aspnetcore/fundamentals/configuration/index/includes/index3-5.md index bc62dc09c444..bbc9ac35ebe2 100644 --- a/aspnetcore/fundamentals/configuration/index/includes/index3-5.md +++ b/aspnetcore/fundamentals/configuration/index/includes/index3-5.md @@ -1,5 +1,5 @@ :::moniker range=">= aspnetcore-5.0 < aspnetcore-6.0" - + ## Kestrel endpoint configuration diff --git a/aspnetcore/fundamentals/configuration/index/includes/index6.md b/aspnetcore/fundamentals/configuration/index/includes/index6.md index e23683ea1012..10aa21d018f4 100644 --- a/aspnetcore/fundamentals/configuration/index/includes/index6.md +++ b/aspnetcore/fundamentals/configuration/index/includes/index6.md @@ -1,5 +1,5 @@ :::moniker range="= aspnetcore-6.0" - + Application configuration in ASP.NET Core is performed using one or more [configuration providers](#cp). Configuration providers read configuration data from key-value pairs using a variety of configuration sources: * Settings files, such as `appsettings.json` diff --git a/aspnetcore/fundamentals/configuration/index/includes/index7.md b/aspnetcore/fundamentals/configuration/index/includes/index7.md index 3fcad1e10426..3c54b4d864c1 100644 --- a/aspnetcore/fundamentals/configuration/index/includes/index7.md +++ b/aspnetcore/fundamentals/configuration/index/includes/index7.md @@ -1,5 +1,5 @@ :::moniker range="= aspnetcore-7.0" - + Application configuration in ASP.NET Core is performed using one or more [configuration providers](#cp). Configuration providers read configuration data from key-value pairs using a variety of configuration sources: * Settings files, such as `appsettings.json` diff --git a/aspnetcore/includes/managed-identities-conn-strings.md b/aspnetcore/includes/managed-identities-conn-strings.md index 47f14d30d7aa..e8d80e875779 100644 --- a/aspnetcore/includes/managed-identities-conn-strings.md +++ b/aspnetcore/includes/managed-identities-conn-strings.md @@ -4,5 +4,6 @@ ms.author: tdykstra ms.date: 10/16/2024 ms.topic: include --- + > [!WARNING] > This article shows the use of connection strings. With a local database the user doesn't have to be authenticated, but in production, connection strings sometimes include a password to authenticate. A resource owner password credential (ROPC) is a security risk that should be avoided in production databases. Production apps should use the most secure authentication flow available. For more information on authentication for apps deployed to test or production environments, see [Secure authentication flows](xref:security/index#secure-authentication-flows). From a2d530088acbfe66aa798ce06eb582cee2d4e781 Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Thu, 17 Oct 2024 11:20:25 -0700 Subject: [PATCH 08/11] Update aspnetcore/fundamentals/configuration/options.md --- aspnetcore/fundamentals/configuration/options.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/fundamentals/configuration/options.md b/aspnetcore/fundamentals/configuration/options.md index 4c0ab6a01228..373e594d3da4 100644 --- a/aspnetcore/fundamentals/configuration/options.md +++ b/aspnetcore/fundamentals/configuration/options.md @@ -17,7 +17,7 @@ when updating this article --> :::moniker range=">= aspnetcore-7.0" -By [Rick Anderson](https://twitter.com/RickAndMSFT) +By [Rick Anderson](https://twitter.com/RickAndMSFT). The options pattern uses classes to provide strongly typed access to groups of related settings. When [configuration settings](xref:fundamentals/configuration/index) are isolated by scenario into separate classes, the app adheres to two important software engineering principles: From 28c27e1c6759ce2d89e9acd6f0ad53f7a83cc6fd Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Mon, 28 Oct 2024 16:56:54 -0600 Subject: [PATCH 09/11] Update aspnetcore/fundamentals/configuration/index.md Co-authored-by: Tom Dykstra <1569635+tdykstra@users.noreply.github.com> --- aspnetcore/fundamentals/configuration/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/fundamentals/configuration/index.md b/aspnetcore/fundamentals/configuration/index.md index 33ac26d8f0f0..bd771b4957cf 100644 --- a/aspnetcore/fundamentals/configuration/index.md +++ b/aspnetcore/fundamentals/configuration/index.md @@ -159,7 +159,7 @@ Configuration data guidelines: * Never store passwords or other sensitive data in configuration provider code or in plain text configuration files. The [Secret Manager](xref:security/app-secrets) tool can be used to store secrets in development. * Don't use production secrets in development or test environments. * Specify secrets outside of the project so that they can't be accidentally committed to a source code repository. -* Avoid the use of passwords in production apps; for more information, see [Secure authentication flows](xref:security/index#secure-authentication-flows). +* Production apps should use the most secure authentication flow available. For more information, see [Secure authentication flows](xref:security/index#secure-authentication-flows). By [default](#default), the user secrets configuration source is registered after the JSON configuration sources. Therefore, user secrets keys take precedence over keys in `appsettings.json` and `appsettings.{Environment}.json`. From a808c1b166e481c3555cd828d96c721d36a3d0db Mon Sep 17 00:00:00 2001 From: Tom Dykstra <1569635+tdykstra@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:24:00 -0700 Subject: [PATCH 10/11] Apply suggestions from code review --- aspnetcore/fundamentals/configuration/index/includes/index6.md | 2 +- aspnetcore/fundamentals/configuration/index/includes/index7.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/aspnetcore/fundamentals/configuration/index/includes/index6.md b/aspnetcore/fundamentals/configuration/index/includes/index6.md index 10aa21d018f4..469a6a10039f 100644 --- a/aspnetcore/fundamentals/configuration/index/includes/index6.md +++ b/aspnetcore/fundamentals/configuration/index/includes/index6.md @@ -135,7 +135,7 @@ Configuration data guidelines: * Never store passwords or other sensitive data in configuration provider code or in plain text configuration files. The [Secret Manager](xref:security/app-secrets) tool can be used to store secrets in development. * Don't use production secrets in development or test environments. * Specify secrets outside of the project so that they can't be accidentally committed to a source code repository. -* Avoid the use of passwords in production apps; for more information, see [Secure authentication flows](xref:security/index#secure-authentication-flows). +* Production apps should use the most secure authentication flow available. For more information, see [Secure authentication flows](xref:security/index#secure-authentication-flows). By [default](#default), the user secrets configuration source is registered after the JSON configuration sources. Therefore, user secrets keys take precedence over keys in `appsettings.json` and `appsettings.{Environment}.json`. diff --git a/aspnetcore/fundamentals/configuration/index/includes/index7.md b/aspnetcore/fundamentals/configuration/index/includes/index7.md index 3c54b4d864c1..189d7f998989 100644 --- a/aspnetcore/fundamentals/configuration/index/includes/index7.md +++ b/aspnetcore/fundamentals/configuration/index/includes/index7.md @@ -140,7 +140,7 @@ Configuration data guidelines: * Never store passwords or other sensitive data in configuration provider code or in plain text configuration files. The [Secret Manager](xref:security/app-secrets) tool can be used to store secrets in development. * Don't use production secrets in development or test environments. * Specify secrets outside of the project so that they can't be accidentally committed to a source code repository. -* Avoid the use of passwords in production apps; for more information, see [Secure authentication flows](xref:security/index#secure-authentication-flows). +* Production apps should use the most secure authentication flow available. For more information, see [Secure authentication flows](xref:security/index#secure-authentication-flows). By [default](#default), the user secrets configuration source is registered after the JSON configuration sources. Therefore, user secrets keys take precedence over keys in `appsettings.json` and `appsettings.{Environment}.json`. From 8b73f0a5890c2151eefce4c4bcdd429adf0317d0 Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Wed, 30 Oct 2024 09:40:23 -0700 Subject: [PATCH 11/11] ROPC remediation - 11 files (#33972) --- aspnetcore/migration/identity.md | 5 ++++- .../migration/proper-to-2x/membership-to-core-identity.md | 5 ++++- aspnetcore/security/app-secrets.md | 3 ++- aspnetcore/security/app-secrets/includes/app-secrets-3-5.md | 4 +++- .../security/authentication/customize-identity-model.md | 5 ++++- .../includes/identity-api-authorization3-7.md | 5 +++++ .../authentication/identity-custom-storage-providers.md | 5 ++++- aspnetcore/security/authentication/mfa.md | 5 ++++- aspnetcore/security/authentication/mfa/includes/mfa-5-8.md | 4 ++++ .../data-protection/implementation/key-storage-providers.md | 5 ++++- aspnetcore/security/key-vault-configuration.md | 3 ++- 11 files changed, 40 insertions(+), 9 deletions(-) diff --git a/aspnetcore/migration/identity.md b/aspnetcore/migration/identity.md index 27bf2e9ab5bd..21d87305a517 100644 --- a/aspnetcore/migration/identity.md +++ b/aspnetcore/migration/identity.md @@ -3,9 +3,10 @@ title: Migrate Authentication and Identity to ASP.NET Core author: ardalis description: Learn how to migrate authentication and identity from an ASP.NET MVC project to an ASP.NET Core MVC project. ms.author: riande -ms.date: 3/22/2020 +ms.date: 10/29/2024 uid: migration/identity --- + # Migrate Authentication and Identity to ASP.NET Core By [Steve Smith](https://ardalis.com/) @@ -22,6 +23,8 @@ Install the following NuGet packages: * `Microsoft.AspNetCore.Authentication.Cookies` * `Microsoft.EntityFrameworkCore.SqlServer` +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + In `Startup.cs`, update the `Startup.ConfigureServices` method to use Entity Framework and Identity services: ```csharp diff --git a/aspnetcore/migration/proper-to-2x/membership-to-core-identity.md b/aspnetcore/migration/proper-to-2x/membership-to-core-identity.md index c873f2e507c8..1d8db1258980 100644 --- a/aspnetcore/migration/proper-to-2x/membership-to-core-identity.md +++ b/aspnetcore/migration/proper-to-2x/membership-to-core-identity.md @@ -4,9 +4,10 @@ author: isaacrlevin description: Learn how to migrate existing ASP.NET apps using Membership authentication to ASP.NET Core 2.0 Identity. ms.author: wpickett ms.custom: mvc -ms.date: 01/10/2019 +ms.date: 10/29/2024 uid: migration/proper-to-2x/membership-to-core-identity --- + # Migrate from ASP.NET Membership authentication to ASP.NET Core 2.0 Identity By [Isaac Levin](https://isaaclevin.com) @@ -49,6 +50,8 @@ The fastest way to view the schema for ASP.NET Core 2.0 Identity is to create a } ``` +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + 1. Select **View** > **SQL Server Object Explorer**. Expand the node corresponding to the database name specified in the `ConnectionStrings:DefaultConnection` property of `appsettings.json`. The `Update-Database` command created the database specified with the schema and any data needed for app initialization. The following image depicts the table structure that's created with the preceding steps. diff --git a/aspnetcore/security/app-secrets.md b/aspnetcore/security/app-secrets.md index 4a1da3fc5317..b867db7ac60f 100644 --- a/aspnetcore/security/app-secrets.md +++ b/aspnetcore/security/app-secrets.md @@ -5,9 +5,10 @@ description: Learn how to store and retrieve sensitive information during the de ms.author: tdykstra monikerRange: '>= aspnetcore-3.0' ms.custom: mvc -ms.date: 02/23/2024 +ms.date: 10/29/2024 uid: security/app-secrets --- + # Safe storage of app secrets in development in ASP.NET Core [!INCLUDE[](~/includes/not-latest-version.md)] diff --git a/aspnetcore/security/app-secrets/includes/app-secrets-3-5.md b/aspnetcore/security/app-secrets/includes/app-secrets-3-5.md index 6a3e11b2d961..2f6e57111814 100644 --- a/aspnetcore/security/app-secrets/includes/app-secrets-3-5.md +++ b/aspnetcore/security/app-secrets/includes/app-secrets-3-5.md @@ -1,11 +1,13 @@ :::moniker range="< aspnetcore-6.0" + By [Rick Anderson](https://twitter.com/RickAndMSFT), [Kirk Larkin](https://twitter.com/serpent5), [Daniel Roth](https://github.com/danroth27), and [Scott Addie](https://github.com/scottaddie) [View or download sample code](https://github.com/dotnet/AspNetCore.Docs/tree/main/aspnetcore/security/app-secrets/samples) ([how to download](xref:index#how-to-download-a-sample)) -This document explains how to manage sensitive data for an ASP.NET Core app on a development machine. Never store passwords or other sensitive data in source code. Production secrets shouldn't be used for development or test. Secrets shouldn't be deployed with the app. Instead, production secrets should be accessed through a controlled means like environment variables or Azure Key Vault. You can store and protect Azure test and production secrets with the [Azure Key Vault configuration provider](xref:security/key-vault-configuration). +This article explains how to manage sensitive data for an ASP.NET Core app on a development machine. Never store passwords or other sensitive data in source code or configuration files. Production secrets shouldn't be used for development or test. Secrets shouldn't be deployed with the app. Production secrets should be accessed through a controlled means like Azure Key Vault. Azure test and production secrets can be stored and protected with the [Azure Key Vault configuration provider](xref:security/key-vault-configuration). +For more information on authentication for test and production environments, see [Secure authentication flows](xref:security/index#secure-authentication-flows). ## Environment variables Environment variables are used to avoid storage of app secrets in code or in local configuration files. Environment variables override configuration values for all previously specified configuration sources. diff --git a/aspnetcore/security/authentication/customize-identity-model.md b/aspnetcore/security/authentication/customize-identity-model.md index 7338935098cb..eddaa6e2d014 100644 --- a/aspnetcore/security/authentication/customize-identity-model.md +++ b/aspnetcore/security/authentication/customize-identity-model.md @@ -3,9 +3,10 @@ title: Identity model customization in ASP.NET Core author: ajcvickers description: This article describes how to customize the underlying Entity Framework Core data model for ASP.NET Core Identity. ms.author: avickers -ms.date: 07/01/2019 +ms.date: 10/29/2024 uid: security/authentication/customize_identity_model --- + # Identity model customization in ASP.NET Core By [Arthur Vickers](https://github.com/ajcvickers) @@ -887,6 +888,8 @@ services Refer to the preceding examples for guidance on adding navigation properties to the entity types. +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + ## Additional resources * diff --git a/aspnetcore/security/authentication/identity-api-authorization/includes/identity-api-authorization3-7.md b/aspnetcore/security/authentication/identity-api-authorization/includes/identity-api-authorization3-7.md index 41b0b0bd43dc..1649260e95c9 100644 --- a/aspnetcore/security/authentication/identity-api-authorization/includes/identity-api-authorization3-7.md +++ b/aspnetcore/security/authentication/identity-api-authorization/includes/identity-api-authorization3-7.md @@ -1,4 +1,5 @@ :::moniker range=">= aspnetcore-6.0 < aspnetcore-8.0" + The ASP.NET Core templates offer authentication in Single Page Apps (SPAs) using the support for API authorization. ASP.NET Core Identity for authenticating and storing users is combined with [Duende Identity Server](https://docs.duendesoftware.com) for implementing OpenID Connect. @@ -76,6 +77,8 @@ The preceding code configures: app.UseIdentityServer(); ``` +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + ### Azure App Service on Linux For Azure App Service deployments on Linux, specify the issuer explicitly: @@ -484,6 +487,8 @@ The `Startup` class has the following additions: app.UseIdentityServer(); ``` +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + ### Azure App Service on Linux For Azure App Service deployments on Linux, specify the issuer explicitly in `Startup.ConfigureServices`: diff --git a/aspnetcore/security/authentication/identity-custom-storage-providers.md b/aspnetcore/security/authentication/identity-custom-storage-providers.md index c6fe0bbf35d4..49d2cdd0ed98 100644 --- a/aspnetcore/security/authentication/identity-custom-storage-providers.md +++ b/aspnetcore/security/authentication/identity-custom-storage-providers.md @@ -4,9 +4,10 @@ author: ardalis description: Learn how to configure custom storage providers for ASP.NET Core Identity. ms.author: riande ms.custom: mvc -ms.date: 07/23/2019 +ms.date: 10/29/2024 uid: security/authentication/identity-custom-storage-providers --- + # Custom storage providers for ASP.NET Core Identity By [Steve Smith](https://ardalis.com/) @@ -207,6 +208,8 @@ Once you have implemented a storage provider, you configure your app to use it. 1. If you are using Roles, update the `RoleManager` to use your `RoleStore` class. 1. Update the connection string and credentials to your app's configuration. +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + Example: :::moniker range="< aspnetcore-6.0" diff --git a/aspnetcore/security/authentication/mfa.md b/aspnetcore/security/authentication/mfa.md index 6d6e7153411a..e888ea877ae6 100644 --- a/aspnetcore/security/authentication/mfa.md +++ b/aspnetcore/security/authentication/mfa.md @@ -5,9 +5,10 @@ description: Learn how to set up multi-factor authentication (MFA) in an ASP.NET monikerRange: '>= aspnetcore-3.1' ms.author: riande ms.custom: mvc -ms.date: 04/02/2024 +ms.date: 10/29/2024 uid: security/authentication/mfa --- + # Multi-factor authentication in ASP.NET Core [!INCLUDE[](~/includes/not-latest-version.md)] @@ -73,6 +74,8 @@ MFA could be forced on users to access sensitive pages within an ASP.NET Core Id The demo code is setup using ASP.NET Core with Identity and Razor Pages. The `AddIdentity` method is used instead of `AddDefaultIdentity` one, so an `IUserClaimsPrincipalFactory` implementation can be used to add claims to the identity after a successful login. +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + ```csharp builder.Services.AddDbContext(options => options.UseSqlite( diff --git a/aspnetcore/security/authentication/mfa/includes/mfa-5-8.md b/aspnetcore/security/authentication/mfa/includes/mfa-5-8.md index 747c6ac65ce3..11b35bb1650d 100644 --- a/aspnetcore/security/authentication/mfa/includes/mfa-5-8.md +++ b/aspnetcore/security/authentication/mfa/includes/mfa-5-8.md @@ -59,6 +59,8 @@ MFA could be forced on users to access sensitive pages within an ASP.NET Core Id The demo code is setup using ASP.NET Core with Identity and Razor Pages. The `AddIdentity` method is used instead of `AddDefaultIdentity` one, so an `IUserClaimsPrincipalFactory` implementation can be used to add claims to the identity after a successful login. +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + ```csharp builder.Services.AddDbContext(options => options.UseSqlite( @@ -561,6 +563,8 @@ MFA could be forced on users to access sensitive pages within an ASP.NET Core Id The demo code is setup using ASP.NET Core with Identity and Razor Pages. The `AddIdentity` method is used instead of `AddDefaultIdentity` one, so an `IUserClaimsPrincipalFactory` implementation can be used to add claims to the identity after a successful login. +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + ```csharp public void ConfigureServices(IServiceCollection services) { diff --git a/aspnetcore/security/data-protection/implementation/key-storage-providers.md b/aspnetcore/security/data-protection/implementation/key-storage-providers.md index 3b588eac6928..b9e8c234a638 100644 --- a/aspnetcore/security/data-protection/implementation/key-storage-providers.md +++ b/aspnetcore/security/data-protection/implementation/key-storage-providers.md @@ -3,9 +3,10 @@ title: Key storage providers in ASP.NET Core author: rick-anderson description: Learn about key storage providers in ASP.NET Core and how to configure key storage locations. ms.author: riande -ms.date: 12/05/2019 +ms.date: 10/29/2024 uid: security/data-protection/implementation/key-storage-providers --- + # Key storage providers in ASP.NET Core The data protection system [employs a discovery mechanism by default](xref:security/data-protection/configuration/default-settings) to determine where cryptographic keys should be persisted. The developer can override the default discovery mechanism and manually specify the location. @@ -43,6 +44,8 @@ public void ConfigureServices(IServiceCollection services) If the web app is running as an Azure service, connection string can be used to authenticate to Azure storage by using [Azure.Storage.Blobs](xref:Azure.Storage.Blobs.BlobContainerClient). +[!INCLUDE [managed-identities](~/includes/managed-identities-conn-strings.md)] + ```csharp string connectionString = ""; string containerName = "my-key-container"; diff --git a/aspnetcore/security/key-vault-configuration.md b/aspnetcore/security/key-vault-configuration.md index 5917f5921f2e..e8caccb71464 100644 --- a/aspnetcore/security/key-vault-configuration.md +++ b/aspnetcore/security/key-vault-configuration.md @@ -5,9 +5,10 @@ description: Learn how to use the Azure Key Vault configuration provider to conf monikerRange: '>= aspnetcore-3.1' ms.author: tdykstra ms.custom: mvc, devx-track-azurecli -ms.date: 01/07/2022 +ms.date: 10/29/2024 uid: security/key-vault-configuration --- + # Azure Key Vault configuration provider in ASP.NET Core :::moniker range=">= aspnetcore-6.0"