Skip to content

Instantly share code, notes, and snippets.

@fmshk97
Last active February 23, 2021 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmshk97/0dad87d9768b8c9855545d6a01ec3776 to your computer and use it in GitHub Desktop.
Save fmshk97/0dad87d9768b8c9855545d6a01ec3776 to your computer and use it in GitHub Desktop.
Register authentication middleware in Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddIdentityCore<AppUser>(options => {
options.User.AllowedUserNameCharacters = "hojn._";
});
services.AddScoped<IUserStore<AppUser>, AppUserStore>();
// Below line registers the authentication service in our app
// along with a cookie-based authentication scheme named "Cookies"
// "Cookies" is also set as the default authentication scheme
services.AddAuthentication(defaultScheme: "Cookies")
.AddCookie("Cookies");
services.AddControllers();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment