Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var JWT = func(ctx *context.Context) { var code int var data interface{} var token string code = e.SUCCESS token = ctx.Request.Header.Get("X-Token") if token == "" { code = e.INVALID_PARAMS } else { claims, err := utils.ParseToken(token) if err != nil { code = e.ERROR_AUTH_CHECK_TOKEN_FAIL } else if time.Now().Unix() > claims.ExpiresAt { code = e.ERROR_AUTH_CHECK_TOKEN_TIMEOUT } } if code != e.SUCCESS { errorInfo := auxpi.RespJson{ Code: code, Msg: e.GetMsg(code), Data: data, } info, _ := errorInfo.MarshalJSON() ctx.Output.Header("Content-Type", "application/json; charset=UTF-8") ctx.ResponseWriter.Write(info) return } }
View Source
var XsrfError = func(ctx *context.Context) { resp := &auxpi.RespJson{} code := e.ERROR_ACCESS_DENIED _xsrf := ctx.Request.Form.Get("_xsrf") if _xsrf != getXSRFToken(beego.BConfig.WebConfig.XSRFKey, int64(beego.BConfig.WebConfig.XSRFExpire)) { resp.Code = code resp.Msg = e.GetMsg(code) resp.Data = "" } ctx.Output.Header("Content-Type", "application/json; charset=UTF-8") info, _ := resp.MarshalJSON() ctx.ResponseWriter.Write(info) return }
自定义 CSRF 错误码返回
Functions ¶
func GetSecureCookie ¶
GetSecureCookie Get secure cookie from request by a given key.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.