我通过 Apache NiFi 传递使用 OkHttp。我正在尝试确定如何在重定向上处理授权和其他敏感标头。 NiFi 的 InvokeHTTP 处理器与 OkHttp 在重定向方面的唯一交互是here https://github.com/apache/nifi/blob/ea9b0db2f620526c8dd0db595cf8b44c3ef835be/nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/InvokeHTTP.java#L624,它读取处理器属性并在 OkHttpClient Builder 对象上设置选项:
// Set whether to follow redirects
okHttpClientBuilder.followRedirects(context.getProperty(PROP_FOLLOW_REDIRECTS).asBoolean());
Quickly搜索 OkHttp 的源代码,我似乎无法确定处理重定向的位置以验证Authorization
正如我所期望的,从后续请求中删除。卷曲只是最近采用的 https://stackoverflow.com/a/50005430/204052出于安全原因的这种行为。
它发生在RetryAndFollowUp拦截器 https://github.com/square/okhttp/blob/master/okhttp/src/main/java/okhttp3/internal/http/RetryAndFollowUpInterceptor.kt#L301.
// 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");
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)