我在 .net core 中进行多个 OpenIdConnect 授权时遇到问题
我想要实现的目标:想象一下 2 个 openid 提供商 OpenID-Main、OpenID-Special;两者都返回 id 令牌、角色等。
现在想象一下,大多数时候我希望我的用户通过 OpenID-Main 登录,这很简单:
.AddOpenIdConnect("Main", "Main", options => {
options.Authority = "OpenID-Main-url";
options.ClientId = "OpenID-Main-d";
options.ClientSecret = "OpenID-Main-secret";
//some other options
}
那么我就可以使用[授权(AuthenticationSchemes = "主要")]效果很好
现在,对于某些类型的请求,我将要求用户登录其他提供商(请不要争论这种方法,让我们假设它是我必须做的事情)
.AddOpenIdConnect("Special", "Special", options => {
options.Authority = "OpenID-Special-url";
options.ClientId = "OpenID-Special-d";
options.ClientSecret = "OpenID-Special-secret";
//some other options
}
然后两者都有[授权(AuthenticationSchemes = "主要")] [授权(AuthenticationSchemes = "特殊")]在我的终点之一
这样,只有在 Main 和 Special 中都获得授权的用户才能执行请求,并且我可以从 Special 中获取 idToken。
我遇到类似相关失败之类的错误。我尝试提供 siddwewnr CorrelationCookie.Name,但没有成功;尝试覆盖一些基本身份验证类,但也卡住并复制多个代码部分。
我的问题是
1. Is it ever possible with Microsoft.AspNetCore.Authentication ?
2. How can I achieve it? Can I do proper CookieBuilder for second auth?
3. How can I manage this easily so that I can get idToken from second cookie?
4. Do I need to write whole handler/extensions/options like those for facebook/google?