You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
OneAuth/doc/README.md

98 lines
2.1 KiB
Markdown

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# VBase 文档
欢迎来到 VBase 文档中心。
## 快速导航
| 文档 | 说明 |
|------|------|
| [API 文档](./api.md) | 完整的 API 接口文档,包含请求/响应格式 |
| [架构设计](./architecture.md) | 系统架构、模块设计、数据模型 |
| [部署指南](./deployment.md) | 环境配置、Docker 部署、运维指南 |
| [权限系统](./permission.md) | RBAC+ABAC 权限模型使用指南 |
## 快速开始
### 1. 启动服务
```bash
# 使用 Docker Compose
docker-compose up -d
# 或使用源码
go run ./cmd/server
```
### 2. 获取初始管理员密码
查看日志获取自动生成的管理员密码:
```bash
docker logs vbase_app_1 | grep -A 5 "Initial admin"
```
### 3. 调用 API
```bash
# 登录
curl -X POST http://localhost:8080/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"your-password"}'
# 访问用户列表
curl http://localhost:8080/users \
-H "Authorization: Bearer your-access-token"
```
## 配置 OAuth 登录
### Google 登录
1. 访问 [Google Cloud Console](https://console.cloud.google.com/)
2. 创建 OAuth 2.0 客户端
3. 配置环境变量:
```bash
OAUTH_GOOGLE_ENABLED=true
OAUTH_GOOGLE_CLIENT_ID=your-client-id
OAUTH_GOOGLE_CLIENT_SECRET=your-client-secret
```
### GitHub 登录
1. 访问 [GitHub Settings](https://github.com/settings/developers)
2. 创建 OAuth App
3. 配置环境变量:
```bash
OAUTH_GITHUB_ENABLED=true
OAUTH_GITHUB_CLIENT_ID=your-client-id
OAUTH_GITHUB_CLIENT_SECRET=your-client-secret
```
## 常见问题
### Q: 首次启动时管理员密码是什么?
A: 如果未设置 `INIT_ADMIN_PASSWORD`,系统会自动生成随机密码并打印在日志中。
### Q: 如何重置管理员密码?
A: 直接修改数据库中的 `users` 表,使用 bcrypt 生成新密码哈希。
### Q: 支持哪些数据库?
A: 支持 MySQL 5.7+、PostgreSQL 12+、SQLite 3。
### Q: 如何实现单点登录(SSO)
A: VBase 可以作为 OAuth2.0/OIDC 服务端,其他应用配置为 OAuth 客户端即可实现 SSO。
## 贡献指南
欢迎提交 Issue 和 PR。
## 许可证
MIT License