1270a93274
Main Changes: • method signature updates everywhere to account for passing around enterprise meta. • populate the EnterpriseAuthorizerContext for all ACL related authorizations. • ACL resource listings now operate like the catalog or kv listings in that the returned entries are filtered down to what the token is allowed to see. With Namespaces its no longer all or nothing. • Modified the acl.Policy parsing to abstract away basic decoding so that enterprise can do it slightly differently. Also updated method signatures so that when parsing a policy it can take extra ent metadata to use during rules validation and policy creation. Secondary Changes: • Moved protobuf encoding functions out of the agentpb package to eliminate circular dependencies. • Added custom JSON unmarshalers for a few ACL resource types (to support snake case and to get rid of mapstructure) • AuthMethod validator cache is now an interface as these will be cached per-namespace for Consul Enterprise. • Added checks for policy/role link existence at the RPC API so we don’t push the request through raft to have it fail internally. • Forward ACL token delete request to the primary datacenter when the secondary DC doesn’t have the token. • Added a bunch of ACL test helpers for inserting ACL resource test data.
39 lines
720 B
Go
39 lines
720 B
Go
// +build !consulent
|
|
|
|
package authmethod
|
|
|
|
import (
|
|
"sync"
|
|
|
|
"github.com/hashicorp/consul/agent/structs"
|
|
)
|
|
|
|
type syncCache struct {
|
|
lock sync.RWMutex
|
|
cache authMethodCache
|
|
}
|
|
|
|
func NewCache() Cache {
|
|
c := &syncCache{}
|
|
c.cache.init()
|
|
return c
|
|
}
|
|
|
|
func (c *syncCache) GetValidator(method *structs.ACLAuthMethod) (uint64, Validator, bool) {
|
|
c.lock.RLock()
|
|
defer c.lock.RUnlock()
|
|
return c.cache.GetValidator(method)
|
|
}
|
|
|
|
func (c *syncCache) PutValidatorIfNewer(method *structs.ACLAuthMethod, validator Validator, idx uint64) Validator {
|
|
c.lock.Lock()
|
|
defer c.lock.Unlock()
|
|
return c.cache.PutValidatorIfNewer(method, validator, idx)
|
|
}
|
|
|
|
func (c *syncCache) Purge() {
|
|
c.lock.Lock()
|
|
c.cache.Purge()
|
|
c.lock.Unlock()
|
|
}
|