Skip to content

bohesocool/gift

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🌿 薄荷CLI共享池

一个基于 OAuth2 认证的 Google Cloud 凭证共享平台,支持用户捐赠和验证密钥。

薄荷CLI共享池

✨ 功能特点

  • 🔐 OAuth2 认证 - 使用 linux.do 账号安全登录
  • 📊 实时仪表盘 - 显示存活/失效密钥数量
  • 🏆 捐赠排行榜 - 前30名贡献者荣誉榜
  • ✅ 自动验证 - 自动验证密钥有效性
  • 🚀 批量上传 - 支持批量上传多个凭证
  • 🐳 Docker部署 - 一键部署,开箱即用

🚀 快速开始

方式一:Docker 部署(推荐)

  1. 克隆项目
git clone <repo-url>
cd juanzeng
  1. 配置环境变量
cp env.example .env
# 编辑 .env 文件,填入您的配置
  1. 启动服务
docker-compose up -d
  1. 访问应用 打开浏览器访问 http://localhost:8181

方式二:本地开发

  1. 安装依赖
cd backend
pip install -r requirements.txt
  1. 配置环境变量
cp env.example .env
  1. 运行应用
python main.py

📁 项目结构

juanzeng/
├── backend/                 # 后端代码
│   ├── main.py             # FastAPI 主应用
│   ├── config.py           # 配置管理
│   ├── database.py         # 数据库操作
│   ├── auth.py             # OAuth2 认证
│   ├── services/           # 业务服务
│   │   ├── key_validator.py   # Key 验证服务
│   │   └── pool_service.py    # 号池服务
│   └── requirements.txt    # Python 依赖
├── frontend/               # 前端代码
│   ├── index.html         # 主页面
│   ├── css/
│   │   └── style.css      # 样式表
│   └── js/
│       └── app.js         # 前端逻辑
├── docker-compose.yml      # Docker Compose 配置
├── Dockerfile              # Docker 镜像配置
├── env.example             # 环境变量示例
└── README.md               # 项目说明

⚙️ 配置说明

环境变量

变量名 说明 默认值
OAUTH2_CLIENT_ID linux.do OAuth2 客户端ID -
OAUTH2_CLIENT_SECRET linux.do OAuth2 客户端密钥 -
OAUTH2_REDIRECT_URI OAuth2 回调地址 http://localhost:8181/oauth2/callback
POOL_API_BASE_URL 号池API地址 http://localhost:5035
POOL_API_AUTH_KEY 号池API认证密钥 -
APP_SECRET_KEY 应用密钥(Session加密) -

凭证格式

上传的凭证应为 JSON 格式,包含以下字段(来自 Google OAuth 认证后的凭证):

{
  "access_token": "ya29.xxx...",
  "refresh_token": "1//0gxxx...",
  "client_id": "xxx.apps.googleusercontent.com",
  "client_secret": "your-google-client-secret",
  "token_uri": "https://oauth2.googleapis.com/token",
  "scope": "https://www.googleapis.com/auth/cloud-platform ...",
  "token_type": "Bearer"
}

验证流程说明:

  1. 使用凭证中的 access_token 直接调用 Google API
  2. 如果 access_token 过期,使用凭证中的 refresh_token + client_id + client_secret 刷新
  3. 自动创建 Google Cloud 项目并启用 cloudaicompanion.googleapis.com API
  4. 调用 Gemini API 测试活性

批量上传多个凭证时,使用 ,,, 分隔:

{"凭证1"},,, {"凭证2"},,, {"凭证3"}

🔒 安全说明

  • 号池API地址和认证密钥存储在服务端环境变量中,前端无法访问
  • 所有敏感操作需要 OAuth2 认证
  • Session 使用加密存储

📝 API 接口

接口 方法 说明
/api/stats GET 获取仪表盘统计
/api/leaderboard GET 获取捐赠排行榜
/api/user GET 获取当前登录用户
/api/auth/login GET 发起 OAuth2 登录
/api/auth/logout POST 退出登录
/api/donate POST 提交捐赠

🤝 贡献

欢迎提交 Issue 和 Pull Request!

📄 许可证

MIT License

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors