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"
|
"math/big"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/jinzhu/gorm"
|
"github.com/jinzhu/gorm"
|
||||||
|
|
||||||
"github.com/goodrain/rainbond/cmd/api/option"
|
"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
|
return ti, nil
|
||||||
CREATE:
|
CREATE:
|
||||||
token := c.createToken(gt)
|
token := c.createToken(gt)
|
||||||
if !c.APISSL {
|
ti.Token = token
|
||||||
return ti, nil
|
logrus.Debugf("create token %v", token)
|
||||||
}
|
|
||||||
//TODO: ca, key
|
|
||||||
ca, key, err := c.CertDispatcher(gt)
|
|
||||||
if err != nil {
|
|
||||||
return nil, util.CreateAPIHandleError(500, fmt.Errorf("create ca or key error"))
|
|
||||||
}
|
|
||||||
rui := &dbmodel.RegionUserInfo{
|
rui := &dbmodel.RegionUserInfo{
|
||||||
EID: gt.Body.EID,
|
EID: gt.Body.EID,
|
||||||
RegionTag: c.RegionTag,
|
RegionTag: c.RegionTag,
|
||||||
ValidityPeriod: gt.Body.ValidityPeriod,
|
ValidityPeriod: gt.Body.ValidityPeriod,
|
||||||
Token: token,
|
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 == "" {
|
if gt.Body.Range == "" {
|
||||||
rui.APIRange = "source"
|
rui.APIRange = dbmodel.SERVERSOURCE
|
||||||
}
|
}
|
||||||
GetTokenIdenHandler().AddTokenIntoMap(rui)
|
GetTokenIdenHandler().AddTokenIntoMap(rui)
|
||||||
rui.CA = string(ca)
|
|
||||||
rui.Key = string(key)
|
|
||||||
if err := db.GetManager().RegionUserInfoDao().AddModel(rui); err != nil {
|
if err := db.GetManager().RegionUserInfoDao().AddModel(rui); err != nil {
|
||||||
return nil, util.CreateAPIHandleErrorFromDBError("create region user info", err)
|
return nil, util.CreateAPIHandleErrorFromDBError("create region user info", err)
|
||||||
}
|
}
|
||||||
ti.CA = string(ca)
|
|
||||||
ti.Key = string(key)
|
|
||||||
ti.Token = token
|
|
||||||
return ti, nil
|
return ti, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,21 +23,21 @@ package model
|
|||||||
type GetUserToken struct {
|
type GetUserToken struct {
|
||||||
// in: body
|
// in: body
|
||||||
Body struct {
|
Body struct {
|
||||||
//eid
|
// eid
|
||||||
//in: body
|
// in: body
|
||||||
//required: true
|
// required: true
|
||||||
EID string `json:"eid" validate:"eid"`
|
EID string `json:"eid" validate:"eid|required"`
|
||||||
//可控范围
|
// 可控范围
|
||||||
//in: body
|
// in: body
|
||||||
//required: false
|
// required: false
|
||||||
Range string `json:"range" validate:"range"`
|
Range string `json:"range" validate:"range"`
|
||||||
//有效期
|
// 有效期
|
||||||
//in: body
|
// in: body
|
||||||
//required: true
|
// required: true
|
||||||
ValidityPeriod int `json:"validity_period" validate:"validity_period|required"` //20191120
|
ValidityPeriod int `json:"validity_period" validate:"validity_period|required"` //1549812345
|
||||||
//数据中心标识
|
// 数据中心标识
|
||||||
//in: body
|
// in: body
|
||||||
//required: true
|
// required: true
|
||||||
RegionTag string `json:"region_tag" validate:"region_tag"`
|
RegionTag string `json:"region_tag" validate:"region_tag"`
|
||||||
BeforeTime int `json:"before_time"`
|
BeforeTime int `json:"before_time"`
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user