IP白名单修改
This commit is contained in:
parent
9fbce167b3
commit
52367cb030
@ -124,7 +124,12 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="4">
|
<el-col :span="4">
|
||||||
<el-card class="stats-card">
|
<el-card class="stats-card">
|
||||||
<el-statistic title="风险评级" :value="stats.riskLevel" />
|
<div class="risk-level-stat">
|
||||||
|
<div class="risk-level-title">风险评级</div>
|
||||||
|
<div class="risk-level-value" :style="{ color: getRiskLevelColor(stats.riskLevel) }">
|
||||||
|
{{ stats.riskLevel || 'A' }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -1490,6 +1495,12 @@ function getRiskLevelText(level) {
|
|||||||
return levelMap[level] || level;
|
return levelMap[level] || level;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 获取风险评级颜色 */
|
||||||
|
function getRiskLevelColor(level) {
|
||||||
|
const colorMap = { 'A': '#67C23A', 'B': '#E6A23C', 'C': '#F56C6C', 'D': '#909399' };
|
||||||
|
return colorMap[level] || '#303133';
|
||||||
|
}
|
||||||
|
|
||||||
/** 获取风险评分颜色 */
|
/** 获取风险评分颜色 */
|
||||||
function getRiskScoreColor(score) {
|
function getRiskScoreColor(score) {
|
||||||
if (score >= 80) return '#67C23A'; // 绿色 - 低风险
|
if (score >= 80) return '#67C23A'; // 绿色 - 低风险
|
||||||
@ -1645,6 +1656,23 @@ onUnmounted(() => {
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.risk-level-stat {
|
||||||
|
text-align: center;
|
||||||
|
padding: 4px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.risk-level-title {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #909399;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.risk-level-value {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: bold;
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
|
||||||
.mb8 {
|
.mb8 {
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -76,7 +76,7 @@ spring:
|
|||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
basename: i18n/messages
|
basename: i18n/messages
|
||||||
profiles:
|
profiles:
|
||||||
active: druid
|
active: druid,api-security
|
||||||
autoconfigure:
|
autoconfigure:
|
||||||
exclude:
|
exclude:
|
||||||
- org.redisson.spring.starter.RedissonAutoConfiguration
|
- org.redisson.spring.starter.RedissonAutoConfiguration
|
||||||
|
|||||||
@ -29,7 +29,7 @@ public class IpWhitelistInterceptor implements HandlerInterceptor {
|
|||||||
private static final Logger logger = LoggerFactory.getLogger(IpWhitelistInterceptor.class);
|
private static final Logger logger = LoggerFactory.getLogger(IpWhitelistInterceptor.class);
|
||||||
|
|
||||||
@Value("${api.ipWhitelist.enabled:true}")
|
@Value("${api.ipWhitelist.enabled:true}")
|
||||||
private Boolean ipWhitelistEnabled;
|
private boolean ipWhitelistEnabled;
|
||||||
|
|
||||||
@Value("${api.ipWhitelist.allowedIps:127.0.0.1,::1}")
|
@Value("${api.ipWhitelist.allowedIps:127.0.0.1,::1}")
|
||||||
private String allowedIpsConfig;
|
private String allowedIpsConfig;
|
||||||
@ -46,10 +46,7 @@ public class IpWhitelistInterceptor implements HandlerInterceptor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||||
// 安全优先:如果配置未正确加载,默认启用IP白名单验证
|
if (!ipWhitelistEnabled) {
|
||||||
boolean isIpWhitelistEnabled = (ipWhitelistEnabled != null) ? ipWhitelistEnabled : true;
|
|
||||||
|
|
||||||
if (!isIpWhitelistEnabled) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user