小编Ant*_*rps的帖子

Identity Server 4 在负载均衡器后面运行

我已经使用实体框架为我的项目设置了 Identity Server 4。我已经将服务配置为使用持久授权存储和签名证书。

services.AddIdentityServer()
        .AddSigningCredential(Config.GetSigningCertificate())
        .AddResourceOwnerValidator<ResourceOwnerPasswordValidator>()
        .AddProfileService<ProfileService>()
        .AddConfigurationStore(builder =>
                    builder.UseSqlServer(connectionString, options =>
                        options.MigrationsAssembly(migrationsAssembly)))
        .AddOperationalStore(builder =>
                    builder.UseSqlServer(connectionString, options =>
                        options.MigrationsAssembly(migrationsAssembly)));
Run Code Online (Sandbox Code Playgroud)

这是服务的配置。

问题是,当我在负载均衡器后面运行服务器(例如,有 2 个相同的实例处理所有请求)时,用户未登录的服务器无法解码 JWT 令牌,从而导致 401 未经授权的错误。

我假设令牌的签名方法或其加密是问题所在,但我找不到解决此问题的方法。

这是我的其余配置。

配置:

app.UseIdentityServerAuthentication(new IdentityServerAuthenticationOptions
{
      Authority = url,
      // Authority = "http://localhost:5000",
      AllowedScopes = { "WebAPI" },
      RequireHttpsMetadata = false,
      AutomaticAuthenticate = true,
      AutomaticChallenge = true,

});
Run Code Online (Sandbox Code Playgroud)

客户端:

new Client
{
     ClientId = "Angular2SPA",
     AllowedGrantTypes = GrantTypes.ResourceOwnerPassword, // Resource Owner Password Credential grant.
     AllowAccessTokensViaBrowser = true,
     RequireClientSecret = false, // This …
Run Code Online (Sandbox Code Playgroud)

.net c# asp.net-identity asp.net-core

5
推荐指数
1
解决办法
4190
查看次数

Python-如何-大查询异步任务

这可能是一个虚拟的问题,但我似乎无法异步运行python google-clood-bigquery。

我的目标是同时运行多个查询,并在asyncio.wait()查询收集器中等待所有查询完成。我正在asyncio.create_tast()用来启动查询。问题是每个查询在开始之前都等待先例的完成。

这是我的查询功能(非常简单):

async def exec_query(self, query, **kwargs) -> bigquery.table.RowIterator:
  job = self.api.query(query, **kwargs)
  return job.result()
Run Code Online (Sandbox Code Playgroud)

既然我不能等待job.result(),我应该等待其他东西吗?

python async-await google-bigquery

5
推荐指数
2
解决办法
1421
查看次数

C#-Xamarin.iOs-向xamarin.auth请求添加随机数

我找不到将随机数添加到Xamarin.Auth请求以连接到我的okta登录名的方法。我是xamarin和nugets包的新手,我不知道如何修改1.3.0版的OAuth2Authenticator的实现。

我正在尝试将request参数用作:

auth.RequestParameters.Add(“ nonce”,Guid.NewGuid()。ToString(“ N”));

但是我从okta一直运行在nonce无效错误中。

如果您有任何想法如何解决。

以下是完整的请求:

   //start login flow seting our openId flow
    public void StartFlow(string responseType, string scope)
    {

        //webViewLogin.Hidden = false;
        var auth = new OAuth2Authenticator(
            clientId: OAuthClientId,
            scope: scope,
            authorizeUrl: new Uri(oktaTenantUrl),
            redirectUrl: new Uri(OAuthRedirectUrl)
            );
        auth.RequestParameters.Add("nonce", Guid.NewGuid().ToString("N"));
        auth.Completed += (sender, eventArgs) =>
        {
            DismissViewController(true, null);
            if (eventArgs.IsAuthenticated)
            {
                    // Use eventArgs.Account to do wonderful things
                }
        };
        PresentViewController(auth.GetUI(), true, null);
    }
Run Code Online (Sandbox Code Playgroud)

c# xamarin.ios xamarin

1
推荐指数
1
解决办法
585
查看次数