WeBankFinTech / DataSphereStudio

DataSphereStudio is a one stop data application development& management portal, covering scenarios including data exchange, desensitization/cleansing, analysis/mining, quality measurement, visualization, and task scheduling.
https://github.com/WeBankFinTech/DataSphereStudio-Doc
Apache License 2.0
3.09k stars 1k forks source link

in workflow add qualitis node after,click this node has error: Failed to redirect to other page #283

Closed seawenc closed 3 years ago

seawenc commented 3 years ago

links version:0.9.0 qualitis version: 0.8.0

qualitis error log:

Failed to redirect to other page, caused by: errCode: 10905 ,desc: URL /api/rest_j/v1/user/userInfo request failed! ResponseBody is {"method":"/api/rest_j/v1/user/userInfo","status":1,"message":"errCode: 11002 ,desc: You are not logged in, please login first(您尚未登录,请先登录!) ,ip: 10.42.135.20 ,port: 9001 ,serviceKind: DataWorkCloud-Gateway","data":{}}. ,ip: null ,port: 0 ,serviceKind: null
com.webank.wedatasphere.linkis.httpclient.exception.HttpClientResultException: errCode: 10905 ,desc: URL /api/rest_j/v1/user/userInfo request failed! ResponseBody is {"method":"/api/rest_j/v1/user/userInfo","status":1,"message":"errCode: 11002 ,desc: You are not logged in, please login first(您尚未登录,请先登录!) ,ip: 10.42.135.20 ,port: 9001 ,serviceKind: DataWorkCloud-Gateway","data":{}}. ,ip: null ,port: 0 ,serviceKind: null
seawenc commented 3 years ago

request header:

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: en,zh;q=0.9
Connection: keep-alive
Cookie: JSESSIONID=node0dnj5mctdkav2ampo9n21qkxd1.node0
Host: qualitis.b.x
Referer: http://dss.b.x/
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36

request param:

redirect: http://qualitis.b.x:80/#/addGroupTechniqueRule?tableType=1&id=1&ruleGroupId=undefined&nodeId=9256a408-8c3e-4e78-8804-a740f0331681
dssurl: http://dss.b.x
cookies: bdp-user-ticket-id=3cSULn63z6ChSy5x2BK4wYP3d14cjuVE
seawenc commented 3 years ago

By catching net packets, i found qualitis request gateway miss cookies param

modify AppJointAuthImpl.scala to fix it:

override def getRedirectMsg(request: HttpServletRequest): RedirectMsg = {
    val dssUrl = request.getParameter(AppJointAuthImpl.DSS_URL_KEY)
    val dwsHttpClient = getDWSClient(dssUrl)
    val userInfoAction = new UserInfoAction
    val cookies = request.getParameter(AppJointAuthImpl.COOKIES_KEY)

    // 由于向dss请求少了对cookies,导致网关报没登录,此bug最根源应该是在AbstractHttpClient.executeHttpAction中,但此类太公共,怕改出问题,因此只在此处改
    var strcookies = userInfoAction.getHeaders.get("Cookie")
    if(strcookies==null){
      strcookies=""
    }
    cookies.split(";").foreach { cookie =>
      val index = cookie.indexOf("=")
      val key = cookie.substring(0, index).trim
      val value = cookie.substring(index + 1).trim
      userInfoAction.addCookie(new BasicClientCookie(key, value))
      strcookies= s"$key=$value;"+strcookies;
    }
    userInfoAction.addHeader("Cookie",strcookies)

    val redirectMsg = new RedirectMsgImpl
    redirectMsg.setRedirectUrl(request.getParameter(AppJointAuthImpl.REDIRECT_KEY))
    dwsHttpClient.execute(userInfoAction) match {
      case userInfoResult: UserInfoResult =>
        redirectMsg.setUser(userInfoResult.getUserName)
    }
    redirectMsg
  }