mirror of
https://gitee.com/rainbond/Rainbond.git
synced 2024-11-30 02:38:17 +08:00
[REV]Update eid get
This commit is contained in:
parent
5f7f63ae42
commit
9c5764a3c1
@ -31,6 +31,7 @@ import (
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"github.com/Sirupsen/logrus"
|
||||
"github.com/jinzhu/gorm"
|
||||
|
||||
"github.com/goodrain/rainbond/cmd/api/option"
|
||||
@ -78,32 +79,31 @@ func (c *CloudAction) TokenDispatcher(gt *api_model.GetUserToken) (*api_model.To
|
||||
return ti, nil
|
||||
CREATE:
|
||||
token := c.createToken(gt)
|
||||
if !c.APISSL {
|
||||
return ti, nil
|
||||
}
|
||||
//TODO: ca, key
|
||||
ca, key, err := c.CertDispatcher(gt)
|
||||
if err != nil {
|
||||
return nil, util.CreateAPIHandleError(500, fmt.Errorf("create ca or key error"))
|
||||
}
|
||||
ti.Token = token
|
||||
logrus.Debugf("create token %v", token)
|
||||
rui := &dbmodel.RegionUserInfo{
|
||||
EID: gt.Body.EID,
|
||||
RegionTag: c.RegionTag,
|
||||
ValidityPeriod: gt.Body.ValidityPeriod,
|
||||
Token: token,
|
||||
}
|
||||
if c.APISSL {
|
||||
ca, key, err := c.CertDispatcher(gt)
|
||||
if err != nil {
|
||||
return nil, util.CreateAPIHandleError(500, fmt.Errorf("create ca or key error"))
|
||||
}
|
||||
rui.CA = string(ca)
|
||||
rui.Key = string(key)
|
||||
ti.CA = string(ca)
|
||||
ti.Key = string(key)
|
||||
}
|
||||
if gt.Body.Range == "" {
|
||||
rui.APIRange = "source"
|
||||
rui.APIRange = dbmodel.SERVERSOURCE
|
||||
}
|
||||
GetTokenIdenHandler().AddTokenIntoMap(rui)
|
||||
rui.CA = string(ca)
|
||||
rui.Key = string(key)
|
||||
if err := db.GetManager().RegionUserInfoDao().AddModel(rui); err != nil {
|
||||
return nil, util.CreateAPIHandleErrorFromDBError("create region user info", err)
|
||||
}
|
||||
ti.CA = string(ca)
|
||||
ti.Key = string(key)
|
||||
ti.Token = token
|
||||
return ti, nil
|
||||
}
|
||||
|
||||
|
@ -23,21 +23,21 @@ package model
|
||||
type GetUserToken struct {
|
||||
// in: body
|
||||
Body struct {
|
||||
//eid
|
||||
//in: body
|
||||
//required: true
|
||||
EID string `json:"eid" validate:"eid"`
|
||||
//可控范围
|
||||
//in: body
|
||||
//required: false
|
||||
// eid
|
||||
// in: body
|
||||
// required: true
|
||||
EID string `json:"eid" validate:"eid|required"`
|
||||
// 可控范围
|
||||
// in: body
|
||||
// required: false
|
||||
Range string `json:"range" validate:"range"`
|
||||
//有效期
|
||||
//in: body
|
||||
//required: true
|
||||
ValidityPeriod int `json:"validity_period" validate:"validity_period|required"` //20191120
|
||||
//数据中心标识
|
||||
//in: body
|
||||
//required: true
|
||||
// 有效期
|
||||
// in: body
|
||||
// required: true
|
||||
ValidityPeriod int `json:"validity_period" validate:"validity_period|required"` //1549812345
|
||||
// 数据中心标识
|
||||
// in: body
|
||||
// required: true
|
||||
RegionTag string `json:"region_tag" validate:"region_tag"`
|
||||
BeforeTime int `json:"before_time"`
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user