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.

167 lines
4.5 KiB
Plaintext

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.

syntax = "v1"
import "../base.api"
type (
// OAuth log in request | OAuth 登录请求
// swagger:parameters OauthLogin
OauthLoginReq {
// Provider name | 服务提供商名称
//
// In: query
// Required: true
// Max Length: 40
// Example: [google, github, facebook]
Provider string `form:"provider" validate:"max=40"`
}
// OAuth login return auth url | OAuth登录返回提供商登录页地址
OauthLoginResp {
// Auth URL | 提供商登录地址
AuthUrl string `json:"authUrl"`
}
// OAuth log in by code request | OAuth 直接登录请求
OauthLoginByCodeReq {
// Code | 一次性code
Code string `json:"code"`
// Provider name | 服务提供商名称
//
// Example: [wechat,google]
Provider string `json:"provider" validate:"max=40"`
}
// OAuth log in by phone code request | OAuth 手机号码登录请求
OauthLoginByPhoneCodeReq {
// AuthCode | 登录Code非必填为了平台兼容性
AuthCode string `json:"authCode,optional"`
// Code | 一次性code
Code string `json:"code"`
// Provider name | 服务提供商名称
//
// Example: [wechat,google]
Provider string `json:"provider" validate:"max=40"`
}
// Log in request | 普通登录请求
LoginReq {
// Log in subject | 登录主体(用户名/邮箱/手机号码)| 作用于验证码时,不支持用户名
Subject string `json:"subject"`
// Credentials | 登录凭证
Credentials string `json:"credentials"`
// Platform | 当前登录平台
Platform string `json:"platform"`
// Captcha ID which store in redis | 图形验证码编号, 存在redis中
//
// Required: true
// Max length: 32
CaptchaId string `json:"captchaId,optional" validate:"len=32"`
// The Captcha which users input | 用户输入的验证码
//
// Required: true
// Max length: 4
Captcha string `json:"captcha,optional" validate:"len=4"`
}
// LoginResp | 登录返回数据
// swagger:model LoginResp
LoginResp {
// TwoFactorType | 两步验证类型,空字符串表示无需两步验证
TwoFactorType string `json:"twoFactorType"`
// Token | Token信息
Token LoginTokenInfo `json:"token,optional"`
}
// LoginTokenInfo | Token数据
// swagger:model LoginTokenInfo
LoginTokenInfo {
// User ID | 用户ID
UID int64 `json:"uid,string"`
// Token Type | Token类型 Authorization: {token_type} {access_token}
//
// Example: [Bearer]
TokenType string `json:"token_type"`
// Access Token | Jwt-Token
AccessToken string `json:"access_token"`
// Expires At | 过期具体时间,时间戳格式
ExpiresAt int64 `json:"expires_at"`
// Scope | 授权范围,逗号分割
Scope string `json:"scope,omitempty,optional"`
}
// Register request | 注册请求
RegisterReq {
// Username | 用户名
Username *string `json:"username,optional"`
// Email | 邮箱
Email *string `json:"email,optional"`
// PhoneNumber | 手机号码
PhoneNumber *string `json:"phoneNumber,optional"`
// Credentials | 凭证
Credentials string `json:"credentials"`
// Code | 验证码
Code *string `json:"code,optional"`
// Captcha ID which store in redis | 图形验证码编号, 存在redis中
//
// Required: true
// Max length: 32
CaptchaId string `json:"captchaId,optional" validate:"len=32"`
// The Captcha which users input | 用户输入的验证码
//
// Required: true
// Max length: 6
Captcha string `json:"captcha,optional" validate:"len=4"`
}
)
@server(
group: auth
prefix: /api/auth
)
service api {
// Oauth log in | Oauth 第三方登录获取登录地址通常针对PC网页登录APP端自行获取code
@handler oauthLogin
get /oauth/login (OauthLoginReq) returns (OauthLoginResp)
// Oauth log in by code | Oauth 第三方登录客户端自行获取code进行登录
@handler oauthLoginByCode
post /oauth/login/byCode (OauthLoginByCodeReq) returns (LoginResp)
// Oauth log in by phone code | Oauth 第三方登录客户端获取换取手机号的code进行登录
@handler oauthLoginByPhone
post /oauth/login/byPhone (OauthLoginByPhoneCodeReq) returns (LoginResp)
// Oauth log in callback route | Oauth 登录返回调接口即redirect_uri
@handler oauthCallback
get /oauth/login/callback returns (LoginResp)
// Log in | 密码登录
@handler login
post /login (LoginReq) returns (LoginResp)
// Log in by code | 验证码登录手机x邮箱
@handler loginByCode
post /login/byCode (LoginReq) returns (LoginResp)
// Register | 注册
@handler register
post /register (RegisterReq) returns (BaseID)
}