ric*_*rdb 3 jwt azure-web-app-service identityserver4 asp.net-core-2.2
有一个尝试获取 OpenId 配置的 Asp.Net Core 2.2.1 Web Api,以便它可以对请求进行身份验证。权威网站恰好是 IdentityServer4。
/.well-known/openid-configuration 看起来正确,api 站点正在运行,不安全的 api 方法工作正常。
在 Kudu 中查看日志,我看到以下错误。似乎是由套接字问题引起的,但我不知道这里出了什么问题。
在我的开发机器上本地一切正常,那么我缺少什么/Azure 需要什么?
System.IO.IOException: IDX20804: Unable to retrieve document from: '[PII is hidden]'. --->
System.Net.Http.HttpRequestException: An attempt was made to access a socket
in a way forbidden by its access permissions --->
Run Code Online (Sandbox Code Playgroud)
完整的错误细节;
2019-01-11 11:07:43.096 +00:00 [Error] Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler: Exception occurred while processing message.
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: '[PII is hidden]'. ---> System.IO.IOException: IDX20804: Unable to retrieve document from: '[PII is hidden]'. ---> System.Net.Http.HttpRequestException: An attempt was made to access a socket in a way forbidden by its access permissions ---> System.Net.Sockets.SocketException: An attempt was made to access a socket in a way forbidden by its access permissions
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
--- End of inner exception stack trace ---
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask`1 creationTask)
at System.Threading.Tasks.ValueTask`1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(String address, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.OpenIdConnect.OpenIdConnectConfigurationRetriever.GetAsync(String address, IDocumentRetriever retriever, CancellationToken cancel)
at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
--- End of inner exception stack trace ---
at Microsoft.IdentityModel.Protocols.ConfigurationManager`1.GetConfigurationAsync(CancellationToken cancel)
at Microsoft.AspNetCore.Authentication.JwtBearer.JwtBearerHandler.HandleAuthenticateAsync()
Run Code Online (Sandbox Code Playgroud)
经过数小时的调试,然后开机
IdentityModelEventSource.ShowPII = true; //show detail of error and see problem
Run Code Online (Sandbox Code Playgroud)
要查看众所周知的配置的问题,我发现它没有从 Azure 门户获取应用程序设置。
由于我的设置是嵌套的,我只需要确保 Azure 刀片中的密钥匹配即可。
IE
{
"AppSettings": {
"ApiUrl": "someUrl",
"AuthorityUrl": "anotherUrl"
}, ...
Run Code Online (Sandbox Code Playgroud)
变成
AppSettings:ApiUrl
Run Code Online (Sandbox Code Playgroud)
简单的错误陷阱。
| 归档时间: |
|
| 查看次数: |
2772 次 |
| 最近记录: |