Browse Source

acl: pass PartitionInfo through ent ACLConfig

pull/11433/head
Kyle Havlovitz 3 years ago committed by freddygv
parent
commit
65c9109396
  1. 5
      acl/acl.go
  2. 8
      agent/consul/acl.go
  3. 8
      agent/consul/acl_oss.go
  4. 2
      agent/consul/client.go
  5. 3
      agent/consul/server.go

5
acl/acl.go

@ -14,6 +14,11 @@ type Config struct {
EnterpriseConfig
}
type PartitionExportInfo interface {
// DownstreamPartitions returns the list of partitions the given service has been exported to.
DownstreamPartitions(service string, ctx *AuthorizerContext) []string
}
// GetWildcardName will retrieve the configured wildcard name or provide a default
// in the case that the config is Nil or the wildcard name is unset.
func (c *Config) GetWildcardName() string {

8
agent/consul/acl.go

@ -1094,7 +1094,7 @@ func (r *ACLResolver) ResolveTokenToIdentityAndAuthorizer(token string) (structs
if r.aclConf != nil {
conf = *r.aclConf
}
conf.LocalPartition = identity.EnterpriseMetadata().PartitionOrDefault()
r.setEnterpriseConf(identity, &conf)
authz, err := policies.Compile(r.cache, &conf)
if err != nil {
@ -1900,3 +1900,9 @@ func filterACL(r *ACLResolver, token string, subj interface{}) error {
filterACLWithAuthorizer(r.logger, authorizer, subj)
return nil
}
type partitionInfoNoop struct{}
func (p *partitionInfoNoop) DownstreamPartitions(service string, ctx *acl.AuthorizerContext) []string {
return []string{}
}

8
agent/consul/acl_oss.go

@ -15,7 +15,11 @@ func (s *Server) replicationEnterpriseMeta() *structs.EnterpriseMeta {
return structs.ReplicationEnterpriseMeta()
}
func newACLConfig(hclog.Logger) *acl.Config {
func serverPartitionInfo(s *Server) acl.PartitionExportInfo {
return &partitionInfoNoop{}
}
func newACLConfig(_ acl.PartitionExportInfo, hclog.Logger) *acl.Config {
return &acl.Config{
WildcardName: structs.WildcardSpecifier,
}
@ -41,3 +45,5 @@ func (_ *ACLResolver) resolveEnterpriseIdentityAndPolicies(_ structs.ACLIdentity
func (_ *ACLResolver) resolveLocallyManagedEnterpriseToken(_ string) (structs.ACLIdentity, acl.Authorizer, bool) {
return nil, nil, false
}
func (_ *ACLResolver) setEnterpriseConf(identity structs.ACLIdentity, conf *acl.Config) {}

2
agent/consul/client.go

@ -123,7 +123,7 @@ func NewClient(config *Config, deps Deps) (*Client, error) {
Logger: c.logger,
DisableDuration: aclClientDisabledTTL,
CacheConfig: clientACLCacheConfig,
ACLConfig: newACLConfig(c.logger),
ACLConfig: newACLConfig(&partitionInfoNoop{}, c.logger),
Tokens: deps.Tokens,
}
var err error

3
agent/consul/server.go

@ -427,7 +427,8 @@ func NewServer(config *Config, flat Deps) (*Server, error) {
// Initialize the stats fetcher that autopilot will use.
s.statsFetcher = NewStatsFetcher(logger, s.connPool, s.config.Datacenter)
s.aclConfig = newACLConfig(logger)
partitionInfo := serverPartitionInfo(s)
s.aclConfig = newACLConfig(partitionInfo, logger)
aclConfig := ACLResolverConfig{
Config: config.ACLResolverSettings,
Delegate: s,

Loading…
Cancel
Save