kun*_*gcc 5 kubernetes openiddict nginx-reverse-proxy abp
我已经将ABP框架部署在Kubernetes集群中。
存在以下部署:
因此,AuthServer、HttpApi.Host 正在侦听端口 80 / http,而 nginx 正在侦听 https。配置/Helm 值如下:
use-forwarded-headers: "true"
use-proxy-protocol: "true"
use-gzip: "true"
Run Code Online (Sandbox Code Playgroud)
到目前为止一切顺利,部署后我可以进入 Swagger 并授权:

通过检查 AuthServer 日志可以确认这一点:
[19:12:39 INF] CORS policy execution successful.
[19:12:39 INF] The request URI matched a server endpoint: Token.
[19:12:39 INF] The token request was successfully extracted: {
"grant_type": "authorization_code",
"code": "[redacted]",
"client_id": "foobar_Swagger",
"redirect_uri": "https://api.staging.foobar.io/swagger/oauth2-redirect.html"
}.
[19:12:39 INF] The token request was successfully validated.
Run Code Online (Sandbox Code Playgroud)
但是,现在我想使用 Swagger 来确保与端点的连接正常工作,因此我尝试第一个 GET 端点:

如您所见,有 500 个响应。查看 HttpApi.Host pod 中的日志:
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ProcessRequests[TContext](IHttpApplication`1 application)
[19:12:52 ERR] Connection id "0HMSQJRK38VSM", Request id "0HMSQJRK38VSM:00000005": An unhandled exception was thrown by the application.
System.InvalidOperationException: IDX20803: Unable to obtain configuration from: '[PII of type 'System.String' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
---> System.IO.IOException: IDX20804: Unable to retrieve document from: '[PII of type 'System.String' is hidden. For more details, see https://aka.ms/IdentityModel/PII.]'.
---> System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
---> System.IO.IOException: Unable to read data from the transport connection: Connection reset by peer.
---> System.Net.Sockets.SocketException (104): Connection reset by peer
--- End of inner exception stack trace ---
Run Code Online (Sandbox Code Playgroud)
所以看来 HttpApi 无法连接到 AuthServer,因为根据上面的堆栈跟踪“无法建立 SSL 连接,请参阅内部异常”,它是 http
看起来 HttpApi.Host 正在通过集群内的 http 连接,但 AuthServer 不喜欢它?
请在这里给我一些建议,先谢谢了。
首先,您可以禁用 PII 以查看详细信息,这有助于查看确切的错误。只需添加:
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
Run Code Online (Sandbox Code Playgroud)
ConfigureServices您的服务方法。
您遇到的问题可能与在内部网络中找到正确的发现端点(以验证令牌)有关。您的应用程序已通过身份验证,Authorization URL但它正在尝试访问 k8s 网络内的相同 URL 以到达发现端点。但是它需要向内部服务名称而不是DNS发出请求。
在v7.4-rc.1之后,我们在Volo.Abp.Swashbuckle包中添加了 OIDC 支持,您可以定义与颁发者(授权 URL)不同的元数据(发现端点)地址。
您可以使用该.AddAbpSwaggerGenWithOidc()方法。请记住,发现 url应该是真实的 DNS,权限应该是 k8s 服务名称。
编辑: 您可以在以下位置查看文档:ABP Swagger Integration,并且可以在以下位置找到示例:ABP Swagger Demo
您可以将元数据设置为:https://myauthserver.staging.mycompany.com/.well-known/openid-configuration。在v7.4-rc.2之后,将元数据设置为https://myauthserver.staging.mycompany.com没有完整路径就足够了。
您还可以将其设置RequireHttpsMetadata为 false,因为令牌验证的发现点将针对端点进行,http://myprojectname-st-authserver而不是真正的 DNS,例如:https://myauthserver.staging.mycompany.com
| 归档时间: |
|
| 查看次数: |
260 次 |
| 最近记录: |