问题描述
我正在使用ASP.NET 5,在我的解决方案中,我具有Web API,Identity Server和Angular 2项目,并且正在使用Identity Server对Angular 2客户端进行身份验证,Angular 2客户端通过在http请求中传递令牌来消耗Web api,并且Web api对令牌进行身份验证并给出响应,为此,我编写了一个自定义属性,用于检查用户是否已通过身份验证
I am using ASP.NET 5, In my solution I have Web API, Identity Server and Angular 2 project and I am authenticating Angular 2 client by using Identity Server, Angular 2 client consumes web api by passing token in http request and web api authenticate token and gives response, for this I have written a custom attribute which checks that user is authenticated or not
使用API时,出现以下异常,Web API返回500个内部服务器错误.
When I consume API I am getting following exception and Web API returns 500 internal server error.
推荐答案
如果Identityserver和访问令牌验证中间件托管在同一应用程序中,则启动时会出现竞争状况.
If identityserver and the access token validation middleware are hosted in the same application there is a race condition at startup.
验证中间件尝试加载发现文档,该文档尚不可用.
The validation middleware tries to load the discovery document, which is not yet available.
在这些情况下,请将验证中间件上的DelayLoadMetadata
标志设置为true.
In these scenarios, set the DelayLoadMetadata
flag on the validation middleware to true.
如果完全禁用发现端点,则需要在验证选项上配置发行方和密钥材料.
If you disable the discovery endpoint altogether, you need to configure the issuer and key material on the validation options.
这篇关于无法从众所周知的/openid配置获取配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!