mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-11-10 04:20:26 +08:00
版本认证中增加公司/组织名
This commit is contained in:
@@ -30,7 +30,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// UpdateKey 设置Key
|
// UpdateKey 设置Key
|
||||||
func (this *AuthorityKeyDAO) UpdateKey(tx *dbs.Tx, value string, dayFrom string, dayTo string, hostname string, macAddresses []string) error {
|
func (this *AuthorityKeyDAO) UpdateKey(tx *dbs.Tx, value string, dayFrom string, dayTo string, hostname string, macAddresses []string, company string) error {
|
||||||
one, err := this.Query(tx).
|
one, err := this.Query(tx).
|
||||||
AscPk().
|
AscPk().
|
||||||
Find()
|
Find()
|
||||||
@@ -55,6 +55,7 @@ func (this *AuthorityKeyDAO) UpdateKey(tx *dbs.Tx, value string, dayFrom string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
op.MacAddresses = macAddressesJSON
|
op.MacAddresses = macAddressesJSON
|
||||||
|
op.Company = company
|
||||||
op.UpdatedAt = time.Now().Unix()
|
op.UpdatedAt = time.Now().Unix()
|
||||||
|
|
||||||
return this.Save(tx, op)
|
return this.Save(tx, op)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ type AuthorityKey struct {
|
|||||||
Hostname string `field:"hostname"` // Hostname
|
Hostname string `field:"hostname"` // Hostname
|
||||||
MacAddresses string `field:"macAddresses"` // MAC地址
|
MacAddresses string `field:"macAddresses"` // MAC地址
|
||||||
UpdatedAt uint64 `field:"updatedAt"` // 创建/修改时间
|
UpdatedAt uint64 `field:"updatedAt"` // 创建/修改时间
|
||||||
|
Company string `field:"company"` // 公司组织
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthorityKeyOperator struct {
|
type AuthorityKeyOperator struct {
|
||||||
@@ -19,6 +20,7 @@ type AuthorityKeyOperator struct {
|
|||||||
Hostname interface{} // Hostname
|
Hostname interface{} // Hostname
|
||||||
MacAddresses interface{} // MAC地址
|
MacAddresses interface{} // MAC地址
|
||||||
UpdatedAt interface{} // 创建/修改时间
|
UpdatedAt interface{} // 创建/修改时间
|
||||||
|
Company interface{} // 公司组织
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAuthorityKeyOperator() *AuthorityKeyOperator {
|
func NewAuthorityKeyOperator() *AuthorityKeyOperator {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ func (this *AuthorityKeyService) UpdateAuthorityKey(ctx context.Context, req *pb
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
var tx = this.NullTx()
|
var tx = this.NullTx()
|
||||||
err = authority.SharedAuthorityKeyDAO.UpdateKey(tx, req.Value, req.DayFrom, req.DayTo, req.Hostname, req.MacAddresses)
|
err = authority.SharedAuthorityKeyDAO.UpdateKey(tx, req.Value, req.DayFrom, req.DayTo, req.Hostname, req.MacAddresses, req.Company)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -58,6 +58,7 @@ func (this *AuthorityKeyService) ReadAuthorityKey(ctx context.Context, req *pb.R
|
|||||||
DayTo: key.DayTo,
|
DayTo: key.DayTo,
|
||||||
Hostname: key.Hostname,
|
Hostname: key.Hostname,
|
||||||
MacAddresses: macAddresses,
|
MacAddresses: macAddresses,
|
||||||
|
Company: key.Company,
|
||||||
UpdatedAt: int64(key.UpdatedAt),
|
UpdatedAt: int64(key.UpdatedAt),
|
||||||
}}, nil
|
}}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
|
teaconst "github.com/TeaOSLab/EdgeAPI/internal/const"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
"github.com/TeaOSLab/EdgeAPI/internal/db/models"
|
||||||
|
"github.com/TeaOSLab/EdgeAPI/internal/db/models/authority"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/encrypt"
|
"github.com/TeaOSLab/EdgeAPI/internal/encrypt"
|
||||||
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
"github.com/TeaOSLab/EdgeAPI/internal/errors"
|
||||||
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
rpcutils "github.com/TeaOSLab/EdgeAPI/internal/rpc/utils"
|
||||||
@@ -184,6 +185,8 @@ func (this *BaseService) ValidateNodeId(ctx context.Context, roles ...rpcutils.U
|
|||||||
nodeIntId = 0
|
nodeIntId = 0
|
||||||
case rpcutils.UserTypeMonitor:
|
case rpcutils.UserTypeMonitor:
|
||||||
nodeIntId, err = models.SharedMonitorNodeDAO.FindEnabledMonitorNodeIdWithUniqueId(nil, nodeId)
|
nodeIntId, err = models.SharedMonitorNodeDAO.FindEnabledMonitorNodeIdWithUniqueId(nil, nodeId)
|
||||||
|
case rpcutils.UserTypeAuthority:
|
||||||
|
nodeIntId, err = authority.SharedAuthorityNodeDAO.FindEnabledAuthorityNodeIdWithUniqueId(nil, nodeId)
|
||||||
default:
|
default:
|
||||||
err = errors.New("unsupported user role '" + apiToken.Role + "'")
|
err = errors.New("unsupported user role '" + apiToken.Role + "'")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user