- route definition
- Url: /api/v1/auth/login
- Method: POST
- Request:
LoginRequest - Response:
LoginResponse
- request definition
type LoginRequest struct {
Username string `json:"username"` // 用户名
Password string `json:"password"` // 密码
}
- response definition
type LoginResponse struct {
Token string `json:"token"`
User UserInfo `json:"user"`
}
type UserInfo struct {
Username string `json:"username"`
Roles []string `json:"roles"`
Nickname string `json:"nickname,omitempty"`
Email string `json:"email,omitempty"`
Phone string `json:"phone,omitempty"`
}
- route definition
- Url: /api/v1/auth/logout
- Method: POST
- Request:
LogoutRequest - Response:
LogoutResponse
- request definition
type LogoutRequest struct {
}
- response definition
type LogoutResponse struct {
}
- route definition
- Url: /api/v1/auth/check
- Method: POST
- Auth: Bearer Token
- Request:
CheckRequest - Response:
CheckResponse
- request definition
type CheckRequest struct {
Resource string `json:"resource"` // 例如 roles、games、functions
Action string `json:"action"` // 例如 read、write、manage
GameID string `json:"gameId,omitempty"`
Env string `json:"env,omitempty"`
}
- response definition
type CheckResponse struct {
Allowed bool `json:"allowed"`
Reason string `json:"reason,omitempty"`
}
- route definition
- Url: /api/v1/auth/check/batch
- Method: POST
- Auth: Bearer Token
- Request:
BatchCheckRequest - Response:
BatchCheckResponse
- request definition
type BatchCheckRequest struct {
Checks []CheckRequest `json:"checks"`
}
- response definition
type BatchCheckResponse struct {
Results []CheckResponse `json:"results"`
}
- 校验基于当前登录用户在数据库中的角色和权限,不依赖前端缓存。
gameId 与 env 字段当前保留用于兼容前端请求结构,现阶段权限判断主要按资源和动作执行。