Closed zhangtingwz closed 6 years ago
When you say conflict what do you mean here?
One thing I notice immediately is you're calling add.Authentication() twice, and changing the default in the second call, so it's wiping out what you set for the default in cookies. You could do
services.AddAuthentication(x =>
{
x.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
x.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
x.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, x =>
{
/// Your config
}).AddJwtBearer(options =>
{
/// Your config
});
And then, when you apply Authorize you specify the scheme, so when you want JWT you'd go
[Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)]
And for cookies
[Authorize(AuthenticationSchemes = CookieAuthenticationDefaults.AuthenticationScheme)]
Dear blowdart I thank you very much ,sorry today ,i can see it,i have done it ,i create a new Authorize , then
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
.AddJwtBearer(JwtBearerAuthorizeAttribute.JwtBearerAuthenticationScheme,options =>
then use my create other Author ,that is ok. At last thank you very much again
@zhangtingwz how can you do it ? i met the same problem.
I hope in my code use cookie to Authen my pc use ,JwtBearerDefaults to for my api,but they are conflict,how can i do