Documentation
¶
Overview ¶
Package otpsdk implements PKCS#7 padding, as defined in RFC 5652. 源码: https://github.com/zenazn/pkcs7pad 标准:https://datatracker.ietf.org/doc/rfc2315/
Index ¶
- Constants
- func AddAccountSecret(account string) error
- func Conf(serverSign, otpServerAddr, ServerKey, ServerIV string)
- func GenAccessToken() (string, error)
- func GetQRCodeContent(account string) (string, error)
- func Pad(buf []byte, size int) []byte
- func Unpad(buf []byte) ([]byte, error)
- func VerifyAccessToken(token string) error
- func VerifyAndGenAccessToken(token string) (string, error)
- func VerifyCode(account, code string) (bool, error)
- type AccountSecretModel
- type Result
Constants ¶
const ( GenAccessTokenPath = "/v1/access-token" VerifyAccessTokenPath = "/v1/access-token/verify" AddAccountSecretPath = "/v1/secret" GetAccountSecretPath = "/v1/secret" VerifyCodePath = "/v1/secret/valid" )
Variables ¶
This section is empty.
Functions ¶
func Conf ¶
func Conf(serverSign, otpServerAddr, ServerKey, ServerIV string)
Conf 初始化配置 serverSign 服务标识(在otp server申请服务时填写的)
func GenAccessToken ¶
GenAccessToken 请求otp server生成 access token address otp server地址,例如:http://127.0.0.1:8066 serverSign 服务标识(在otp server申请服务时填写的) key,iv 服务密钥和IV
func GetQRCodeContent ¶
GetQRCodeContent 获取密钥二维码内容
func Pad ¶
Pad appends PKCS#7 padding to the given buffer such that the resulting slice of bytes has a length divisible by the given size. If you are using this function to pad a plaintext before encrypting it with a block cipher, the size should be equal to the block size of the cipher (e.g., aes.BlockSize).
func Unpad ¶
Unpad returns a subslice of the input buffer with trailing PKCS#7 padding removed. It checks the correctness of the padding bytes in constant time, and returns an error if the padding bytes are malformed.
func VerifyAccessToken ¶
VerifyAccessToken 验证access token
func VerifyAndGenAccessToken ¶
VerifyAndGenAccessToken 验证token,不通过生成获取新的token
Types ¶
type AccountSecretModel ¶
type AccountSecretModel struct { ID int64 `gorm:"column:id;primary_key" json:"id"` SecretSeed string `gorm:"column:secret_seed_cipher" json:"secret"` // 密钥种子密文 = AES(KEY, 密钥种子) Account string `gorm:"column:account" json:"account"` // 账号 DataCheck string `gorm:"column:data_check" json:"dataCheck"` // 数据校验 = HMACSHA256(KEY, secret_seed_cipher + account + is_enable) IsEnable uint8 `gorm:"column:is_enable" json:"isEnable"` // 是否启用,1启用,2禁用 CreateTime time.Time `gorm:"column:create_time" json:"createTime"` UpdateTime time.Time `gorm:"column:update_time" json:"updateTime"` }
func GetAccountSecret ¶
func GetAccountSecret(account string) (*AccountSecretModel, error)
GetAccountSecret 获取指定账号密钥