diff --git a/aspnetcore/fundamentals/configuration/index.md b/aspnetcore/fundamentals/configuration/index.md index 785f46db77a5..bd771b4957cf 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) @@ -158,6 +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. +* 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`. @@ -165,8 +167,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 +409,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 +462,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..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 @@ -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..469a6a10039f 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` @@ -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. +* 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`. @@ -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..189d7f998989 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` @@ -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. +* 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`. @@ -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/use-http-context.md b/aspnetcore/fundamentals/use-http-context.md index e5c63f2fa052..05266eb35304 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,7 +30,7 @@ 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| ### Get request headers diff --git a/aspnetcore/includes/managed-identities-conn-strings.md b/aspnetcore/includes/managed-identities-conn-strings.md new file mode 100644 index 000000000000..e8d80e875779 --- /dev/null +++ b/aspnetcore/includes/managed-identities-conn-strings.md @@ -0,0 +1,9 @@ +--- +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 environments, see [Secure authentication flows](xref:security/index#secure-authentication-flows).