[fix]Stream load 307 temporary redirection authentication information is lost (#9363)

This commit is contained in:
jiafeng.zhang
2022-05-07 19:22:45 +08:00
committed by GitHub
parent 816aaa7fd1
commit 9bae0a61ed

View File

@ -75,11 +75,21 @@ public class RestBaseController extends BaseController {
String userInfo = null;
if (!Strings.isNullOrEmpty(request.getHeader("Authorization"))) {
ActionAuthorizationInfo authInfo = getAuthorizationInfo(request);
// Fix username@cluster:passwod is modified to cluster: username:passwod causes authentication failure
// @see https://github.com/apache/incubator-doris/issues/8100
//username@cluster:password
//This is a Doris-specific parsing format in the parseAuthInfo of BaseController.
//This is to go directly to BE, but in fact,
//BE still needs to take this authentication information and send RPC
// to FE to parse the authentication information,
//so in the end, the format of this authentication information is parsed on the FE side.
//The normal format for fullUserName is actually default_cluster:username
//I don't know why the format username@default_cluster is used in parseAuthInfo.
//It is estimated that it is compatible with the standard format of username:password.
//So here we feel that we can assemble it completely by hand.
String clusterName = ConnectContext.get() == null ?
SystemInfoService.DEFAULT_CLUSTER : ConnectContext.get().getClusterName();
userInfo = ClusterNamespace.getNameFromFullName(authInfo.fullUserName) +
"@" + ClusterNamespace.getClusterNameFromFullName(authInfo.fullUserName) +
":" + authInfo.password;
"@" + clusterName +
":" + authInfo.password;
}
try {
urlObj = new URI(urlStr);