In .NET Core 2.0 the Authentication Classes have been majorly redesigned in the upcoming version of the cross-plattform framework.
The old
app.UseCookieAuthentication(new CookieAuthenticationOptions{...});
is deprecated now and therefore not working anymore. Which leads to major problems with the website’s authentication mechanism.
app.UseCookieAuthentication()
in your
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
method has been replaced by the
public void ConfigureServices(IServiceCollection services){ services.AddCookieAuthentication( options => {...}); }
In your Configure(…) method a simple
app.UseAuthentication();
call now is sufficient.
Furthermore the
SignInAsync
Mechanism has been redesigned as well.
Instead of
AuthenticationManager.SignInAsync(string authscheme, ClaimsPrinciple cp);
a call to the HttpContext itself is necessary
HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, claimsPrinciple);
So HttpContext.Authentication is mostly(?) obsolete.
The needed namespaces are:
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Cookies;
Keep an eye on the Git Repository, you’ll find most of the information there:
Most importantly: https://github.com/aspnet/Announcements/issues/232
https://github.com/aspnet/Security/issues/1179
https://github.com/aspnet/Security/pull/1170/files