Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why don't we use secret.json when creating an admin account? #46

Closed
sadqiang opened this issue Jan 16, 2018 · 2 comments
Closed

Why don't we use secret.json when creating an admin account? #46

sadqiang opened this issue Jan 16, 2018 · 2 comments
Labels

Comments

@sadqiang
Copy link

sadqiang commented Jan 16, 2018

Putting the following data

"Administrator" : {
     "UserName" : "admin@todo.local",
     "Email" : "admin@todo.local",
     "Password" : "NotSecure123!!"
}

in secret.json and loading them via IConfiguration con should be safer as well as it promotes a better practice.

private static async Task EnsureTestAdminAsync(UserManager<ApplicationUser> userManager, IConfiguration con)
{
    // ........

    testAdmin = new ApplicationUser { UserName = con["Administrator:UserName"], Email = con["Administrator:Email"] };
    await userManager.CreateAsync(testAdmin, con["Administrator:Password"]);
    await userManager.AddToRoleAsync(testAdmin, Constants.AdministratorRole);
}

Note: secret.json will not be uploaded to github repository.

@sadqiang sadqiang changed the title Why don Why don't we use secret.json when creating an admin account? Jan 16, 2018
@OlekRia
Copy link

OlekRia commented Jan 23, 2018

AFAIK, secret.json used for development only. When you as a user have own password and want to override your development configuration. So, data in this json will be only in your computer, not in SVN.
{ "Administrator": { "Password": "My onw developer password" }}

So, secrets.json might be useful for scenario like u have different users, passwords, etc. in different machines, for example of SQL connection.

And for most securable reason in production we have to use Environment variable which overrides both appsettings.json and secret.json:
set Adminitrator__Password TopSecretPasswordForRealDevOps

@nbarbettini
Copy link
Owner

The example in the book is meant to be for demonstration purposes only, hence a goofy password like NotSecure123!!. It's a value only used once to seed the database, and the instructions tell the user to change it immediately.

If you need to store and retrieve a sensitive configuration value repeatedly, you should definitely use environment variables (in production) or secrets.json (in development). This example doesn't really fall into that category in my opinion.

I'll investigate not using a hardcoded password in #58.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants