mirror of https://github.com/hashicorp/consul
consul: rename function to avoid collision and clean up
parent
6623538c93
commit
d217c25668
|
@ -309,10 +309,10 @@ func (f *aclFilter) filterNodeDump(dump *structs.NodeDump) {
|
|||
}
|
||||
}
|
||||
|
||||
// aclFilter is used to filter results from our service catalog based on the
|
||||
// filterACL is used to filter results from our service catalog based on the
|
||||
// rules configured for the provided token. The subject is scrubbed and
|
||||
// modified in-place, leaving only resources the token can access.
|
||||
func (s *Server) aclFilter(token string, subj interface{}) error {
|
||||
func (s *Server) filterACL(token string, subj interface{}) error {
|
||||
// Get the ACL from the token
|
||||
acl, err := s.resolveToken(token)
|
||||
if err != nil {
|
||||
|
|
|
@ -126,7 +126,7 @@ func (c *Catalog) ListNodes(args *structs.DCSpecificRequest, reply *structs.Inde
|
|||
state.QueryTables("Nodes"),
|
||||
func() error {
|
||||
reply.Index, reply.Nodes = state.Nodes()
|
||||
return c.srv.aclFilter(args.Token, reply)
|
||||
return c.srv.filterACL(args.Token, reply)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ func (c *Catalog) ListServices(args *structs.DCSpecificRequest, reply *structs.I
|
|||
state.QueryTables("Services"),
|
||||
func() error {
|
||||
reply.Index, reply.Services = state.Services()
|
||||
return c.srv.aclFilter(args.Token, reply)
|
||||
return c.srv.filterACL(args.Token, reply)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -169,7 +169,7 @@ func (c *Catalog) ServiceNodes(args *structs.ServiceSpecificRequest, reply *stru
|
|||
} else {
|
||||
reply.Index, reply.ServiceNodes = state.ServiceNodes(args.ServiceName)
|
||||
}
|
||||
return c.srv.aclFilter(args.Token, reply)
|
||||
return c.srv.filterACL(args.Token, reply)
|
||||
})
|
||||
|
||||
// Provide some metrics
|
||||
|
@ -203,6 +203,6 @@ func (c *Catalog) NodeServices(args *structs.NodeSpecificRequest, reply *structs
|
|||
state.QueryTables("NodeServices"),
|
||||
func() error {
|
||||
reply.Index, reply.NodeServices = state.NodeServices(args.Node)
|
||||
return c.srv.aclFilter(args.Token, reply)
|
||||
return c.srv.filterACL(args.Token, reply)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -778,7 +778,7 @@ func TestCatalogRegister_FailedCase1(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestCatalog_applyDiscoveryACLs(t *testing.T) {
|
||||
func TestCatalog_filterACL(t *testing.T) {
|
||||
dir, srv := testServerWithConfig(t, func(c *Config) {
|
||||
c.ACLDatacenter = "dc1"
|
||||
c.ACLMasterToken = "root"
|
||||
|
|
|
@ -43,7 +43,7 @@ func (h *Health) NodeChecks(args *structs.NodeSpecificRequest,
|
|||
state.QueryTables("NodeChecks"),
|
||||
func() error {
|
||||
reply.Index, reply.HealthChecks = state.NodeChecks(args.Node)
|
||||
return h.srv.aclFilter(args.Token, reply)
|
||||
return h.srv.filterACL(args.Token, reply)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ func (h *Health) ServiceChecks(args *structs.ServiceSpecificRequest,
|
|||
state.QueryTables("ServiceChecks"),
|
||||
func() error {
|
||||
reply.Index, reply.HealthChecks = state.ServiceChecks(args.ServiceName)
|
||||
return h.srv.aclFilter(args.Token, reply)
|
||||
return h.srv.filterACL(args.Token, reply)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ func (h *Health) ServiceNodes(args *structs.ServiceSpecificRequest, reply *struc
|
|||
} else {
|
||||
reply.Index, reply.Nodes = state.CheckServiceNodes(args.ServiceName)
|
||||
}
|
||||
return h.srv.aclFilter(args.Token, reply)
|
||||
return h.srv.filterACL(args.Token, reply)
|
||||
})
|
||||
|
||||
// Provide some metrics
|
||||
|
|
|
@ -223,7 +223,7 @@ func TestHealth_ServiceNodes(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestHealth_applyDiscoveryACLs(t *testing.T) {
|
||||
func TestHealth_filterACL(t *testing.T) {
|
||||
dir, srv := testServerWithConfig(t, func(c *Config) {
|
||||
c.ACLDatacenter = "dc1"
|
||||
c.ACLMasterToken = "root"
|
||||
|
|
|
@ -25,12 +25,8 @@ func (m *Internal) NodeInfo(args *structs.NodeSpecificRequest,
|
|||
&reply.QueryMeta,
|
||||
state.QueryTables("NodeInfo"),
|
||||
func() error {
|
||||
index, dump := state.NodeInfo(args.Node)
|
||||
if err := m.srv.aclFilter(args.Token, &dump); err != nil {
|
||||
return err
|
||||
}
|
||||
reply.Index, reply.Dump = index, dump
|
||||
return nil
|
||||
reply.Index, reply.Dump = state.NodeInfo(args.Node)
|
||||
return m.srv.filterACL(args.Token, reply)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -47,12 +43,8 @@ func (m *Internal) NodeDump(args *structs.DCSpecificRequest,
|
|||
&reply.QueryMeta,
|
||||
state.QueryTables("NodeDump"),
|
||||
func() error {
|
||||
index, dump := state.NodeDump()
|
||||
if err := m.srv.aclFilter(args.Token, &dump); err != nil {
|
||||
return err
|
||||
}
|
||||
reply.Index, reply.Dump = index, dump
|
||||
return nil
|
||||
reply.Index, reply.Dump = state.NodeDump()
|
||||
return m.srv.filterACL(args.Token, reply)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue