OkHttp是否在重定向上发送授权和其他可能敏感的标头?

问题描述 投票:3回答:1

我通过Apache NiFi传递使用OkHttp。我正在尝试确定如何在重定向上处理授权和其他敏感标头。 NiFi的InvokeHTTP处理器与OkHttp在重定向方面唯一的交互是here,它在那里读取处理器属性并在OkHttpClientBuilder对象上设置选项:

// Set whether to follow redirects
okHttpClientBuilder.followRedirects(context.getProperty(PROP_FOLLOW_REDIRECTS).asBoolean());

快速搜索OkHttp的来源,我似乎无法确定重定向的处理位置,以便验证Authorization是否会被后续请求剥离,正如我所料。 cURL只是recently adopted出于安全原因这种行为。

authorization okhttp apache-nifi
1个回答
4
投票

它发生在RetryAndFollowUpInterceptor

// When redirecting across hosts, drop all authentication headers. This
// is potentially annoying to the application layer since they have no
// way to retain them.
if (!sameConnection(userResponse, url)) {
  requestBuilder.removeHeader("Authorization");
}
© www.soinside.com 2019 - 2024. All rights reserved.