React to auth default changes

This commit is contained in:
Hao Kung 2017-07-07 12:08:11 -07:00
parent f1c4aa14d3
commit e09a0f5b7c
3 changed files with 6 additions and 3 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace RazorPagesWebSite namespace RazorPagesWebSite
@ -10,7 +11,7 @@ namespace RazorPagesWebSite
{ {
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddAuthentication().AddCookie(options => options.LoginPath = "/Login"); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => options.LoginPath = "/Login");
services.AddMvc() services.AddMvc()
.AddCookieTempDataProvider() .AddCookieTempDataProvider()
.AddRazorPagesOptions(options => .AddRazorPagesOptions(options =>

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace RazorPagesWebSite namespace RazorPagesWebSite
@ -10,7 +11,7 @@ namespace RazorPagesWebSite
{ {
public void ConfigureServices(IServiceCollection services) public void ConfigureServices(IServiceCollection services)
{ {
services.AddAuthentication() services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(options => options.LoginPath = "/Login"); .AddCookie(options => options.LoginPath = "/Login");
services.AddMvc() services.AddMvc()
.AddCookieTempDataProvider() .AddCookieTempDataProvider()

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
namespace SecurityWebSite namespace SecurityWebSite
@ -14,7 +15,7 @@ namespace SecurityWebSite
// Add framework services. // Add framework services.
services.AddMvc(); services.AddMvc();
services.AddAntiforgery(); services.AddAntiforgery();
services.AddAuthentication().AddCookie(options => services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options =>
{ {
options.LoginPath = "/Home/Login"; options.LoginPath = "/Home/Login";
options.LogoutPath = "/Home/Logout"; options.LogoutPath = "/Home/Logout";