Harden exposed security-sensitive endpoints
This commit is contained in:
parent
adac18ba86
commit
6750e85ad4
4
.gitignore
vendored
4
.gitignore
vendored
@ -52,6 +52,10 @@ migration-backup-*/
|
|||||||
migration-backup-complete/
|
migration-backup-complete/
|
||||||
*.dump
|
*.dump
|
||||||
*.sql
|
*.sql
|
||||||
|
*.zip
|
||||||
|
*.tar
|
||||||
|
*.tar.gz
|
||||||
|
*.tgz
|
||||||
migration-*.log
|
migration-*.log
|
||||||
migration-*.txt
|
migration-*.txt
|
||||||
|
|
||||||
|
|||||||
@ -22,10 +22,10 @@ function verifyAuthToken(request: Request): boolean {
|
|||||||
// 与环境变量中的密钥比对
|
// 与环境变量中的密钥比对
|
||||||
const cronSecret = process.env.CRON_SECRET;
|
const cronSecret = process.env.CRON_SECRET;
|
||||||
|
|
||||||
// 如果未配置 CRON_SECRET,则允许所有请求(开发环境)
|
// 安全默认拒绝:定时任务接口被 middleware 公开放行,生产环境不能在缺少密钥时放开。
|
||||||
if (!cronSecret) {
|
if (!cronSecret) {
|
||||||
console.warn("[VideoArchiveAPI] ⚠️ CRON_SECRET 未配置,允许所有请求");
|
console.error("[VideoArchiveAPI] CRON_SECRET 未配置,拒绝执行定时任务接口");
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return token === cronSecret;
|
return token === cronSecret;
|
||||||
@ -109,4 +109,3 @@ export async function GET(request: Request) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -10,10 +10,8 @@ function verifyAuthToken(request: Request): boolean {
|
|||||||
const cronSecret = process.env.CRON_SECRET;
|
const cronSecret = process.env.CRON_SECRET;
|
||||||
|
|
||||||
if (!cronSecret) {
|
if (!cronSecret) {
|
||||||
console.warn(
|
console.error("[DingTalkNotificationJob] CRON_SECRET 未配置,拒绝执行定时任务接口");
|
||||||
"[DingTalkNotificationJob] CRON_SECRET 未配置,当前允许所有请求",
|
return false;
|
||||||
);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return token === cronSecret;
|
return token === cronSecret;
|
||||||
|
|||||||
@ -10,8 +10,8 @@ function verifyAuthToken(request: Request): boolean {
|
|||||||
const cronSecret = process.env.CRON_SECRET;
|
const cronSecret = process.env.CRON_SECRET;
|
||||||
|
|
||||||
if (!cronSecret) {
|
if (!cronSecret) {
|
||||||
console.warn("[OSSMigrationAPI] ⚠️ CRON_SECRET 未配置,允许所有请求");
|
console.error("[OSSMigrationAPI] CRON_SECRET 未配置,拒绝执行定时任务接口");
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return token === cronSecret;
|
return token === cronSecret;
|
||||||
@ -68,4 +68,3 @@ export async function GET(request: Request) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -922,6 +922,14 @@ export async function GET(request: NextRequest) {
|
|||||||
return getAgentWorkflowAdminSettingsResponse();
|
return getAgentWorkflowAdminSettingsResponse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!session?.user) {
|
||||||
|
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!isAdmin && !canManageAgentWorkflow) {
|
||||||
|
return NextResponse.json({ error: "Forbidden" }, { status: 403 });
|
||||||
|
}
|
||||||
|
|
||||||
const [
|
const [
|
||||||
settings,
|
settings,
|
||||||
notificationSetting,
|
notificationSetting,
|
||||||
|
|||||||
@ -9,7 +9,7 @@ set -e
|
|||||||
SERVER="156.225.27.52"
|
SERVER="156.225.27.52"
|
||||||
PORT="5204"
|
PORT="5204"
|
||||||
USER="root"
|
USER="root"
|
||||||
PASSWORD="Jsjj@8888"
|
PASSWORD="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
REMOTE_DIR="/var/www/ai-chatbot"
|
REMOTE_DIR="/var/www/ai-chatbot"
|
||||||
|
|
||||||
# 颜色输出
|
# 颜色输出
|
||||||
|
|||||||
@ -4,7 +4,7 @@ set timeout -1
|
|||||||
set host "156.225.27.52"
|
set host "156.225.27.52"
|
||||||
set port "5204"
|
set port "5204"
|
||||||
set user "root"
|
set user "root"
|
||||||
set password "Jsjj@8888"
|
set password $env(DEPLOY_SSH_PASSWORD)
|
||||||
set local_script "remote_deploy_dreamomni2.sh"
|
set local_script "remote_deploy_dreamomni2.sh"
|
||||||
set remote_script "/root/remote_deploy_dreamomni2.sh"
|
set remote_script "/root/remote_deploy_dreamomni2.sh"
|
||||||
|
|
||||||
|
|||||||
@ -8,7 +8,7 @@ set -e
|
|||||||
OLD_SERVER="156.225.27.52"
|
OLD_SERVER="156.225.27.52"
|
||||||
OLD_PORT="5204"
|
OLD_PORT="5204"
|
||||||
OLD_USER="root"
|
OLD_USER="root"
|
||||||
OLD_PASS="Jsjj@8888"
|
OLD_PASS="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
BACKUP_DIR="./migration-backup-$(date +%Y%m%d_%H%M%S)"
|
BACKUP_DIR="./migration-backup-$(date +%Y%m%d_%H%M%S)"
|
||||||
|
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
|
|||||||
@ -3,7 +3,7 @@ set timeout 30
|
|||||||
set host "156.225.27.52"
|
set host "156.225.27.52"
|
||||||
set port "5204"
|
set port "5204"
|
||||||
set user "root"
|
set user "root"
|
||||||
set password "Jsjj@8888"
|
set password $env(DEPLOY_SSH_PASSWORD)
|
||||||
|
|
||||||
spawn ssh -o StrictHostKeyChecking=no -p $port $user@$host "echo 'Connected successfully' && nvidia-smi"
|
spawn ssh -o StrictHostKeyChecking=no -p $port $user@$host "echo 'Connected successfully' && nvidia-smi"
|
||||||
expect {
|
expect {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ set timeout -1
|
|||||||
set host "156.225.27.52"
|
set host "156.225.27.52"
|
||||||
set port "5204"
|
set port "5204"
|
||||||
set user "root"
|
set user "root"
|
||||||
set password "Jsjj@8888"
|
set password $env(DEPLOY_SSH_PASSWORD)
|
||||||
|
|
||||||
spawn ssh -p $port $user@$host "
|
spawn ssh -p $port $user@$host "
|
||||||
echo '--- GPU Status ---'
|
echo '--- GPU Status ---'
|
||||||
|
|||||||
@ -6,7 +6,7 @@ set -e
|
|||||||
SERVER="156.225.27.52"
|
SERVER="156.225.27.52"
|
||||||
PORT="5204"
|
PORT="5204"
|
||||||
USER="root"
|
USER="root"
|
||||||
PASSWORD="Jsjj@8888"
|
PASSWORD="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
|
|
||||||
ssh_cmd() {
|
ssh_cmd() {
|
||||||
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -p $PORT $USER@$SERVER "$1"
|
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -p $PORT $USER@$SERVER "$1"
|
||||||
|
|||||||
@ -10,7 +10,7 @@ PUBLIC_PASS="it5NuKGemX"
|
|||||||
|
|
||||||
PRIVATE_HOST="192.168.150.22"
|
PRIVATE_HOST="192.168.150.22"
|
||||||
PRIVATE_USER="root"
|
PRIVATE_USER="root"
|
||||||
PRIVATE_PASS="Jsjj@8888"
|
PRIVATE_PASS="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
|
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo "部署重定向修复"
|
echo "部署重定向修复"
|
||||||
|
|||||||
@ -9,7 +9,7 @@ set -e
|
|||||||
SERVER="156.225.27.52"
|
SERVER="156.225.27.52"
|
||||||
PORT="5204"
|
PORT="5204"
|
||||||
USER="root"
|
USER="root"
|
||||||
PASSWORD="Jsjj@8888"
|
PASSWORD="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
REMOTE_DIR="/var/www/ai-chatbot"
|
REMOTE_DIR="/var/www/ai-chatbot"
|
||||||
LOCAL_DIR="."
|
LOCAL_DIR="."
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
- **IP**: 156.225.27.52
|
- **IP**: 156.225.27.52
|
||||||
- **端口**: 5204
|
- **端口**: 5204
|
||||||
- **用户**: root
|
- **用户**: root
|
||||||
- **密码**: Jsjj@8888
|
- **密码**: <DEPLOY_SSH_PASSWORD>
|
||||||
|
|
||||||
## 🚀 快速部署步骤
|
## 🚀 快速部署步骤
|
||||||
|
|
||||||
@ -14,7 +14,7 @@
|
|||||||
ssh -p 5204 root@156.225.27.52
|
ssh -p 5204 root@156.225.27.52
|
||||||
```
|
```
|
||||||
|
|
||||||
输入密码: `Jsjj@8888`
|
输入密码: `<DEPLOY_SSH_PASSWORD>`
|
||||||
|
|
||||||
### 步骤 2: 上传部署脚本
|
### 步骤 2: 上传部署脚本
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ set -e
|
|||||||
SERVER="156.225.27.52"
|
SERVER="156.225.27.52"
|
||||||
PORT="5204"
|
PORT="5204"
|
||||||
USER="root"
|
USER="root"
|
||||||
PASSWORD="Jsjj@8888"
|
PASSWORD="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
|
|
||||||
ssh_cmd() {
|
ssh_cmd() {
|
||||||
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -p $PORT $USER@$SERVER "$1"
|
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -p $PORT $USER@$SERVER "$1"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ set timeout -1
|
|||||||
set host "156.225.27.52"
|
set host "156.225.27.52"
|
||||||
set port "5204"
|
set port "5204"
|
||||||
set user "root"
|
set user "root"
|
||||||
set password "Jsjj@8888"
|
set password $env(DEPLOY_SSH_PASSWORD)
|
||||||
|
|
||||||
puts "--> Connecting to finish installation..."
|
puts "--> Connecting to finish installation..."
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ set -e
|
|||||||
SERVER="156.225.27.52"
|
SERVER="156.225.27.52"
|
||||||
PORT="5204"
|
PORT="5204"
|
||||||
USER="root"
|
USER="root"
|
||||||
PASSWORD="Jsjj@8888"
|
PASSWORD="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
|
|
||||||
ssh_cmd() {
|
ssh_cmd() {
|
||||||
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -p $PORT $USER@$SERVER "$1"
|
sshpass -p "$PASSWORD" ssh -o StrictHostKeyChecking=no -o ConnectTimeout=30 -p $PORT $USER@$SERVER "$1"
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
HOST="156.225.27.52"
|
HOST="156.225.27.52"
|
||||||
PORT="5204"
|
PORT="5204"
|
||||||
USER="root"
|
USER="root"
|
||||||
PASSWORD="Jsjj@8888"
|
PASSWORD="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
|
|
||||||
echo "=========================================="
|
echo "=========================================="
|
||||||
echo "FRPC 访问问题诊断和修复"
|
echo "FRPC 访问问题诊断和修复"
|
||||||
|
|||||||
@ -10,7 +10,7 @@ PUBLIC_PASS="it5NuKGemX"
|
|||||||
|
|
||||||
PRIVATE_HOST="192.168.150.22"
|
PRIVATE_HOST="192.168.150.22"
|
||||||
PRIVATE_USER="root"
|
PRIVATE_USER="root"
|
||||||
PRIVATE_PASS="Jsjj@8888"
|
PRIVATE_PASS="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
|
|
||||||
APP_URL="http://156.225.27.52:5245"
|
APP_URL="http://156.225.27.52:5245"
|
||||||
|
|
||||||
|
|||||||
@ -9,7 +9,7 @@ set -e # 遇到错误立即退出
|
|||||||
OLD_SERVER="156.225.27.52"
|
OLD_SERVER="156.225.27.52"
|
||||||
OLD_PORT="5204"
|
OLD_PORT="5204"
|
||||||
OLD_USER="root"
|
OLD_USER="root"
|
||||||
OLD_PASS="Jsjj@8888"
|
OLD_PASS="${DEPLOY_SSH_PASSWORD:?set DEPLOY_SSH_PASSWORD}"
|
||||||
|
|
||||||
NEW_SERVER="114.66.31.51"
|
NEW_SERVER="114.66.31.51"
|
||||||
NEW_PORT="22"
|
NEW_PORT="22"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ set timeout -1
|
|||||||
set host "156.225.27.52"
|
set host "156.225.27.52"
|
||||||
set port "5204"
|
set port "5204"
|
||||||
set user "root"
|
set user "root"
|
||||||
set password "Jsjj@8888"
|
set password $env(DEPLOY_SSH_PASSWORD)
|
||||||
|
|
||||||
# 定义测试指令
|
# 定义测试指令
|
||||||
# 这是一个更通用的测试命令,先尝试列出文件确认脚本名
|
# 这是一个更通用的测试命令,先尝试列出文件确认脚本名
|
||||||
|
|||||||
@ -4,7 +4,7 @@ set timeout -1
|
|||||||
set host "156.225.27.52"
|
set host "156.225.27.52"
|
||||||
set port "5204"
|
set port "5204"
|
||||||
set user "root"
|
set user "root"
|
||||||
set password "Jsjj@8888"
|
set password $env(DEPLOY_SSH_PASSWORD)
|
||||||
|
|
||||||
# 定义正确的模型路径
|
# 定义正确的模型路径
|
||||||
set base_dir "/root/ai-projects/DreamOmni2"
|
set base_dir "/root/ai-projects/DreamOmni2"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ set timeout -1
|
|||||||
set host "156.225.27.52"
|
set host "156.225.27.52"
|
||||||
set port "5204"
|
set port "5204"
|
||||||
set user "root"
|
set user "root"
|
||||||
set password "Jsjj@8888"
|
set password $env(DEPLOY_SSH_PASSWORD)
|
||||||
|
|
||||||
# 定义正确的模型路径
|
# 定义正确的模型路径
|
||||||
set base_dir "/root/ai-projects/DreamOmni2"
|
set base_dir "/root/ai-projects/DreamOmni2"
|
||||||
|
|||||||
@ -4,7 +4,7 @@ set timeout -1
|
|||||||
set host "156.225.27.52"
|
set host "156.225.27.52"
|
||||||
set port "5204"
|
set port "5204"
|
||||||
set user "root"
|
set user "root"
|
||||||
set password "Jsjj@8888"
|
set password $env(DEPLOY_SSH_PASSWORD)
|
||||||
set remote_script "/root/remote_setup.sh"
|
set remote_script "/root/remote_setup.sh"
|
||||||
|
|
||||||
# 1. Upload Setup Script (small file, scp is fine)
|
# 1. Upload Setup Script (small file, scp is fine)
|
||||||
|
|||||||
@ -4,7 +4,7 @@ set timeout -1
|
|||||||
set host "156.225.27.52"
|
set host "156.225.27.52"
|
||||||
set port "5204"
|
set port "5204"
|
||||||
set user "root"
|
set user "root"
|
||||||
set password "Jsjj@8888"
|
set password $env(DEPLOY_SSH_PASSWORD)
|
||||||
set local_model_dir "FLUX_Model"
|
set local_model_dir "FLUX_Model"
|
||||||
set remote_base_dir "/root/ai-projects/DreamOmni2/checkpoints"
|
set remote_base_dir "/root/ai-projects/DreamOmni2/checkpoints"
|
||||||
|
|
||||||
|
|||||||
@ -129,7 +129,7 @@ cd /Users/lanmu/Desktop/ai-chatbot-main
|
|||||||
npm run build
|
npm run build
|
||||||
|
|
||||||
# 上传并重启
|
# 上传并重启
|
||||||
sshpass -p "Jsjj@8888" ssh -p 5204 root@156.225.27.52 "
|
sshpass -p "<DEPLOY_SSH_PASSWORD>" ssh -p 5204 root@156.225.27.52 "
|
||||||
cd /var/www/ai-chatbot && \
|
cd /var/www/ai-chatbot && \
|
||||||
npm run build && \
|
npm run build && \
|
||||||
pm2 restart ai-chatbot
|
pm2 restart ai-chatbot
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user