yzyauth

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

yzyauth

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DebugConf = &Config{
	EnableAuth:         true,
	EnableDebug:        false,
	DebugUser:          "",
	AuthUrl:            "https://xtbgtest.digitalgd.com.cn/pps/auth",
	ClientId:           "workbench",
	Secret:             "MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALIJSI7be4tZFmC2AtQTcXZuCVg1k+gLuoE/rDcR9E5nWDw21669/pqVgb2ay6VBL4dGVXL/TFQnpQT6s3WhlBUCAwEAAQ==",
	CallbackURI:        "http://10.101.101.7:8080/demo/callback?call_uri=",
	DefaultRedirectUrl: "http://10.101.101.7:8080/demo/index",
}

Functions

func Auth

func Auth(ctx *fasthttp.RequestCtx) (success bool, authorizeURI string)

Auth 请求接口认证包装方法,success:认证是否通过,authorizeURI:认证不通过时,返回重定向粤政易认证地址链接

func GetAccessToken

func GetAccessToken(ctx *fasthttp.RequestCtx) (accessToken string, ok bool)

GetAccessToken 从cookie或header取access_token

func GetTokenValue

func GetTokenValue(token, key string) (value interface{})

GetTokenValue 根据key获取token中的value access token demo: eyJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJ3b3JrYmVuY2giLCJzdWIiOiJ4ejJvYzQ1N2syMTVqMHFqZ3BvMGw2Iiwicm9sZXMiOiJ7fSIsImlzcyI6ImRpZ2l0YWxnZCIsImV4cCI6MTY0NDgxNjgyMCwibm9uY2UiOiJjOGMyOWI0ZDliY2JhMTQxNmZjYmIwNGQzNjY3OTdiZCMyIiwiaWF0IjoxNjQ0ODA5NjIwfQ.gYbomslVH4x0Y8Tvnd64jDJNnMmg5XtpO7S4NxRZm9uUWOXG5yQVfu4mG5wCBFVrS7Li-qTrd9IPqIQrZ1tiXw payload:{"aud":"workbench","sub":"xz2oc457k215j0qjgpo0l6","roles":"{}","iss":"digitalgd","exp":1644816820,"nonce":"c8c29b4d9bcba1416fcbb04d366797bd#2","iat":1644809620}

func InitAuth

func InitAuth(config *Config)

InitAuth 初始化认证配置

func IsAjaxRequest

func IsAjaxRequest(ctx *fasthttp.RequestCtx) bool

func ResponseJSON

func ResponseJSON(ctx *fasthttp.RequestCtx, response interface{})

ResponseJSON fasthttp响应JSON格式结果

func SetCookie

func SetCookie(key, value string, expire int, ctx *fasthttp.RequestCtx)

SetCookie 设置指定Cookie

func TodayRemainSecond

func TodayRemainSecond() int

TodayRemainSecond 获取服务器当前时间离当天结束还有多少秒

Types

type Config

type Config struct {
	EnableAuth         bool
	EnableDebug        bool
	DebugUser          string
	AuthUrl            string
	ClientId           string
	Secret             string
	CallbackURI        string
	DefaultRedirectUrl string
}
var AuthConf *Config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL