fix authentication issue in mvc sample app

This commit is contained in:
Alexandre SPIESER
2021-03-16 09:19:02 +00:00
parent 94d8f6b1ec
commit 35ab8de584
7 changed files with 513 additions and 930 deletions
+19 -2
View File
@@ -41,11 +41,29 @@ namespace MongoIdentitySample.Mvc
services.AddSingleton<MongoDbSettings>(settings);
services.AddIdentity<ApplicationUser, MongoIdentityRole>()
services.AddAuthentication(o =>
{
o.DefaultScheme = IdentityConstants.ApplicationScheme;
o.DefaultSignInScheme = IdentityConstants.ExternalScheme;
})
.AddIdentityCookies(o => { });
services.AddIdentityCore<ApplicationUser>()
.AddRoles<MongoIdentityRole>()
.AddMongoDbStores<ApplicationUser, MongoIdentityRole, Guid>(settings.ConnectionString, settings.DatabaseName)
.AddSignInManager()
.AddDefaultTokenProviders();
services.ConfigureApplicationCookie(options =>
{
// Cookie settings
options.Cookie.HttpOnly = true;
options.ExpireTimeSpan = TimeSpan.FromMinutes(5);
options.LoginPath = "/Account/Login";
options.SlidingExpiration = true;
});
var builder = services.AddRazorPages();
@@ -70,7 +88,6 @@ namespace MongoIdentitySample.Mvc
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{