【问题标题】:OpenIddict The token request was rejected because the authorization code or the refresh token was invalidOpenIddict 令牌请求被拒绝,因为授权码或刷新令牌无效
【发布时间】:2018-11-21 04:02:10
【问题描述】:

我有一个托管在 IIS 服务器上的 ASP.NET Core 2.1 Angular 6 应用程序。我的刷新令牌无效时遇到问题。我有一个 IIS ARR Round Robin 集群。当只有一台服务器在线时,一切正常。但是,当多个服务器在线时,我的刷新令牌仅在向发出令牌的服务器发出请求时才有效。

我将此添加到我的 startup.cs 中,但没有成功

 app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.All
            });

            string XForwardedPathBase = "X-Forwarded-PathBase";
            string XForwardedProto = "X-Forwarded-Proto";

            app.Use((context, next) =>
            {
                if (context.Request.Headers.TryGetValue(XForwardedPathBase, out StringValues pathBase))
                {
                    context.Request.PathBase = new PathString(pathBase);

                }

                if (context.Request.Headers.TryGetValue(XForwardedProto, out StringValues proto))
                {
                    context.Request.Protocol = proto;
                }

                return next();
            });

【问题讨论】:

  • 我从 startup.cs 文件中删除了上述代码。

标签: angular6 iis-8 asp.net-core-2.1 round-robin web-farm-framework


【解决方案1】:

问题是密钥默认存储在本地计算机上。在网络场中,您需要将其保存在每个主机都可以访问的地方。我将此添加到我的 startup.cs 及其工作中。不知道为什么,但没有选项可以将密钥存储在 sql server 中。

 services.AddDataProtection()
      .PersistKeysToFileSystem(new DirectoryInfo(@"\\server\path\"));

https://docs.microsoft.com/en-us/aspnet/core/security/data-protection/configuration/overview?view=aspnetcore-2.1

【讨论】:

    猜你喜欢
    • 2016-08-29
    • 2017-12-25
    • 2020-06-13
    • 1970-01-01
    • 2017-02-02
    • 1970-01-01
    • 1970-01-01
    • 2017-01-11
    • 2017-05-09
    相关资源
    最近更新 更多