我有一个基于 IS4 Identity 示例的 IdentityServer4 应用程序,以及一个使用不记名令牌通过 IS4.AccessTokenValidation 进行授权的 API。这通过 VisualStudio 在 localhost 上运行良好,当我部署到 Windows 2012 VM 并通过 IIS 托管时。当我将身份服务器作为应用服务网站部署到 Azure 时,一切都很好。但是,当 API 部署为使用与 VM 相同的域和证书的应用服务时,任何具有 Authorize 属性(有策略或无策略都无关紧要)的方法总是返回带有标头消息的 401:
Www-Authenticate: Bearer error="invalid_token", error_description="The signature key was not found"
我们使用 .NET 4.5.2,最新版本的 IdentityServer4 和 IdentityServer4.AccessTokenValidation 包。我还从 2016 年 8 月 30 日从 GitHub 中提取了最新的这些包,没有任何变化。无论如何,我不认为 IS4 Validator 是一个错误,但我不知道是什么原因造成的。有什么建议么?它是 Azure 主机错误吗?
我希望能够对此进行调试,但即使我从头开始重建,我也无法让远程调试对这个应用程序起作用,并且应用程序日志什么也没告诉我。我在 ASP.NET 安全存储库中翻找过,但没有更多的日志记录或调试访问权限,我对如何解决这个问题一无所知。
API 配置非常基础:
var jwtBearerOptions = new JwtBearerOptions()
{
Authority = Configuration["Authentication:IdentityServer:Server"],
Audience = Configuration["Authentication:IdentityServer:Server"]+"/resources",
RequireHttpsMetadata = false,
AutomaticAuthenticate = true,
AutomaticChallenge = true,
};
app.UseJwtBearerAuthentication(jwtBearerOptions);
并且 Identity Server 是直接从样本中提取出来的,并且使用购买的证书进行签名。
是否有其他人将此配置完全用作 2 个 Azure 应用程序服务?或者考虑到发送到 VM 托管 API 的相同不记名令牌,可能导致此错误的原因是可以接受的。