question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Secrets Management in different Environments

See original GitHub issue

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

Secrets management in Development environments is unfulfilling. The Basic configuration is helpful, but is not user friendly when handling multiple environments and bigger teams, as it lacks:

  • Quickly switching between different secrets for different environments
  • finding currently configured secrets (of course there is dotnet user-secrets list, but one has to remember this command instead of visually seeing the .env file in the repository`)
  • misalignment with “industry standards” (if you could call .env files this)
  • Easy sharing of secrets between developers (where was the file again to quickly share with my coworker?)

Describe the solution you’d like

There are multiple ways to relief some development pain:

  1. Allowing another flag for the current cli: (Apart from the --configuration), e.g. --environment Basically this would be the equivalent to the different appsettings.json files. If the application would read appsettings.Development.json it would also read secrets.Development.json and the CLI options would write to the respective file. This would allow to easily switch between “Staging” and “Development” Secrets (basically allowing each launch Profile to potentially have different Secrets). Please note that the current --configuration implementation does not allow this, as I might want to Debug with the secrets from the Staging Environment or test the Release build with the local Development Secrets.

  2. Make the dotnet eco system understand .env files. Instead of writing extra documentation about how to handle secrets with the dotnet project or searching the internet for this guide .env files could be used as they are a defacto standard known to many development tools. Some ideas on how to add them:

    • Add launchSettings.json support:
    {
     "profiles": {
       "EnvironmentsSample": {
         "commandName": "Project",
         "dotnetRunMessages": true,
         "launchBrowser": true,
         "applicationUrl": "https://localhost:7152;http://localhost:5105",
         "environmentVariables": {
           "ASPNETCORE_ENVIRONMENT": "Development"
         },
        // Add another Option for reading .env Files
        "environmentFiles": [".env", "development.env"]
       },
    }
    
    • Add dotnet cli support: For --configuration=Development the .env file could be loaded automatically. For manually adding it with other configurations adding the option --env-file .env would be great.

Additional context

As a workaround one could use a nuget package such as DotNetEnv but this would add unneeded complexity and packages to the build + functionality which would only be called during Development or anytime adding side effects to Release Builds.

Issue Analytics

  • State:open
  • Created 3 months ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
baronfelcommented, Jun 15, 2023

Made a quick update to the gitignore template as a PR to at least give us some coverage if we do decide to do things with dotenv in the future. Several other ecosystems’ gitignore files in the github/gitignore repo already have this, so we’re playing catchup from a safety perspective here.

1reaction
blowdartcommented, Jun 15, 2023

At least .env files are understood as not to be checked in virtually everywhere.

For those people that know and understand them 😃

It’s worth evaluating for 8 though, but we’d have to make sure VS’s default gitignore does indeed ignore .env, and also look at what github and azdo do, just in case it does get checked in with secrets.

But I leave that to feature PMs, I’ve gone my spoilsport security rant now 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Secrets Management in Complex Environments at Scale
Secrets management is becoming increasingly important but remains difficult to implement, scale, maintain and secure in complex environments that can include  ...
Read more >
Secrets Management Cheat Sheet
Most cloud providers have at least one service that offers secret management. Of course, it's also possible to run a different secret management...
Read more >
What is Secret Management | Tools & Best Practices
Secret Management is a practice that allows developers to securely store sensitive data in a secure environment with strict access controls.
Read more >
Managing Secrets Within Your Development Environment
There are different approaches you can take to limit exposure from running configuration management systems or secret managers like Vault ...
Read more >
The quick guide to secrets management in the enterprise
Secrets management is the appropriate set of tools and best practices used to securely store, access and centrally manage digital authentication ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found