Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
提交反馈
为 GitLab 提交贡献
登录
切换导航
T
TrainSys
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
苏州培训方案
TrainSys
提交
7e8ed31b
提交
7e8ed31b
编写于
9月 18, 2025
作者:
Cano1997
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update: 页面重定向添加白名单校验
上级
9e57e46c
变更
7
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
63 行增加
和
20 行删除
+63
-20
environment.config
app_Web/environment.config
+2
-1
cas-login.js
app_Web/public/assets/js/cas-login.js
+25
-1
bapproxy.html
app_Web/public/bapproxy.html
+27
-13
unauthorized-handler.ts
...eb/src/guard/unauthorized-handler/unauthorized-handler.ts
+3
-2
index.ts
app_Web/src/router/index.ts
+2
-1
open-view-util.ts
app_Web/src/util/open-view-util/open-view-util.ts
+2
-1
todo-redirect.tsx
app_Web/src/views/todo-redirect/todo-redirect.tsx
+2
-1
未找到文件。
app_Web/environment.config
浏览文件 @
7e8ed31b
...
...
@@ -15,3 +15,4 @@ enableGridRowBreak:ENABLEGRIDROWBREAK
publicKey
:
PUBLICKEY
enableRSA
:
ENABLERSA
customParams
:
CUSTOMPARAMS
redirectWhiteList
:
REDIRECTWHITELIST
\ No newline at end of file
app_Web/public/assets/js/cas-login.js
浏览文件 @
7e8ed31b
...
...
@@ -53,6 +53,26 @@ function setCookie(name, value, day, isDomain, path) {
function
clearCookie
(
cookieName
,
isDomain
)
{
this
.
setCookie
(
cookieName
,
''
,
-
1
,
isDomain
);
}
function
isAllowed
(
url
)
{
if
(
!
url
)
return
false
;
const
{
protocol
,
hostname
,
origin
}
=
new
URL
(
url
,
window
.
location
.
origin
);
if
(
!
[
'blob:'
,
'https:'
,
'http:'
].
includes
(
protocol
))
return
false
;
if
(
window
.
location
.
origin
===
origin
)
{
return
true
;
}
const
allowList
=
ibiz
.
env
.
redirectWhiteList
.
split
(
','
);
return
allowList
.
some
(
rule
=>
{
if
(
typeof
rule
===
'string'
)
{
if
(
rule
.
includes
(
'*'
))
{
const
reg
=
new
RegExp
(
`^
${
rule
.
replace
(
/
\*
/g
,
'[^/]+'
)}
$`
);
return
reg
.
test
(
hostname
);
}
return
rule
===
`
${
protocol
}
//
${
hostname
}
`
;
}
return
rule
.
test
(
url
);
});
};
window
.
onload
=
function
()
{
var
infoEl
=
document
.
getElementById
(
'redirect-info'
);
var
errInfoEl
=
document
.
getElementById
(
'redirect-error'
);
...
...
@@ -78,7 +98,11 @@ window.onload = function () {
const
expiredDate
=
new
Date
().
getTime
()
+
(
expirein
||
7199
)
*
1000
;
setCookie
(
'access_token_expires'
,
`
${
expiredDate
}
`
,
0
,
true
);
if
(
ru
&&
isAllowed
(
ru
))
{
window
.
location
.
href
=
ru
;
}
else
{
console
.
error
(
`重定向路径
${
ru
}
不在白名单中,请确认是否正确!`
);
}
};
var
redirectInfoActionEl
=
document
.
getElementById
(
'redirect-info-action'
);
redirectInfoActionEl
.
onclick
=
function
()
{
...
...
app_Web/public/bapproxy.html
浏览文件 @
7e8ed31b
...
...
@@ -20,6 +20,27 @@
</div>
</body>
<script>
function
isAllowed
(
url
)
{
if
(
!
url
)
return
false
;
const
{
protocol
,
hostname
,
origin
}
=
new
URL
(
url
,
window
.
location
.
origin
);
if
(
!
[
'blob:'
,
'https:'
,
'http:'
].
includes
(
protocol
))
return
false
;
if
(
window
.
location
.
origin
===
origin
)
{
return
true
;
}
const
allowList
=
ibiz
.
env
.
redirectWhiteList
.
split
(
','
);
return
allowList
.
some
(
rule
=>
{
if
(
typeof
rule
===
'string'
)
{
if
(
rule
.
includes
(
'*'
))
{
const
reg
=
new
RegExp
(
`^
${
rule
.
replace
(
/
\*
/g
,
'[^/]+'
)}
$`
);
return
reg
.
test
(
hostname
);
}
return
rule
===
`
${
protocol
}
//
${
hostname
}
`
;
}
return
rule
.
test
(
url
);
});
};
function
created
()
{
try
...
...
@@ -45,12 +66,14 @@
}
if
(
response
.
appdata
.
user
)
{
setCookie
(
'ibzuaa-user'
,
JSON
.
stringify
(
response
.
appdata
.
user
),
7
,
true
);
// 设置cookie,保存账号密码7天
setCookie
(
'loginname'
,
response
.
appdata
.
user
.
loginname
,
7
,
true
);
}
if
(
bapru
&&
isAllowed
(
bapru
))
{
window
.
location
.
href
=
bapru
;
}
else
{
console
.
error
(
`重定向路径
${
bapru
}
不在白名单中,请确认是否正确!`
);
}
}
else
{
...
...
@@ -69,17 +92,8 @@
}
}
/**
* 获取指定的URL参数值
* URL:http://www.xxx.com/index?name=123
* 参数:param URL参数
* 调用方法:getParam("name")
* 返回值:123
* alert(getParam('date'));
*/
function
getParam
(
name
)
{
let
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
,
"i"
);
//search,查询?后面的参数,并匹配正则
let
r
=
location
.
search
.
substr
(
1
).
match
(
reg
);
if
(
r
!=
null
)
return
decodeURI
(
decodeURI
(
r
[
2
]));
}
...
...
@@ -87,7 +101,7 @@
function
showinfo
(
arg
)
{
var
ele
=
document
.
getElementById
(
"info"
);
ele
.
inner
HTML
=
ele
.
innerHTML
+
"<br>"
+
arg
;
ele
.
inner
Text
=
`
${
ele
.
innerText
}
\n
${
arg
}
`
;
}
...
...
app_Web/src/guard/unauthorized-handler/unauthorized-handler.ts
浏览文件 @
7e8ed31b
import
qs
from
'qs'
;
import
{
safeRedirect
}
from
'@ibiz-template/runtime'
;
import
{
LoginMode
,
RuntimeError
,
UrlHelper
}
from
'@ibiz-template/core'
;
import
router
from
'@/router'
;
...
...
@@ -49,7 +50,7 @@ export class UnauthorizedHandler {
);
// 跳转cas登录地址
window
.
location
.
href
=
targetUrl
;
safeRedirect
(
targetUrl
,
{
type
:
'href'
})
;
}
/**
...
...
@@ -63,7 +64,7 @@ export class UnauthorizedHandler {
*/
protected
static
async
normalLogin
():
Promise
<
void
>
{
if
(
ibiz
.
env
.
noAuthRedirectUrl
)
{
window
.
open
(
ibiz
.
env
.
noAuthRedirectUrl
,
'_self'
);
safeRedirect
(
ibiz
.
env
.
noAuthRedirectUrl
,
{
type
:
'_self'
}
);
return
;
}
// 禁止跳转登录视图时不处理
...
...
app_Web/src/router/index.ts
浏览文件 @
7e8ed31b
import
Router
from
'vue-router'
;
import
{
Environment
}
from
'@ibiz-template/core'
;
import
{
safeRedirect
}
from
'@ibiz-template/runtime'
;
import
{
AuthGuard
}
from
'../guard'
;
import
RouterShell
from
'@/components/router-shell/router-shell'
;
import
appRedirectView
from
'@/views/app-redirect-view/app-redirect-view'
;
...
...
@@ -36,7 +37,7 @@ const router = new Router({
name
:
'loginView'
,
beforeEnter
:
async
(
_to
,
_from
,
next
)
=>
{
if
(
ibiz
.
env
.
noAuthRedirectUrl
)
{
window
.
open
(
ibiz
.
env
.
noAuthRedirectUrl
,
'_self'
);
safeRedirect
(
ibiz
.
env
.
noAuthRedirectUrl
,
{
type
:
'_self'
}
);
}
if
(
ibiz
.
env
.
disabledLogin
)
{
next
(
false
);
...
...
app_Web/src/util/open-view-util/open-view-util.ts
浏览文件 @
7e8ed31b
...
...
@@ -3,6 +3,7 @@ import {
IModal
,
IModalData
,
IOpenViewUtil
,
safeRedirect
,
ViewMode
,
}
from
'@ibiz-template/runtime'
;
import
{
generateRoutePath
}
from
'@ibiz-template/vue-util'
;
...
...
@@ -176,7 +177,7 @@ export class OpenViewUtil implements IOpenViewUtil {
url
=
`
${
UrlHelper
.
routeBase
}${
path
}
`
;
}
if
(
srfopenmode
===
'open'
)
{
window
.
open
(
url
,
srfopentarget
);
safeRedirect
(
url
,
{
type
:
srfopentarget
}
);
}
// 其他方式待补充
}
...
...
app_Web/src/views/todo-redirect/todo-redirect.tsx
浏览文件 @
7e8ed31b
import
{
safeRedirect
}
from
'@ibiz-template/runtime'
;
import
{
useRouter
}
from
'@ibiz-template/vue-util'
;
import
qs
from
'qs'
;
import
{
defineComponent
,
getCurrentInstance
}
from
'vue'
;
...
...
@@ -35,7 +36,7 @@ export default defineComponent({
let
url
:
string
=
res
.
data
.
linkurl
;
// apptype存在,带ip、端口等完整数据
if
(
apptype
)
{
window
.
location
.
href
=
url
;
safeRedirect
(
url
,
{
type
:
'href'
})
;
}
else
{
if
(
url
.
indexOf
(
'/'
)
!==
0
)
{
url
=
`/
${
url
}
`
;
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录