修改: 在organization中添加Acl相关字段;AclRules和SSHPolicy不保存db,由ACLPolicy生成;减少重复查询,添加organization local缓存

This commit is contained in:
chuanh
2023-03-17 09:25:08 +00:00
parent 0fb15f2683
commit 8acfb5f5b2
10 changed files with 350 additions and 64 deletions
+11 -2
View File
@@ -72,7 +72,16 @@ func (h *Mirage) generateMapResponse(
)
now := time.Now()
org, err := h.GetOrgnaizationByName(machine.User.OrgName)
if err != nil {
log.Error().
Caller().
Str("func", "generateMapResponse").
Err(err).
Msg("Failed to get organization of machine")
return nil, err
}
resp := tailcfg.MapResponse{
KeepAlive: false,
Node: node,
@@ -102,12 +111,12 @@ func (h *Mirage) generateMapResponse(
CollectServices: "false",
// TODO: Only send if updated
PacketFilter: h.aclRules,
PacketFilter: org.AclRules,
UserProfiles: profiles,
// TODO: Only send if updated
SSHPolicy: h.sshPolicy,
SSHPolicy: org.SshPolicy,
ControlTime: &now,