使用 Spring Sleuth Zipkin 配置基本身份验证
Configure basic authentication with Spring Sleuth Zipkin
我正在尝试配置我的 spring 启动应用程序以登录到 zipkin 服务器。问题是该服务器受代理(具有基本身份验证)保护,我找不到任何描述如何使用 spring-sleuth.
配置授权的文档
我试过使用那种配置:
spring.zipkin.baseUrl: http://user:password@zipkin-server:9411
但没有成功,日志显示:
ZipkinRestTemplateWrapper : Created POST request for "http://user:password@zipkin-server:9411/api/v2/spans"
ZipkinRestTemplateWrapper : Setting request Accept header to [text/plain, application/json, application/*+json, */*]
ZipkinRestTemplateWrapper : Writing [[B@46d92b65] as "application/json" using [org.springframework.http.converter.ByteArrayHttpMessageConverter@53804b23]
ZipkinRestTemplateWrapper : POST request for "http://user:password@zipkin-server:9411/api/v2/spans" resulted in 401 (Unauthorized); invoking error handler
我试过 curl 并且有效。
是否有人已经成功配置了 spring-sleuth 的身份验证?
对于基本身份验证,用户名和密码需要作为 HTTP Header Authorization
的一部分发送。 header 值计算为字符串 username:password
的 Base64 编码。因此,如果用户名是 abcd
,密码是 1234
,header 将类似于这个(使用的聊天集:UTF-8)。
Authorization: Basic YWJjZDoxMjM0
Sleuth 云项目提供ZipkinRestTemplateCustomizer
配置RestTemplate
用于与 Zipkin 服务器通信。
相同的请参阅文档:
https://cloud.spring.io/spring-cloud-sleuth/reference/html/#sending-spans-to-zipkin
注意:Base64 编码是可逆的,因此基本身份验证凭据不安全。 HTTPS 通信应与基本身份验证一起使用。
我正在尝试配置我的 spring 启动应用程序以登录到 zipkin 服务器。问题是该服务器受代理(具有基本身份验证)保护,我找不到任何描述如何使用 spring-sleuth.
配置授权的文档我试过使用那种配置:
spring.zipkin.baseUrl: http://user:password@zipkin-server:9411
但没有成功,日志显示:
ZipkinRestTemplateWrapper : Created POST request for "http://user:password@zipkin-server:9411/api/v2/spans"
ZipkinRestTemplateWrapper : Setting request Accept header to [text/plain, application/json, application/*+json, */*]
ZipkinRestTemplateWrapper : Writing [[B@46d92b65] as "application/json" using [org.springframework.http.converter.ByteArrayHttpMessageConverter@53804b23]
ZipkinRestTemplateWrapper : POST request for "http://user:password@zipkin-server:9411/api/v2/spans" resulted in 401 (Unauthorized); invoking error handler
我试过 curl 并且有效。
是否有人已经成功配置了 spring-sleuth 的身份验证?
对于基本身份验证,用户名和密码需要作为 HTTP Header Authorization
的一部分发送。 header 值计算为字符串 username:password
的 Base64 编码。因此,如果用户名是 abcd
,密码是 1234
,header 将类似于这个(使用的聊天集:UTF-8)。
Authorization: Basic YWJjZDoxMjM0
Sleuth 云项目提供ZipkinRestTemplateCustomizer
配置RestTemplate
用于与 Zipkin 服务器通信。
相同的请参阅文档: https://cloud.spring.io/spring-cloud-sleuth/reference/html/#sending-spans-to-zipkin
注意:Base64 编码是可逆的,因此基本身份验证凭据不安全。 HTTPS 通信应与基本身份验证一起使用。