Docs link -- https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?tabs=visual-studio%2Caspnetcore2x
https://docs.microsoft.com/en-us/aspnet/core/security/app-secrets?tabs=visual-studio
We can create a secrets.json file in visual studio by right click on solution Manage User Secrets and then write the following in the secrets.json file
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\MSSQLLocalDB;Database=_CHANGE_ME;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}
https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl
To create a new razor app with security enabled, use
donet new --auth Individual -o AuthLearnCoreApp
The template already uses a IdentityUser Model with all the necessary attributes and checks for the user model in the database.
IdentityUser already has strong assumptions about the table names and column names of the users table. Hence to change the default column and table names, override the onModelCreating method in the ApplicationDBContext class https://stackoverflow.com/questions/19460386/how-can-i-change-the-table-names-when-using-visual-studio-2013-asp-net-identity
We can use ignore class members for column mapping using the NotMapped annotation or using the modelBuilder.Entity<Customer>().Ignore(t => t.LastName);
command in during the onModelCreating method
Procedure to add Google authentication -- https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/google-logins?tabs=aspnetcore2x