c# - add multiple cookie schemes in aspnet core 2 -
how add multiple cookie schemes in aspnet core 2.0
?
i've followed instructions here auth 2.0 migration announcement , here migrating authentication , identity asp.net core 2.0 unable add multiple schemes.
for example:
services.addauthentication("myscheme1").addcookie(o =>{ o.expiretimespan = timespan.fromhours(1); o.loginpath = new pathstring("/foruser"); o.cookie.name = "token1"; o.slidingexpiration = true; }); services.addauthentication("myscheme2").addcookie(o =>{ o.expiretimespan = timespan.fromhours(1); o.loginpath = new pathstring("/foradmin"); o.cookie.name = "token2"; o.slidingexpiration = true; });
adding multiple schemes in aspnet core 2.0
simple. i've solved doing this.
services.addauthentication() .addcookie("myscheme1", o => // scheme1 { o.expiretimespan = timespan.fromhours(1); o.loginpath = new pathstring("/foruser"); o.cookie.name = "token1"; o.slidingexpiration = true; }) .addcookie("myscheme2", o => //scheme2 { o.expiretimespan = timespan.fromhours(1); o.loginpath = new pathstring("/foradmin"); o.cookie.name = "token2"; o.slidingexpiration = true; });
discussion can found here auth 2.0 migration announcement
wiki
Comments
Post a Comment