Skip to content

dotnet user-secrets should allow for entry from stdin without echo #28094

@reinux

Description

@reinux

Is your feature request related to a problem? Please describe.

dotnet user-scripts add <key> <value> has at least two problems:

  1. Depending on the shell, different symbols are escaped. In PowerShell, "woohoo i got $$!" will replace $$ with some token based on context. Bash has its own issues, apparently: dotnet user-secrets set does not parse escaped characters correctly aspnet/UserSecrets#76 . And Windows Terminal behaves differently from cmd.exe. All in all, there's far too much room for error, especially when entering things like passwords.

  2. Many shells and terminals log all inputs as a convenience feature, which could lead to accidental exposure of secrets.

Describe the solution you'd like

An interaction like this would be nice:

> dotnet user-secrets set
Enter secret name: test
Enter secret value:
Successfully saved test = <25 characters>

Or, entering dotnet user-secrets set "test" prompts for the value.

In either case, I think a warning to encourage users to enter values this way would also be helpful.

Describe alternatives you've considered

Writing directly to the to secrets.json, aside from being cumbersome, suffers a similar problem as 1, as the user would need to be aware of JavaScript's escape sequences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-very-fewThis issue impacts very few customersarea-commandlinetoolsIncludes: Command line tools, dotnet-dev-certs, dotnet-user-jwts, and OpenAPIenhancementThis issue represents an ask for new feature or an enhancement to an existing onefeature-user-secretsseverity-nice-to-haveThis label is used by an internal tool

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions