我对中间件的概念比较陌生。我知道一个中间件在完成时调用下一个中间件。多重身份验证中间件ASP.NET核心
我试图使用Google或我的Identity Server来验证请求。用户可以使用谷歌或本地帐户登录我的移动应用程序。但是,我无法弄清楚如何使用两个身份验证中间件。如果我通过了google的id_token,它会传递第一个中间件(UseJwtBearerAuthentication
),但在第二个(UseIdentityServerAuthentication
)上失败。我怎样才能使它在传递至少一个身份验证中间件时不会抛出错误?例如,如果它传递给第一个中间件,那么第二个中间件会被忽略?
app.UseJwtBearerAuthentication(new JwtBearerOptions()
{
Authority = "https://accounts.google.com",
Audience = "secret.apps.googleusercontent.com",
TokenValidationParameters = new TokenValidationParameters()
{
ValidateAudience = true,
ValidIssuer = "accounts.google.com"
},
RequireHttpsMetadata = false
});
app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
Authority = "http://localhost:1000/",
RequireHttpsMetadata = false,
ScopeName = "MyApp.Api"
});
当我回家后,会尝试解决方案2,并在此之后将其标记为答案。谢谢您的回复。 –