This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.3.1
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.1 by this push:
new 75894fbe6 fix bug get request host ip always 127.0.0.1 (#4031)
75894fbe6 is described below
commit 75894fbe6641793b4386710862f0e907845a7713
Author: Casion <[email protected]>
AuthorDate: Fri Dec 23 10:01:20 2022 +0800
fix bug get request host ip always 127.0.0.1 (#4031)
* fix basedata maanger bug
* fix bug:get request host ip always 127.0.0.1
---
.../linkis/gateway/http/GatewayHttpRequest.scala | 4 +++
.../security/token/TokenAuthentication.scala | 4 ++-
.../http/SpringCloudGatewayHttpRequest.scala | 36 +++++++++++++++++++++-
linkis-web/src/apps/linkis/i18n/common/en.json | 3 +-
linkis-web/src/apps/linkis/i18n/common/zh.json | 3 +-
.../linkis/module/EnginePluginManagement/index.vue | 9 +++---
.../src/apps/linkis/module/datasourceEnv/index.vue | 2 +-
.../module/datasourceTypeKey/EditForm/index.vue | 11 +------
.../src/apps/linkis/module/errorCode/index.vue | 2 +-
.../apps/linkis/module/gatewayAuthToken/index.vue | 2 +-
.../module/rmExternalResourceProvider/index.vue | 3 +-
.../src/apps/linkis/module/udfManager/index.vue | 2 +-
12 files changed, 56 insertions(+), 25 deletions(-)
diff --git
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/http/GatewayHttpRequest.scala
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/http/GatewayHttpRequest.scala
index a78cfca73..6af8bb3c8 100644
---
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/http/GatewayHttpRequest.scala
+++
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/http/GatewayHttpRequest.scala
@@ -19,6 +19,8 @@ package org.apache.linkis.gateway.http
import org.apache.linkis.server.JMap
+import org.springframework.http.server.reactive.AbstractServerHttpRequest
+
import javax.servlet.http.Cookie
import java.net.{InetSocketAddress, URI}
@@ -41,6 +43,8 @@ trait GatewayHttpRequest {
def getRemoteAddress: InetSocketAddress
+ def getRequestRealIpAddr(): String
+
def getMethod: String
def getRequestBody: String
diff --git
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/security/token/TokenAuthentication.scala
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/security/token/TokenAuthentication.scala
index e455f8bc4..3b5815ca7 100644
---
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/security/token/TokenAuthentication.scala
+++
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-gateway-core/src/main/scala/org/apache/linkis/gateway/security/token/TokenAuthentication.scala
@@ -51,7 +51,9 @@ object TokenAuthentication extends Logging {
}
var token = gatewayContext.getRequest.getHeaders.get(TOKEN_KEY)(0)
var tokenUser = gatewayContext.getRequest.getHeaders.get(TOKEN_USER_KEY)(0)
- var host =
gatewayContext.getRequest.getRemoteAddress.getAddress.getHostAddress
+
+ var host = gatewayContext.getRequest.getRequestRealIpAddr()
+
if (StringUtils.isBlank(token) || StringUtils.isBlank(tokenUser)) {
token = gatewayContext.getRequest.getCookies.get(TOKEN_KEY)(0).getValue
tokenUser =
gatewayContext.getRequest.getCookies.get(TOKEN_USER_KEY)(0).getValue
diff --git
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/http/SpringCloudGatewayHttpRequest.scala
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/http/SpringCloudGatewayHttpRequest.scala
index 3d93d02ea..f438277c7 100644
---
a/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/http/SpringCloudGatewayHttpRequest.scala
+++
b/linkis-spring-cloud-services/linkis-service-gateway/linkis-spring-cloud-gateway/src/main/scala/org/apache/linkis/gateway/springcloud/http/SpringCloudGatewayHttpRequest.scala
@@ -24,12 +24,15 @@ import org.apache.commons.lang3.StringUtils
import org.springframework.http.server.reactive.AbstractServerHttpRequest
-import javax.servlet.http.Cookie
+import javax.servlet.http.{Cookie, HttpServletRequest}
import java.net.{InetSocketAddress, URI}
+import java.util
import scala.collection.JavaConverters._
+import com.google.common.net.InetAddresses
+
class SpringCloudGatewayHttpRequest(request: AbstractServerHttpRequest)
extends GatewayHttpRequest {
private val headers = {
@@ -99,6 +102,37 @@ class SpringCloudGatewayHttpRequest(request:
AbstractServerHttpRequest) extends
override def getRemoteAddress: InetSocketAddress = request.getRemoteAddress
+ override def getRequestRealIpAddr(): String = {
+ val addrList = new util.ArrayList[String]()
+ addrList.addAll(
+ Option(request.getHeaders.get("x-forwarded-for")).getOrElse(new
util.ArrayList[String]())
+ )
+ addrList.addAll(
+ Option(request.getHeaders.get("Proxy-Client-IP")).getOrElse(new
util.ArrayList[String]())
+ )
+ addrList.addAll(
+ Option(request.getHeaders.get("WL-Proxy-Client-IP")).getOrElse(new
util.ArrayList[String]())
+ )
+ addrList.addAll(
+ Option(request.getHeaders.get("HTTP_CLIENT_IP")).getOrElse(new
util.ArrayList[String]())
+ )
+ addrList.addAll(
+ Option(request.getHeaders.get("HTTP_X_FORWARDED_FOR")).getOrElse(new
util.ArrayList[String]())
+ )
+
+ val afterProxyIp = addrList
+ .find(ip => {
+ StringUtils.isNotEmpty(ip) && InetAddresses.isInetAddress(ip)
+ })
+ .getOrElse("")
+
+ if (StringUtils.isNotEmpty(afterProxyIp)) {
+ afterProxyIp
+ } else {
+ request.getRemoteAddress.getAddress.getHostAddress
+ }
+ }
+
override def getMethod: String = request.getMethodValue
def setRequestBody(requestBody: String): Unit = {
diff --git a/linkis-web/src/apps/linkis/i18n/common/en.json
b/linkis-web/src/apps/linkis/i18n/common/en.json
index 1eb54b0ab..42dadd62a 100644
--- a/linkis-web/src/apps/linkis/i18n/common/en.json
+++ b/linkis-web/src/apps/linkis/i18n/common/en.json
@@ -415,8 +415,7 @@
"cancel": "Cancel",
"modalTitle": "Info",
"modalFormat": "Confirm deleting the {0} record?",
- "modalDelete1": "Confirm that the record [{username}] should be
deleted?",
- "modalDelete": "Confirm that the record [{envName}] should be
deleted?",
+ "modalDelete": "Confirm that the record [{name}] should be deleted?",
"modalDeleteSuccess": "Successfully delete",
"modalDeleteFail": "Fail to delete",
"modalAddSuccess": "Successfully added",
diff --git a/linkis-web/src/apps/linkis/i18n/common/zh.json
b/linkis-web/src/apps/linkis/i18n/common/zh.json
index 6a4930d6b..e0022c46d 100644
--- a/linkis-web/src/apps/linkis/i18n/common/zh.json
+++ b/linkis-web/src/apps/linkis/i18n/common/zh.json
@@ -417,8 +417,7 @@
"cancel": "取消",
"modalTitle": "提示信息",
"modalFormat": "确定删除 {0} 这条记录?",
- "modalDelete1": "确认是否删除[{username}]该记录?",
- "modalDelete": "确认是否删除[{envName}]该记录?",
+ "modalDelete": "确认是否删除[{name}]该记录?",
"modalDeleteSuccess": "删除成功",
"modalDeleteFail": "删除失败",
"modalAddSuccess": "添加成功",
diff --git a/linkis-web/src/apps/linkis/module/EnginePluginManagement/index.vue
b/linkis-web/src/apps/linkis/module/EnginePluginManagement/index.vue
index 7fd0843f9..bdeeb93c2 100644
--- a/linkis-web/src/apps/linkis/module/EnginePluginManagement/index.vue
+++ b/linkis-web/src/apps/linkis/module/EnginePluginManagement/index.vue
@@ -118,10 +118,10 @@
</div>
</Col>
<Col span="12">
- <Button type="primary" :style="{width: '60px', marginRight: '5px',
padding: '5px'}" @click="resetSearch">{{
- $t('message.linkis.EnginePluginManagement.Reset')}}</Button>
<Button type="primary" class="button" :style="{width: '60px',
marginRight: '5px', marginLeft: '5px', padding: '5px'}"
@click="initECMList()">{{
$t('message.linkis.search') }}</Button>
+ <Button type="primary" :style="{width: '60px', marginRight: '5px',
padding: '5px'}" @click="resetSearch">{{
+ $t('message.linkis.EnginePluginManagement.Reset')}}</Button>
<!-- <Button type="primary" :style="{width: '120px', marginRight:
'5px', padding: '5px'}" @click="createOrUpdate(1)">{{
$t('message.linkis.EnginePluginManagement.update')}}</Button>
<Button type="error" :style="{width: '120px', marginRight: '5px',
padding: '5px'}" @click="deleteBML">{{
@@ -176,6 +176,7 @@
</template>
<script>
import api from '@/common/service/api';
+import moment from 'moment';
export default {
data() {
return {
@@ -232,7 +233,7 @@ export default {
tooltip: true,
align: 'center',
render: (h, params) => {
- let time = new
Date(parseInt(params.row.lastModified)).toLocaleString().replace(/:\d(1,2)$/, '
')
+ let time = moment(new
Date(params.row.lastModified)).format('YYYY-MM-DD HH:mm:ss')
return h('span', time);
}
},
@@ -447,7 +448,7 @@ export default {
this.version = row.version;
this.updWay = 'table';
this.createOrUpdate(1);
- }
+ }
},
async openVersionList(row) {
this.currentEnginpluginData = row
diff --git a/linkis-web/src/apps/linkis/module/datasourceEnv/index.vue
b/linkis-web/src/apps/linkis/module/datasourceEnv/index.vue
index d19a15780..4fb9ddf12 100644
--- a/linkis-web/src/apps/linkis/module/datasourceEnv/index.vue
+++ b/linkis-web/src/apps/linkis/module/datasourceEnv/index.vue
@@ -256,7 +256,7 @@ export default {
onTableDelete(row){
this.$Modal.confirm({
title: this.$t('message.linkis.basedataManagement.modal.modalTitle'),
- content:
this.$t('message.linkis.basedataManagement.modal.modalDelete', {envName:
row.envName}),
+ content:
this.$t('message.linkis.basedataManagement.modal.modalDelete', {name:
row.envName}),
onOk: ()=>{
let params = {
id: row.id
diff --git
a/linkis-web/src/apps/linkis/module/datasourceTypeKey/EditForm/index.vue
b/linkis-web/src/apps/linkis/module/datasourceTypeKey/EditForm/index.vue
index f1c240548..56f553e22 100644
--- a/linkis-web/src/apps/linkis/module/datasourceTypeKey/EditForm/index.vue
+++ b/linkis-web/src/apps/linkis/module/datasourceTypeKey/EditForm/index.vue
@@ -211,16 +211,7 @@ export default {
placeholder: "",
trueValue: 1,
falseValue: 0,
- },
- validate: [
- {
- required: false,
- message: `${this.$t(
- 'message.linkis.datasource.pleaseInput'
- )}
`+this.$t('message.linkis.basedataManagement.datasourceTypeKey.require'),
- trigger: 'blur',
- },
- ],
+ }
},
{
type: 'input',
diff --git a/linkis-web/src/apps/linkis/module/errorCode/index.vue
b/linkis-web/src/apps/linkis/module/errorCode/index.vue
index 3d3cb2449..b3cc038ae 100644
--- a/linkis-web/src/apps/linkis/module/errorCode/index.vue
+++ b/linkis-web/src/apps/linkis/module/errorCode/index.vue
@@ -188,7 +188,7 @@ export default {
this.$Modal.confirm({
title: this.$t('message.linkis.basedataManagement.modal.modalTitle'),
- content:
this.$t('message.linkis.basedataManagement.modal.modalDelete'),
+ content:
this.$t('message.linkis.basedataManagement.modal.modalDelete', {name:
row.errorCode}),
onOk: ()=>{
let params = {
id: row.id
diff --git a/linkis-web/src/apps/linkis/module/gatewayAuthToken/index.vue
b/linkis-web/src/apps/linkis/module/gatewayAuthToken/index.vue
index 43304f3ce..171b7f101 100644
--- a/linkis-web/src/apps/linkis/module/gatewayAuthToken/index.vue
+++ b/linkis-web/src/apps/linkis/module/gatewayAuthToken/index.vue
@@ -224,7 +224,7 @@ export default {
this.$Modal.confirm({
title: this.$t('message.linkis.basedataManagement.modal.modalTitle'),
- content:
this.$t('message.linkis.basedataManagement.modal.modalDelete'),
+ content:
this.$t('message.linkis.basedataManagement.modal.modalDelete', {name:
row.tokenName}),
onOk: ()=>{
let params = {
id: row.id
diff --git
a/linkis-web/src/apps/linkis/module/rmExternalResourceProvider/index.vue
b/linkis-web/src/apps/linkis/module/rmExternalResourceProvider/index.vue
index 7f0999340..feff388dd 100644
--- a/linkis-web/src/apps/linkis/module/rmExternalResourceProvider/index.vue
+++ b/linkis-web/src/apps/linkis/module/rmExternalResourceProvider/index.vue
@@ -195,7 +195,8 @@ export default {
this.$Modal.confirm({
title: this.$t('message.linkis.basedataManagement.modal.modalTitle'),
- content:
this.$t('message.linkis.basedataManagement.modal.modalDelete'),
+ content: this.$t('message.linkis.basedataManagement.modal.modalDelete',
{name: row.name}),
+
onOk: ()=>{
let params = {
id: row.id
diff --git a/linkis-web/src/apps/linkis/module/udfManager/index.vue
b/linkis-web/src/apps/linkis/module/udfManager/index.vue
index 64c957839..289e03390 100644
--- a/linkis-web/src/apps/linkis/module/udfManager/index.vue
+++ b/linkis-web/src/apps/linkis/module/udfManager/index.vue
@@ -177,7 +177,7 @@ export default {
this.$Modal.confirm({
title: this.$t('message.linkis.basedataManagement.modal.modalTitle'),
- content:
this.$t('message.linkis.basedataManagement.modal.modalDelete1', {username:
row.userName}),
+ content:
this.$t('message.linkis.basedataManagement.modal.modalDelete', {name:
row.userName}),
onOk: ()=>{
let params = {
id: row.id
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]