fix authentication issue in mvc sample app
This commit is contained in:
@@ -25,15 +25,15 @@
|
||||
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\AspNetCore.Identity.MongoDbCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Update="appsettings.json">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<!-- Select one of the following to build this solution -->
|
||||
<ItemGroup>
|
||||
<!-- <PackageReference Include="AspNetCore.Identity.MongoDbCore" Version="3.1.0" /> -->
|
||||
<ProjectReference Include="..\..\src\AspNetCore.Identity.MongoDbCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user