Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
397 views
in Technique[技术] by (71.8m points)

asp.net-core - 发展的秘密(Secrets in development)

In development is there a good way to store secrets in environment variables and not to have them in git?

(在开发中,有什么好方法可以将机密存储在环境变量中,而不是将其存储在git中?)

In VS Properties -> Debug -> Environment variables it is possible to set it but I guess it is stored somewhere in .vs directory.

(在“ VS Properties -> Debug -> Environment variables ,可以进行设置,但我想它存储在.vs目录中的某个位置。)

Should it be committed?

(应该承诺吗?)

I red this article and it sounds too complicated for such a simple task.

(我把这篇文章改成红色,听起来对于这样一个简单的任务来说太复杂了。)

Also I want to have same secret loading code for development and production.

(我也想拥有用于开发和生产的相同的秘密加载代码。)

  ask by Jonas translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I guess it is outdated documentation.

(我想这是过时的文档。)

With Core 3.0 you don't need to add anything special to template ASP project, it almost works out of the box.

(使用Core 3.0,您无需为模板ASP项目添加任何特殊功能,它几乎可以立即使用。)

    public class Startup
    {
        public Startup(IConfiguration configuration)
        {
            Configuration = configuration;
        }

        public IConfiguration Configuration { get; }

Configuration is going to have values from appsettings.json overridden by secrets.json overridden by environment variables.

(Configuration将具有来自appsettings.json的值,这些值被secrets.json覆盖,并被环境变量覆盖。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...