作者 陈志颖

合并分支 'test' 到 'master'

Test



查看合并请求 !69
... ... @@ -5,18 +5,19 @@ go 1.14
require (
github.com/Shopify/sarama v1.26.4
github.com/ajg/form v1.5.1 // indirect
github.com/astaxie/beego v1.12.1
github.com/astaxie/beego v1.12.3
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
github.com/gavv/httpexpect v2.0.0+incompatible
github.com/gin-gonic/gin v1.5.0
github.com/go-pg/pg/v10 v10.0.0-beta.2
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9
github.com/moul/http2curl v1.0.0 // indirect
github.com/onsi/ginkgo v1.15.0
github.com/onsi/gomega v1.10.5
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
github.com/shopspring/decimal v1.2.0
github.com/tiptok/gocomm v1.0.5
github.com/valyala/fasthttp v1.19.0 // indirect
... ... @@ -24,4 +25,5 @@ require (
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
)
... ...
... ... @@ -9,6 +9,8 @@ import (
)
func init() {
beego.InsertFilter("/*", beego.BeforeRouter, middleware.AllowCors())
beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequestBodyFilter())
beego.InsertFilter("/v1/*", beego.BeforeExec, middleware.CheckJWTToken)
... ...
/**
@author: stevechan
@date: 2021/3/9
@note:
**/
package middleware
import (
"github.com/astaxie/beego/context"
"github.com/astaxie/beego/plugins/cors"
)
func AllowCors() func(ctx *context.Context) {
fn := cors.Allow(&cors.Options{
//允许访问所有源
AllowAllOrigins: true,
//可选参数"GET", "POST", "PUT", "DELETE", "OPTIONS" (*为所有)
//其中Options跨域复杂请求预检
AllowMethods: []string{"*"},
//指的是允许的Header的种类
//AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Content-Type", "x-requested-with"},
//AllowHeaders: []string{"*"},
AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Content-Type", "X-MMM-DeviceType", "X-MMM-Version", "X-MMM-Timestamp", "X-MMM-Sign", "X-MMM-Uuid", "X-MMM-AccessToken", "X-MMM-AppName", "X-MMM-AppProject"},
//公开的HTTP标头列表
ExposeHeaders: []string{"Content-Length"},
//如果设置,则允许共享身份验证凭据,例如cookie
AllowCredentials: true,
})
return fn
}
... ...
... ... @@ -15,11 +15,12 @@ const RefreshTokenExipre = 3600 * 24 * 30 * 1 //刷新token 一个月过期
//const RefreshTokenExipre = 60 //刷新token
/*Login */
// TODO 判断grantTypePwd校验
type LoginRequest struct {
Phone string `json:"phone" valid:"Required;"`
Password string `json:"password"`
Captcha string `json:"captcha"`
GrantType string `json:"grantType"` // 登录类型 1:密码 2:验证码
GrantType string `json:"grantType" valid:"Required;"` // 登录类型 1:密码 2:验证码
ClientId string `json:"clientId"`
Credentials string `json:"credentials"` //凭证登录
}
... ...