Documentation
¶
Index ¶
- Constants
- func Request(method string, url string, data interface{}) ([]byte, error)
- type GoogleAuth
- func (this *GoogleAuth) GetCode(secret string, expireSecond int64) (string, error)
- func (this *GoogleAuth) GetQrcode(issuer string, user string, secret string, digits int, expireSecond int) string
- func (this *GoogleAuth) GetQrcodeUrl(qrcode string, width int, height int) string
- func (this *GoogleAuth) GetSecret() string
- func (this *GoogleAuth) VerifyCode(secret, code string, expireSecond int64) (bool, error)
- type GoogleAuthenticator
- type OauthObj
- type OauthPlatformDto
- type ReqDto
- type ResDto
- type TokenInfoDto
- type UserInfoDto
- type VerifyReqDto
- type VerifyResDto
Constants ¶
View Source
const ( ERR_CODE_PARAMETER_ERROR = "PARAMETER_ERROR" // 参数错误 ERR_CODE_FAIL = "FAIL" // 失败 ERR_CODE_UNKNOWN_ERROR = "UNKNOWN_ERROR" // 未知错误 ERR_CODE_RECORD_NOT_FOUND = "RECORD_NOT_FOUND" // 未找到记录 ERR_CODE_FREQUENT_OPERATIONS = "FREQUENT_OPERATIONS" // 频繁操作 ERR_CODE_TYPE_INVALID_CODE = "INVALID_CODE" // 无效的CODE(过期或code格式不对) ERR_CODE_ACCESS_TOKEN_FAIL = "ACCESS_TOKEN_FAIL" // 获取ACCESS_TOKEN失败 ERR_CODE_OAUTH_CONFIG_FAIL = "OAUTH_CONFIG_FAIL" // 获取OAUTH配置失败 )
View Source
const ( CODE_TYPE_GRANT_CODE = "grant_code" // APP使用 CODE_TYPE_ACCESS_TOKEN = "access_token" // WEB使用 )
code type
View Source
const GOOGLE_AUTHENTICATOR_EXPIRE_SECOND = 30
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GoogleAuth ¶
type GoogleAuth struct {
}
func (*GoogleAuth) GetCode ¶
func (this *GoogleAuth) GetCode(secret string, expireSecond int64) (string, error)
获取动态码
func (*GoogleAuth) GetQrcode ¶
func (this *GoogleAuth) GetQrcode(issuer string, user string, secret string, digits int, expireSecond int) string
获取动态码二维码内容
func (*GoogleAuth) GetQrcodeUrl ¶
func (this *GoogleAuth) GetQrcodeUrl(qrcode string, width int, height int) string
获取动态码二维码图片地址,这里是第三方二维码api
func (*GoogleAuth) VerifyCode ¶
func (this *GoogleAuth) VerifyCode(secret, code string, expireSecond int64) (bool, error)
验证动态码
type GoogleAuthenticator ¶
type GoogleAuthenticator struct {
}
func NewGoogleAuthenticator ¶
func NewGoogleAuthenticator() *GoogleAuthenticator
func (*GoogleAuthenticator) InitAuth ¶
func (p *GoogleAuthenticator) InitAuth(issuer string, user string, width int, height int) (secret, qrCodeUrl string)
开启二次认证
func (*GoogleAuthenticator) VerifyCode ¶
func (p *GoogleAuthenticator) VerifyCode(secret string, code string) (ok bool, err error)
type OauthObj ¶
type OauthObj struct {
PlatformConf OauthPlatformDto
PlatformObj *oauth2.Config
}
func (*OauthObj) GetAccessToken ¶
func (p *OauthObj) GetAccessToken(code string) (*TokenInfoDto, string, string)
获取access_token
type OauthPlatformDto ¶
type OauthPlatformDto struct {
Platform string
BaseUrl string
Version string
AuthURL string
TokenURL string
Scopes []string
}
func (*OauthPlatformDto) GetUserInfo ¶
func (o *OauthPlatformDto) GetUserInfo(accessToken string) (*UserInfoDto, string, string)
type ReqDto ¶
type ReqDto struct {
Issuer string `json:"-"`
Username string `json:"username"`
Width int `json:"-"`
Height int `json:"-"`
}
获取
type TokenInfoDto ¶
type UserInfoDto ¶
type VerifyReqDto ¶
验证
type VerifyResDto ¶
type VerifyResDto struct {
VerifyResult bool `json:"verify_result"`
}
Click to show internal directories.
Click to hide internal directories.