我在 .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
}
Run Code Online (Sandbox Code Playgroud)
那么我可以使用[Authorize(AuthenticationSchemes = "Main")] 这很好用现在对于某些类型的请求我将要求用户登录到其他提供商(请不要争论这种方法,让我们假设它是我有的东西去做)
.AddOpenIdConnect("Special", "Special", options => {
options.Authority = "OpenID-Special-url";
options.ClientId = "OpenID-Special-d";
options.ClientSecret = "OpenID-Special-secret";
//some other options
}
Run Code Online (Sandbox Code Playgroud)
然后在我的端点之一中同时拥有[Authorize(AuthenticationSchemes = "Main")] [Authorize(AuthenticationSchemes = "Special")]这样,只有在 Main 和 Special 中都获得授权的用户才能执行请求,并且我可以从中获取 idToken特别的。
我遇到类似相关失败之类的错误。我尝试提供 siddwewnr CorrelationCookie.Name,但没有成功;尝试覆盖一些基本身份验证类,但也卡住并复制多个代码部分。
我的问题是
1. Is it ever possible …Run Code Online (Sandbox Code Playgroud) 我有一个非常简单的数组属性案例,更新后不会使计算属性更改 jsfidle 链接:https ://jsfiddle.net/fx1v4ze6/30/
Vue.component('test', {
data: function() {
return {
arr: this.myarray.slice()
}
},
props:['myarray','secondprop'],
template:'#arraybug',
methods:{
add:function(){
this.myarray.push(1);
this.secondprop+=1;
this.arr.push(1);
}
},
computed:{
mycomputed: function(){
return this.arr.length;
},
mycomputed2: function(){
return this.secondprop;
},
mycomputed3: function(){
return this.myarray.length;
},
}
});
var test = new Vue({
el:"#test"});
Run Code Online (Sandbox Code Playgroud)
HTML:
<div id="test">
<test :myarray="[1,2,3]" :secondprop="1"></test>
</div>
<template id="arraybug">
<div >
<button v-on:click="add()">
click
</button>
{{mycomputed}} - {{mycomputed2}} - {{mycomputed3}}
</div>
</template>
Run Code Online (Sandbox Code Playgroud)
我希望,由于 mycomputed 是基于 myarray,因此对 myarray 的任何更改都将导致计算更新。我错过了什么?
我已经更新了我的例子 - mycomputed2 …
通过设置 asp.net 核心,AddOpenIdConnect它通过默认/signin-oidc页面创建,当从 opeind 提供程序访问时,该页面工作正常。用户已登录,一切正常。
虽然用户仍然可以尝试mypage.com/signin-oidc直接访问并得到Correlation failed失败的错误。
如何正确处理对该页面的访问,使其仍然适用于 openid 流,但在直接访问时不会产生错误(重定向)?(已经尝试用 HttpGet 覆盖 Route)
编辑
详细说明,将/signin-oidc使用基础启动提供 500 状态,例如
``
public void ConfigureServices(IServiceCollection services)
{
services.AddOptions();
services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = OpenIdConnectDefaults.AuthenticationScheme;
options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
}).AddCookie()
.AddOpenIdConnect(options =>
{
options.ClientId = "test";
options.ClientSecret = Environment.GetEnvironmentVariable("ClientSecret");
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.Authority = "https://test.net";
options.ResponseType = "code";
options.Scope.Add("openid");
options.GetClaimsFromUserInfoEndpoint = true;
options.SaveTokens = true;
options.Events = new OpenIdConnectEvents
{
OnTokenValidated = async …Run Code Online (Sandbox Code Playgroud)