feat: add login authentication and certificate expiry notifications

- JWT-based login with ADMIN_USER/ADMIN_PASSWORD env config
- Login page with auth guard for Vue frontend
- Feishu bot webhook notification for expiring certificates
- SMTP email notification for expiring certificates
- Daily 8:00 AM cron for expiry checks
- Startup health check notification
This commit is contained in:
2026-07-23 16:25:02 +08:00
parent 1bb895fd67
commit 2d70a15307
17 changed files with 2813 additions and 66 deletions
+18 -4
View File
@@ -1,11 +1,11 @@
#!/bin/bash
set -e
echo "=== Auto-SSL 一键部署脚本 ==="
echo "=== Auto-SSL 一键部署脚本 ===
# 1. 拉取最新代码
echo "1. 拉取最新代码..."
git pull origin 0.01
git pull origin master 2>/dev/null || git pull origin 0.01 2>/dev/null || echo " (跳过git拉取)"
# 2. 编译后端
echo "2. 编译Go后端..."
@@ -28,7 +28,6 @@ cp -rf frontend/dist/* backend/dist/
# 5. 创建systemd服务
echo "5. 安装systemd服务..."
# 直接生成正确路径的service文件,避免sed替换失败
cat > /tmp/autossl.service << EOF
[Unit]
Description=Auto-SSL 证书管理服务
@@ -42,6 +41,18 @@ WorkingDirectory=$PWD/backend
Environment="PORT=9090"
Environment="ACME_PORT=8082"
Environment="GIN_MODE=release"
Environment="ADMIN_USER=admin"
Environment="ADMIN_PASSWORD=****?
Environment="JWT_SECRET="
# 飞书机器人通知(可选)
# Environment="FEISHU_WEBHOOK_URL=https://open.feishu.cn/open-apis/bot/v2/hook/xxxxx"
# 邮件通知(可选)
# Environment="SMTP_HOST=smtp.example.com"
# Environment="SMTP_PORT=587"
# Environment="SMTP_USER=user@example.com"
# Environment="SMTP_PASSWORD=password"
# Environment="SMTP_FROM=user@example.com"
# Environment="NOTIFY_TO=admin@example.com"
ExecStart=$PWD/backend/autossl
Restart=always
RestartSec=3
@@ -63,9 +74,12 @@ sudo systemctl restart autossl
# 7. 检查状态
sleep 2
echo "7. 检查服务状态..."
if curl -s http://127.0.0.1:9090/api/stats > /dev/null; then
if curl -s http://127.0.0.1:9090/api/health > /dev/null; then
echo "✅ 部署成功!服务运行在 http://0.0.0.0:9090"
echo "📝 日志查看:journalctl -u autossl -f"
echo ""
echo "默认登录账号: admin / admin123"
echo "请通过环境变量 ADMIN_USER / ADMIN_PASSWORD 修改密码"
else
echo "❌ 部署失败,请检查日志:journalctl -u autossl -n 50"
exit 1