auth.go
2.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package protocol
const (
LoginByPassword = "signInPassword"
LoginBySmsCode = " signInCaptcha"
)
const AuthCodeExpire = 60 * 15
const TokenExpire = 60 * 60 * 2
const RefreshTokenExipre = 3600 * 24 * 30 * 3 //刷新token 三个月过期
/*Login */
type LoginRequest struct {
Phone string `json:"phone" valid:"Required;"`
Password string `json:"password"`
Captcha string `json:"captcha"`
GrantType string `json:"grantType"` // 登录类型 1:密码 2:验证码
ClientId string `json:"clientId"`
}
type LoginResponse struct {
AuthCode string `json:"authCode"`
}
//JWT用户信息
type JWTUserInfo struct {
UserId string `json:"id"` //用户id
PassWord string `json:"passWord"` //密码
}
/*SmsCode*/
type SmsCodeRequest struct {
Phone string `json:"phone" valid:"Required;Mobile"`
Content string `json:"-"`
SendType string `json:"send_type"` //sms_login_code sms_change_mobile
}
type SmsCodeResponse struct {
Code string `json:"-"`
}
/*UpdateDevice*/
type UpdateDeviceRequest struct {
ClientId string `json:"clientId" valid:"Required"`
DeviceToken string `json:"deviceToken"`
}
type UpdateDeviceResponse struct {
}
/*AccessToken */
type AccessTokenRequest struct {
//ClientId string `json:"clientId" valid:"Required"`
//ClientSecret string `json:"clientSecret" valid:"Required"`
AuthCode string `json:"authCode" valid:"Required"`
}
type AccessTokenResponse struct {
RefreshToken string `json:"refreshToken"`
AccessToken string `json:"accessToken"`
ExpiresIn int `json:"expiresIn"`
}
/*RefreshToken */
type RefreshTokenRequest struct {
ClientId string `json:"clientId" valid:"Required"`
ClientSecret string `json:"clientSecret" valid:"Required"`
RefreshToken string `json:"refreshToken" valid:"Required"`
//Uid int64 `json:"-"`
//LoginType string `json:"-"`
}
type RefreshTokenResponse struct {
RefreshToken string `json:"refreshToken"`
AccessToken string `json:"accessToken"`
ExpiresIn int `json:"expiresIn"`
}
/*Revoke */
type RevokeRequest struct {
}
type RevokeResponse struct {
}
/*AuthCheckSmsCode */
type AuthCheckSmsCodeRequest struct {
Phone string `json:"phone" valid:"Required;"`
Captcha string `json:"captcha" valid:"Required;"`
}
type AuthCheckSmsCodeResponse struct {
CaptchaCertificate string `json:"captchaCertificate"` //短信验证码通过凭证
}