add models / services / handlers of user / token / 2fa, add web server command
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
package models
|
||||
|
||||
import "github.com/mayswind/lab/pkg/core"
|
||||
|
||||
const TOKEN_USER_AGENT_MAX_LENGTH = 255
|
||||
|
||||
type TokenRecord struct {
|
||||
Uid int64 `xorm:"PK"`
|
||||
UserTokenId int64 `xorm:"PK"`
|
||||
TokenType core.TokenType `xorm:"TINYINT NOT NULL"`
|
||||
Secret string `xorm:"VARCHAR(10) NOT NULL"`
|
||||
UserAgent string `xorm:"VARCHAR(255)"`
|
||||
CreatedUnixTime int64 `xorm:"PK"`
|
||||
ExpiredUnixTime int64
|
||||
}
|
||||
|
||||
type TokenRevokeRequest struct {
|
||||
TokenId string `json:"tokenId" binding:"required,notBlank"`
|
||||
}
|
||||
|
||||
type TokenInfoResponse struct {
|
||||
TokenId string `json:"tokenId"`
|
||||
TokenType core.TokenType `json:"tokenType"`
|
||||
UserAgent string `json:"userAgent"`
|
||||
CreatedAt int64 `json:"createdAt"`
|
||||
ExpiredAt int64 `json:"expiredAt"`
|
||||
IsCurrent bool `json:"isCurrent"`
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package models
|
||||
|
||||
type TwoFactor struct {
|
||||
Uid int64 `xorm:"PK"`
|
||||
Secret string `xorm:"VARCHAR(80) NOT NULL"`
|
||||
CreatedUnixTime int64
|
||||
}
|
||||
|
||||
type TwoFactorLoginRequest struct {
|
||||
Passcode string `json:"passcode" binding:"required,notBlank,len=6"`
|
||||
}
|
||||
|
||||
type TwoFactorEnableConfirmRequest struct {
|
||||
Secret string `json:"secret" binding:"required,notBlank,len=32"`
|
||||
Passcode string `json:"passcode" binding:"required,notBlank,len=6"`
|
||||
}
|
||||
|
||||
type TwoFactorEnableResponse struct {
|
||||
Secret string `json:"secret"`
|
||||
QRCode string `json:"qrcode"`
|
||||
}
|
||||
|
||||
type TwoFactorEnableConfirmResponse struct {
|
||||
Token string `json:"token,omitempty"`
|
||||
RecoveryCodes []string `json:"recoveryCodes"`
|
||||
}
|
||||
|
||||
type TwoFactorStatusResponse struct {
|
||||
Enable bool `json:"enable"`
|
||||
CreatedAt int64 `json:"createdAt,omitempty"`
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package models
|
||||
|
||||
type TwoFactorRecoveryCode struct {
|
||||
Uid int64 `xorm:"PK"`
|
||||
RecoveryCode string `xorm:"VARCHAR(64) PK"`
|
||||
Used bool `xorm:"NOT NULL"`
|
||||
CreatedUnixTime int64
|
||||
UsedUnixTime int64
|
||||
}
|
||||
|
||||
type TwoFactorRecoveryCodeLoginRequest struct {
|
||||
RecoveryCode string `json:"recoveryCode" binding:"required,notBlank,len=11"`
|
||||
}
|
||||
Reference in New Issue
Block a user