dotnet / dotnet/aspnetcore

Configuring the DataProtection options via appsettings.json file

Open
#45,942 11 comments 0 reactions 0 assignees View on GitHub
area-dataprotection design-proposal
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 9h
Merged PRs (30d)
276

Description

## Summary

Currently, it seems the DataProtection settings need to be configured via code. We are looking for support via appsettings.json or in general via configuration without recompiling the application for different deployment environment types.

## Motivation and goals

As developers, we would like to code once and deploy in various environment types by tuning the configuration. Currently, the DataProtection configuration seems to support only via code. Though we can read configuration in a custom way, it would be great if the library provides the configuration options out of box.

## In scope

Configure the DataProtection options from appsettings.json. In code, we will be adding `services.AddDataProtection();`

## Out of scope

## Risks / unknowns

How might developers misinterpret/misuse this? How might implementing it restrict us from other enhancements in the future? Also list any perf/security/correctness concerns.

## Examples

`services.AddDataProtection()` - This will be loading the settings from the appsettings.json before defaulting to the values in the code.

ex: By default, the keys are stores at %USERPROFILE%\AppData\Local\ASP.NET\DataProtection-Keys. To change this folder we have to write code. This path should be configurable via appsettings.json

Contributor guide

Open the contributing guide

Research direction

The issue names no source files, tests, or entry points beyond services.AddDataProtection(). Start by tracing how DataProtection options are currently configured and how application configuration is loaded. Define how appsettings.json values should map to those options, including the key-storage path, while preserving code defaults and addressing the listed security and compatibility questions.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
security
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.