2014-08-06 22:08:17 +00:00
|
|
|
package acl
|
|
|
|
|
|
|
|
import (
|
2018-07-24 20:37:01 +00:00
|
|
|
"fmt"
|
2014-08-06 22:08:17 +00:00
|
|
|
"testing"
|
2018-07-24 20:37:01 +00:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2014-08-06 22:08:17 +00:00
|
|
|
)
|
|
|
|
|
2018-10-19 16:04:07 +00:00
|
|
|
func legacyPolicy(policy *Policy) *Policy {
|
|
|
|
return &Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Agents: policy.Agents,
|
|
|
|
AgentPrefixes: policy.Agents,
|
|
|
|
Nodes: policy.Nodes,
|
|
|
|
NodePrefixes: policy.Nodes,
|
|
|
|
Keys: policy.Keys,
|
|
|
|
KeyPrefixes: policy.Keys,
|
|
|
|
Services: policy.Services,
|
|
|
|
ServicePrefixes: policy.Services,
|
|
|
|
Sessions: policy.Sessions,
|
|
|
|
SessionPrefixes: policy.Sessions,
|
|
|
|
Events: policy.Events,
|
|
|
|
EventPrefixes: policy.Events,
|
|
|
|
PreparedQueries: policy.PreparedQueries,
|
|
|
|
PreparedQueryPrefixes: policy.PreparedQueries,
|
|
|
|
Keyring: policy.Keyring,
|
|
|
|
Operator: policy.Operator,
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-24 20:37:01 +00:00
|
|
|
//
|
|
|
|
// The following 1 line functions are created to all conform to what
|
|
|
|
// can be stored in the aclCheck type to make defining ACL tests
|
|
|
|
// nicer in the embedded struct within TestACL
|
|
|
|
//
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowACLRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.ACLRead(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowACLWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.ACLWrite(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowAgentRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.AgentRead(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowAgentWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.AgentWrite(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowEventRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.EventRead(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowEventWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.EventWrite(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowIntentionDefaultAllow(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.IntentionDefaultAllow(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowIntentionRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.IntentionRead(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowIntentionWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.IntentionWrite(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowKeyRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.KeyRead(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowKeyList(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.KeyList(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowKeyringRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.KeyringRead(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowKeyringWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.KeyringWrite(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowKeyWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.KeyWrite(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowKeyWritePrefix(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.KeyWritePrefix(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowNodeRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.NodeRead(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2020-11-04 18:50:03 +00:00
|
|
|
func checkAllowNodeReadAll(t *testing.T, authz Authorizer, _ string, entCtx *AuthorizerContext) {
|
|
|
|
require.Equal(t, Allow, authz.NodeReadAll(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowNodeWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.NodeWrite(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowOperatorRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.OperatorRead(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowOperatorWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.OperatorWrite(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowPreparedQueryRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.PreparedQueryRead(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowPreparedQueryWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.PreparedQueryWrite(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowServiceRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.ServiceRead(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2020-11-04 18:50:03 +00:00
|
|
|
func checkAllowServiceReadAll(t *testing.T, authz Authorizer, _ string, entCtx *AuthorizerContext) {
|
|
|
|
require.Equal(t, Allow, authz.ServiceReadAll(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowServiceWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.ServiceWrite(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowSessionRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.SessionRead(prefix, entCtx))
|
2014-08-12 17:35:27 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowSessionWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.SessionWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
2014-08-06 22:08:17 +00:00
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkAllowSnapshot(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Allow, authz.Snapshot(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
2014-08-06 22:08:17 +00:00
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyACLRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.ACLRead(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
2014-08-12 22:09:01 +00:00
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyACLWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.ACLWrite(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
2016-12-02 04:31:50 +00:00
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyAgentRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.AgentRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
2016-12-02 04:31:50 +00:00
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyAgentWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.AgentWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyEventRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.EventRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyEventWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.EventWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyIntentionDefaultAllow(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.IntentionDefaultAllow(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyIntentionRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.IntentionRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyIntentionWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.IntentionWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyKeyRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.KeyRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyKeyList(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.KeyList(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyKeyringRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.KeyringRead(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyKeyringWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.KeyringWrite(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyKeyWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.KeyWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyKeyWritePrefix(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.KeyWritePrefix(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyNodeRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.NodeRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 18:50:03 +00:00
|
|
|
func checkDenyNodeReadAll(t *testing.T, authz Authorizer, _ string, entCtx *AuthorizerContext) {
|
|
|
|
require.Equal(t, Deny, authz.NodeReadAll(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyNodeWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.NodeWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyOperatorRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.OperatorRead(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyOperatorWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.OperatorWrite(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyPreparedQueryRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.PreparedQueryRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyPreparedQueryWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.PreparedQueryWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyServiceRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.ServiceRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 18:50:03 +00:00
|
|
|
func checkDenyServiceReadAll(t *testing.T, authz Authorizer, _ string, entCtx *AuthorizerContext) {
|
|
|
|
require.Equal(t, Deny, authz.ServiceReadAll(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenyServiceWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.ServiceWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenySessionRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.SessionRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenySessionWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.SessionWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDenySnapshot(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Deny, authz.Snapshot(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultACLRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.ACLRead(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultACLWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.ACLWrite(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultAgentRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.AgentRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultAgentWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.AgentWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultEventRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.EventRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultEventWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.EventWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultIntentionDefaultAllow(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.IntentionDefaultAllow(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultIntentionRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.IntentionRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultIntentionWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.IntentionWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultKeyRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.KeyRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultKeyList(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.KeyList(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultKeyringRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.KeyringRead(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultKeyringWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.KeyringWrite(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultKeyWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.KeyWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultKeyWritePrefix(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.KeyWritePrefix(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultNodeRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.NodeRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 18:50:03 +00:00
|
|
|
func checkDefaultNodeReadAll(t *testing.T, authz Authorizer, _ string, entCtx *AuthorizerContext) {
|
|
|
|
require.Equal(t, Default, authz.NodeReadAll(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultNodeWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.NodeWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultOperatorRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.OperatorRead(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultOperatorWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.OperatorWrite(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultPreparedQueryRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.PreparedQueryRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultPreparedQueryWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.PreparedQueryWrite(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultServiceRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.ServiceRead(prefix, entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2020-11-04 18:50:03 +00:00
|
|
|
func checkDefaultServiceReadAll(t *testing.T, authz Authorizer, _ string, entCtx *AuthorizerContext) {
|
|
|
|
require.Equal(t, Default, authz.ServiceReadAll(entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultServiceWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.ServiceWrite(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultSessionRead(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.SessionRead(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultSessionWrite(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.SessionWrite(prefix, entCtx))
|
|
|
|
}
|
|
|
|
|
2019-12-18 18:43:24 +00:00
|
|
|
func checkDefaultSnapshot(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, Default, authz.Snapshot(entCtx))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestACL(t *testing.T) {
|
|
|
|
type aclCheck struct {
|
|
|
|
name string
|
|
|
|
prefix string
|
2019-12-18 18:43:24 +00:00
|
|
|
check func(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext)
|
2016-12-13 04:20:28 +00:00
|
|
|
}
|
2018-07-24 20:37:01 +00:00
|
|
|
|
|
|
|
type aclTest struct {
|
|
|
|
name string
|
2018-10-19 16:04:07 +00:00
|
|
|
defaultPolicy Authorizer
|
2018-07-24 20:37:01 +00:00
|
|
|
policyStack []*Policy
|
|
|
|
checks []aclCheck
|
2016-10-26 02:20:24 +00:00
|
|
|
}
|
2014-08-06 22:08:17 +00:00
|
|
|
|
2018-07-24 20:37:01 +00:00
|
|
|
tests := []aclTest{
|
|
|
|
{
|
|
|
|
name: "DenyAll",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
checks: []aclCheck{
|
2018-10-19 16:04:07 +00:00
|
|
|
{name: "DenyACLRead", check: checkDenyACLRead},
|
|
|
|
{name: "DenyACLWrite", check: checkDenyACLWrite},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "DenyAgentRead", check: checkDenyAgentRead},
|
|
|
|
{name: "DenyAgentWrite", check: checkDenyAgentWrite},
|
|
|
|
{name: "DenyEventRead", check: checkDenyEventRead},
|
|
|
|
{name: "DenyEventWrite", check: checkDenyEventWrite},
|
|
|
|
{name: "DenyIntentionDefaultAllow", check: checkDenyIntentionDefaultAllow},
|
|
|
|
{name: "DenyIntentionRead", check: checkDenyIntentionRead},
|
|
|
|
{name: "DenyIntentionWrite", check: checkDenyIntentionWrite},
|
|
|
|
{name: "DenyKeyRead", check: checkDenyKeyRead},
|
|
|
|
{name: "DenyKeyringRead", check: checkDenyKeyringRead},
|
|
|
|
{name: "DenyKeyringWrite", check: checkDenyKeyringWrite},
|
|
|
|
{name: "DenyKeyWrite", check: checkDenyKeyWrite},
|
|
|
|
{name: "DenyNodeRead", check: checkDenyNodeRead},
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "DenyNodeReadAll", check: checkDenyNodeReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "DenyNodeWrite", check: checkDenyNodeWrite},
|
|
|
|
{name: "DenyOperatorRead", check: checkDenyOperatorRead},
|
|
|
|
{name: "DenyOperatorWrite", check: checkDenyOperatorWrite},
|
|
|
|
{name: "DenyPreparedQueryRead", check: checkDenyPreparedQueryRead},
|
|
|
|
{name: "DenyPreparedQueryWrite", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "DenyServiceRead", check: checkDenyServiceRead},
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "DenyServiceReadAll", check: checkDenyServiceReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "DenyServiceWrite", check: checkDenyServiceWrite},
|
|
|
|
{name: "DenySessionRead", check: checkDenySessionRead},
|
|
|
|
{name: "DenySessionWrite", check: checkDenySessionWrite},
|
|
|
|
{name: "DenySnapshot", check: checkDenySnapshot},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AllowAll",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
checks: []aclCheck{
|
2018-10-19 16:04:07 +00:00
|
|
|
{name: "DenyACLRead", check: checkDenyACLRead},
|
|
|
|
{name: "DenyACLWrite", check: checkDenyACLWrite},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "AllowAgentRead", check: checkAllowAgentRead},
|
|
|
|
{name: "AllowAgentWrite", check: checkAllowAgentWrite},
|
|
|
|
{name: "AllowEventRead", check: checkAllowEventRead},
|
|
|
|
{name: "AllowEventWrite", check: checkAllowEventWrite},
|
|
|
|
{name: "AllowIntentionDefaultAllow", check: checkAllowIntentionDefaultAllow},
|
|
|
|
{name: "AllowIntentionRead", check: checkAllowIntentionRead},
|
|
|
|
{name: "AllowIntentionWrite", check: checkAllowIntentionWrite},
|
|
|
|
{name: "AllowKeyRead", check: checkAllowKeyRead},
|
|
|
|
{name: "AllowKeyringRead", check: checkAllowKeyringRead},
|
|
|
|
{name: "AllowKeyringWrite", check: checkAllowKeyringWrite},
|
|
|
|
{name: "AllowKeyWrite", check: checkAllowKeyWrite},
|
|
|
|
{name: "AllowNodeRead", check: checkAllowNodeRead},
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "AllowNodeReadAll", check: checkAllowNodeReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "AllowNodeWrite", check: checkAllowNodeWrite},
|
|
|
|
{name: "AllowOperatorRead", check: checkAllowOperatorRead},
|
|
|
|
{name: "AllowOperatorWrite", check: checkAllowOperatorWrite},
|
|
|
|
{name: "AllowPreparedQueryRead", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "AllowPreparedQueryWrite", check: checkAllowPreparedQueryWrite},
|
|
|
|
{name: "AllowServiceRead", check: checkAllowServiceRead},
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "AllowServiceReadAll", check: checkAllowServiceReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "AllowServiceWrite", check: checkAllowServiceWrite},
|
|
|
|
{name: "AllowSessionRead", check: checkAllowSessionRead},
|
|
|
|
{name: "AllowSessionWrite", check: checkAllowSessionWrite},
|
|
|
|
{name: "DenySnapshot", check: checkDenySnapshot},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "ManageAll",
|
|
|
|
defaultPolicy: ManageAll(),
|
|
|
|
checks: []aclCheck{
|
2018-10-19 16:04:07 +00:00
|
|
|
{name: "AllowACLRead", check: checkAllowACLRead},
|
|
|
|
{name: "AllowACLWrite", check: checkAllowACLWrite},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "AllowAgentRead", check: checkAllowAgentRead},
|
|
|
|
{name: "AllowAgentWrite", check: checkAllowAgentWrite},
|
|
|
|
{name: "AllowEventRead", check: checkAllowEventRead},
|
|
|
|
{name: "AllowEventWrite", check: checkAllowEventWrite},
|
|
|
|
{name: "AllowIntentionDefaultAllow", check: checkAllowIntentionDefaultAllow},
|
|
|
|
{name: "AllowIntentionRead", check: checkAllowIntentionRead},
|
|
|
|
{name: "AllowIntentionWrite", check: checkAllowIntentionWrite},
|
|
|
|
{name: "AllowKeyRead", check: checkAllowKeyRead},
|
|
|
|
{name: "AllowKeyringRead", check: checkAllowKeyringRead},
|
|
|
|
{name: "AllowKeyringWrite", check: checkAllowKeyringWrite},
|
|
|
|
{name: "AllowKeyWrite", check: checkAllowKeyWrite},
|
|
|
|
{name: "AllowNodeRead", check: checkAllowNodeRead},
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "AllowNodeReadAll", check: checkAllowNodeReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "AllowNodeWrite", check: checkAllowNodeWrite},
|
|
|
|
{name: "AllowOperatorRead", check: checkAllowOperatorRead},
|
|
|
|
{name: "AllowOperatorWrite", check: checkAllowOperatorWrite},
|
|
|
|
{name: "AllowPreparedQueryRead", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "AllowPreparedQueryWrite", check: checkAllowPreparedQueryWrite},
|
|
|
|
{name: "AllowServiceRead", check: checkAllowServiceRead},
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "AllowServiceReadAll", check: checkAllowServiceReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "AllowServiceWrite", check: checkAllowServiceWrite},
|
|
|
|
{name: "AllowSessionRead", check: checkAllowSessionRead},
|
|
|
|
{name: "AllowSessionWrite", check: checkAllowSessionWrite},
|
|
|
|
{name: "AllowSnapshot", check: checkAllowSnapshot},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "AgentBasicDefaultDeny",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Agents: []*AgentRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "DefaultReadDenied", prefix: "ro", check: checkDenyAgentRead},
|
|
|
|
{name: "DefaultWriteDenied", prefix: "ro", check: checkDenyAgentWrite},
|
|
|
|
{name: "ROReadAllowed", prefix: "root", check: checkAllowAgentRead},
|
|
|
|
{name: "ROWriteDenied", prefix: "root", check: checkDenyAgentWrite},
|
|
|
|
{name: "ROSuffixReadAllowed", prefix: "root-ro", check: checkAllowAgentRead},
|
|
|
|
{name: "ROSuffixWriteDenied", prefix: "root-ro", check: checkDenyAgentWrite},
|
|
|
|
{name: "RWReadAllowed", prefix: "root-rw", check: checkAllowAgentRead},
|
|
|
|
{name: "RWWriteDenied", prefix: "root-rw", check: checkAllowAgentWrite},
|
|
|
|
{name: "RWSuffixReadAllowed", prefix: "root-rw-sub", check: checkAllowAgentRead},
|
|
|
|
{name: "RWSuffixWriteAllowed", prefix: "root-rw-sub", check: checkAllowAgentWrite},
|
|
|
|
{name: "DenyReadDenied", prefix: "root-nope", check: checkDenyAgentRead},
|
|
|
|
{name: "DenyWriteDenied", prefix: "root-nope", check: checkDenyAgentWrite},
|
|
|
|
{name: "DenySuffixReadDenied", prefix: "root-nope-sub", check: checkDenyAgentRead},
|
|
|
|
{name: "DenySuffixWriteDenied", prefix: "root-nope-sub", check: checkDenyAgentWrite},
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AgentBasicDefaultAllow",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Agents: []*AgentRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "DefaultReadDenied", prefix: "ro", check: checkAllowAgentRead},
|
|
|
|
{name: "DefaultWriteDenied", prefix: "ro", check: checkAllowAgentWrite},
|
|
|
|
{name: "ROReadAllowed", prefix: "root", check: checkAllowAgentRead},
|
|
|
|
{name: "ROWriteDenied", prefix: "root", check: checkDenyAgentWrite},
|
|
|
|
{name: "ROSuffixReadAllowed", prefix: "root-ro", check: checkAllowAgentRead},
|
|
|
|
{name: "ROSuffixWriteDenied", prefix: "root-ro", check: checkDenyAgentWrite},
|
|
|
|
{name: "RWReadAllowed", prefix: "root-rw", check: checkAllowAgentRead},
|
|
|
|
{name: "RWWriteDenied", prefix: "root-rw", check: checkAllowAgentWrite},
|
|
|
|
{name: "RWSuffixReadAllowed", prefix: "root-rw-sub", check: checkAllowAgentRead},
|
|
|
|
{name: "RWSuffixWriteAllowed", prefix: "root-rw-sub", check: checkAllowAgentWrite},
|
|
|
|
{name: "DenyReadDenied", prefix: "root-nope", check: checkDenyAgentRead},
|
|
|
|
{name: "DenyWriteDenied", prefix: "root-nope", check: checkDenyAgentWrite},
|
|
|
|
{name: "DenySuffixReadDenied", prefix: "root-nope-sub", check: checkDenyAgentRead},
|
|
|
|
{name: "DenySuffixWriteDenied", prefix: "root-nope-sub", check: checkDenyAgentWrite},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "PreparedQueryDefaultAllow",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
PreparedQueries: []*PreparedQueryRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "other",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
// in version 1.2.1 and below this would have failed
|
|
|
|
{name: "ReadAllowed", prefix: "foo", check: checkAllowPreparedQueryRead},
|
|
|
|
// in version 1.2.1 and below this would have failed
|
|
|
|
{name: "WriteAllowed", prefix: "foo", check: checkAllowPreparedQueryWrite},
|
|
|
|
{name: "ReadDenied", prefix: "other", check: checkDenyPreparedQueryRead},
|
|
|
|
{name: "WriteDenied", prefix: "other", check: checkDenyPreparedQueryWrite},
|
2017-10-02 22:10:21 +00:00
|
|
|
},
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "AgentNestedDefaultDeny",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Agents: []*AgentRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "override",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Agents: []*AgentRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "override",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
Creates new "prepared-query" ACL type and new token capture behavior.
Prior to this change, prepared queries had the following behavior for
ACLs, which will need to change to support templates:
1. A management token, or a token with read access to the service being
queried needed to be provided in order to create a prepared query.
2. The token used to create the prepared query was stored with the query
in the state store and used to execute the query.
3. A management token, or the token used to create the query needed to be
supplied to perform and CRUD operations on an existing prepared query.
This was pretty subtle and complicated behavior, and won't work for
templates since the service name is computed at execution time. To solve
this, we introduce a new "prepared-query" ACL type, where the prefix
applies to the query name for static prepared query types and to the
prefix for template prepared query types.
With this change, the new behavior is:
1. A management token, or a token with "prepared-query" write access to
the query name or (soon) the given template prefix is required to do
any CRUD operations on a prepared query, or to list prepared queries
(the list is filtered by this ACL).
2. You will no longer need a management token to list prepared queries,
but you will only be able to see prepared queries that you have access
to (you get an empty list instead of permission denied).
3. When listing or getting a query, because it was easy to capture
management tokens given the past behavior, this will always blank out
the "Token" field (replacing the contents as <hidden>) for all tokens
unless a management token is supplied. Going forward, we should
discourage people from binding tokens for execution unless strictly
necessary.
4. No token will be captured by default when a prepared query is created.
If the user wishes to supply an execution token then can pass it in via
the "Token" field in the prepared query definition. Otherwise, this
field will default to empty.
5. At execution time, we will use the captured token if it exists with the
prepared query definition, otherwise we will use the token that's passed
in with the request, just like we do for other RPCs (or you can use the
agent's configured token for DNS).
6. Prepared queries with no name (accessible only by ID) will not require
ACLs to create or modify (execution time will depend on the service ACL
configuration). Our argument here is that these are designed to be
ephemeral and the IDs are as good as an ACL. Management tokens will be
able to list all of these.
These changes enable templates, but also enable delegation of authority to
manage the prepared query namespace.
2016-02-23 08:12:58 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "DefaultReadDenied", prefix: "nope", check: checkDenyAgentRead},
|
|
|
|
{name: "DefaultWriteDenied", prefix: "nope", check: checkDenyAgentWrite},
|
|
|
|
{name: "DenyReadDenied", prefix: "root-nope", check: checkDenyAgentRead},
|
|
|
|
{name: "DenyWriteDenied", prefix: "root-nope", check: checkDenyAgentWrite},
|
|
|
|
{name: "ROReadAllowed", prefix: "root-ro", check: checkAllowAgentRead},
|
|
|
|
{name: "ROWriteDenied", prefix: "root-ro", check: checkDenyAgentWrite},
|
|
|
|
{name: "RWReadAllowed", prefix: "root-rw", check: checkAllowAgentRead},
|
|
|
|
{name: "RWWriteAllowed", prefix: "root-rw", check: checkAllowAgentWrite},
|
|
|
|
{name: "DenySuffixReadDenied", prefix: "root-nope-prefix", check: checkDenyAgentRead},
|
|
|
|
{name: "DenySuffixWriteDenied", prefix: "root-nope-prefix", check: checkDenyAgentWrite},
|
|
|
|
{name: "ROSuffixReadAllowed", prefix: "root-ro-prefix", check: checkAllowAgentRead},
|
|
|
|
{name: "ROSuffixWriteDenied", prefix: "root-ro-prefix", check: checkDenyAgentWrite},
|
|
|
|
{name: "RWSuffixReadAllowed", prefix: "root-rw-prefix", check: checkAllowAgentRead},
|
|
|
|
{name: "RWSuffixWriteAllowed", prefix: "root-rw-prefix", check: checkAllowAgentWrite},
|
|
|
|
{name: "ChildDenyReadDenied", prefix: "child-nope", check: checkDenyAgentRead},
|
|
|
|
{name: "ChildDenyWriteDenied", prefix: "child-nope", check: checkDenyAgentWrite},
|
|
|
|
{name: "ChildROReadAllowed", prefix: "child-ro", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildROWriteDenied", prefix: "child-ro", check: checkDenyAgentWrite},
|
|
|
|
{name: "ChildRWReadAllowed", prefix: "child-rw", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildRWWriteAllowed", prefix: "child-rw", check: checkAllowAgentWrite},
|
|
|
|
{name: "ChildDenySuffixReadDenied", prefix: "child-nope-prefix", check: checkDenyAgentRead},
|
|
|
|
{name: "ChildDenySuffixWriteDenied", prefix: "child-nope-prefix", check: checkDenyAgentWrite},
|
|
|
|
{name: "ChildROSuffixReadAllowed", prefix: "child-ro-prefix", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildROSuffixWriteDenied", prefix: "child-ro-prefix", check: checkDenyAgentWrite},
|
|
|
|
{name: "ChildRWSuffixReadAllowed", prefix: "child-rw-prefix", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildRWSuffixWriteAllowed", prefix: "child-rw-prefix", check: checkAllowAgentWrite},
|
|
|
|
{name: "ChildOverrideReadAllowed", prefix: "override", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildOverrideWriteAllowed", prefix: "override", check: checkAllowAgentWrite},
|
Creates new "prepared-query" ACL type and new token capture behavior.
Prior to this change, prepared queries had the following behavior for
ACLs, which will need to change to support templates:
1. A management token, or a token with read access to the service being
queried needed to be provided in order to create a prepared query.
2. The token used to create the prepared query was stored with the query
in the state store and used to execute the query.
3. A management token, or the token used to create the query needed to be
supplied to perform and CRUD operations on an existing prepared query.
This was pretty subtle and complicated behavior, and won't work for
templates since the service name is computed at execution time. To solve
this, we introduce a new "prepared-query" ACL type, where the prefix
applies to the query name for static prepared query types and to the
prefix for template prepared query types.
With this change, the new behavior is:
1. A management token, or a token with "prepared-query" write access to
the query name or (soon) the given template prefix is required to do
any CRUD operations on a prepared query, or to list prepared queries
(the list is filtered by this ACL).
2. You will no longer need a management token to list prepared queries,
but you will only be able to see prepared queries that you have access
to (you get an empty list instead of permission denied).
3. When listing or getting a query, because it was easy to capture
management tokens given the past behavior, this will always blank out
the "Token" field (replacing the contents as <hidden>) for all tokens
unless a management token is supplied. Going forward, we should
discourage people from binding tokens for execution unless strictly
necessary.
4. No token will be captured by default when a prepared query is created.
If the user wishes to supply an execution token then can pass it in via
the "Token" field in the prepared query definition. Otherwise, this
field will default to empty.
5. At execution time, we will use the captured token if it exists with the
prepared query definition, otherwise we will use the token that's passed
in with the request, just like we do for other RPCs (or you can use the
agent's configured token for DNS).
6. Prepared queries with no name (accessible only by ID) will not require
ACLs to create or modify (execution time will depend on the service ACL
configuration). Our argument here is that these are designed to be
ephemeral and the IDs are as good as an ACL. Management tokens will be
able to list all of these.
These changes enable templates, but also enable delegation of authority to
manage the prepared query namespace.
2016-02-23 08:12:58 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "AgentNestedDefaultAllow",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Agents: []*AgentRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "override",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Agents: []*AgentRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "override",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
Creates new "prepared-query" ACL type and new token capture behavior.
Prior to this change, prepared queries had the following behavior for
ACLs, which will need to change to support templates:
1. A management token, or a token with read access to the service being
queried needed to be provided in order to create a prepared query.
2. The token used to create the prepared query was stored with the query
in the state store and used to execute the query.
3. A management token, or the token used to create the query needed to be
supplied to perform and CRUD operations on an existing prepared query.
This was pretty subtle and complicated behavior, and won't work for
templates since the service name is computed at execution time. To solve
this, we introduce a new "prepared-query" ACL type, where the prefix
applies to the query name for static prepared query types and to the
prefix for template prepared query types.
With this change, the new behavior is:
1. A management token, or a token with "prepared-query" write access to
the query name or (soon) the given template prefix is required to do
any CRUD operations on a prepared query, or to list prepared queries
(the list is filtered by this ACL).
2. You will no longer need a management token to list prepared queries,
but you will only be able to see prepared queries that you have access
to (you get an empty list instead of permission denied).
3. When listing or getting a query, because it was easy to capture
management tokens given the past behavior, this will always blank out
the "Token" field (replacing the contents as <hidden>) for all tokens
unless a management token is supplied. Going forward, we should
discourage people from binding tokens for execution unless strictly
necessary.
4. No token will be captured by default when a prepared query is created.
If the user wishes to supply an execution token then can pass it in via
the "Token" field in the prepared query definition. Otherwise, this
field will default to empty.
5. At execution time, we will use the captured token if it exists with the
prepared query definition, otherwise we will use the token that's passed
in with the request, just like we do for other RPCs (or you can use the
agent's configured token for DNS).
6. Prepared queries with no name (accessible only by ID) will not require
ACLs to create or modify (execution time will depend on the service ACL
configuration). Our argument here is that these are designed to be
ephemeral and the IDs are as good as an ACL. Management tokens will be
able to list all of these.
These changes enable templates, but also enable delegation of authority to
manage the prepared query namespace.
2016-02-23 08:12:58 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "DefaultReadAllowed", prefix: "nope", check: checkAllowAgentRead},
|
|
|
|
{name: "DefaultWriteAllowed", prefix: "nope", check: checkAllowAgentWrite},
|
|
|
|
{name: "DenyReadDenied", prefix: "root-nope", check: checkDenyAgentRead},
|
|
|
|
{name: "DenyWriteDenied", prefix: "root-nope", check: checkDenyAgentWrite},
|
|
|
|
{name: "ROReadAllowed", prefix: "root-ro", check: checkAllowAgentRead},
|
|
|
|
{name: "ROWriteDenied", prefix: "root-ro", check: checkDenyAgentWrite},
|
|
|
|
{name: "RWReadAllowed", prefix: "root-rw", check: checkAllowAgentRead},
|
|
|
|
{name: "RWWriteAllowed", prefix: "root-rw", check: checkAllowAgentWrite},
|
|
|
|
{name: "DenySuffixReadDenied", prefix: "root-nope-prefix", check: checkDenyAgentRead},
|
|
|
|
{name: "DenySuffixWriteDenied", prefix: "root-nope-prefix", check: checkDenyAgentWrite},
|
|
|
|
{name: "ROSuffixReadAllowed", prefix: "root-ro-prefix", check: checkAllowAgentRead},
|
|
|
|
{name: "ROSuffixWriteDenied", prefix: "root-ro-prefix", check: checkDenyAgentWrite},
|
|
|
|
{name: "RWSuffixReadAllowed", prefix: "root-rw-prefix", check: checkAllowAgentRead},
|
|
|
|
{name: "RWSuffixWriteAllowed", prefix: "root-rw-prefix", check: checkAllowAgentWrite},
|
|
|
|
{name: "ChildDenyReadDenied", prefix: "child-nope", check: checkDenyAgentRead},
|
|
|
|
{name: "ChildDenyWriteDenied", prefix: "child-nope", check: checkDenyAgentWrite},
|
|
|
|
{name: "ChildROReadAllowed", prefix: "child-ro", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildROWriteDenied", prefix: "child-ro", check: checkDenyAgentWrite},
|
|
|
|
{name: "ChildRWReadAllowed", prefix: "child-rw", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildRWWriteAllowed", prefix: "child-rw", check: checkAllowAgentWrite},
|
|
|
|
{name: "ChildDenySuffixReadDenied", prefix: "child-nope-prefix", check: checkDenyAgentRead},
|
|
|
|
{name: "ChildDenySuffixWriteDenied", prefix: "child-nope-prefix", check: checkDenyAgentWrite},
|
|
|
|
{name: "ChildROSuffixReadAllowed", prefix: "child-ro-prefix", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildROSuffixWriteDenied", prefix: "child-ro-prefix", check: checkDenyAgentWrite},
|
|
|
|
{name: "ChildRWSuffixReadAllowed", prefix: "child-rw-prefix", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildRWSuffixWriteAllowed", prefix: "child-rw-prefix", check: checkAllowAgentWrite},
|
|
|
|
{name: "ChildOverrideReadAllowed", prefix: "override", check: checkAllowAgentRead},
|
|
|
|
{name: "ChildOverrideWriteAllowed", prefix: "override", check: checkAllowAgentWrite},
|
2015-06-18 01:56:29 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "KeyringDefaultAllowPolicyDeny",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Keyring: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadDenied", check: checkDenyKeyringRead},
|
|
|
|
// in version 1.2.1 and below this would have failed
|
|
|
|
{name: "WriteDenied", check: checkDenyKeyringWrite},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "KeyringDefaultAllowPolicyRead",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Keyring: PolicyRead,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowKeyringRead},
|
|
|
|
// in version 1.2.1 and below this would have failed
|
|
|
|
{name: "WriteDenied", check: checkDenyKeyringWrite},
|
2018-03-04 08:38:04 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "KeyringDefaultAllowPolicyWrite",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Keyring: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowKeyringRead},
|
|
|
|
{name: "WriteAllowed", check: checkAllowKeyringWrite},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "KeyringDefaultAllowPolicyNone",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{},
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowKeyringRead},
|
|
|
|
{name: "WriteAllowed", check: checkAllowKeyringWrite},
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "KeyringDefaultDenyPolicyDeny",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Keyring: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2016-02-24 09:26:16 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadDenied", check: checkDenyKeyringRead},
|
|
|
|
{name: "WriteDenied", check: checkDenyKeyringWrite},
|
2016-02-24 09:26:16 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "KeyringDefaultDenyPolicyRead",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Keyring: PolicyRead,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowKeyringRead},
|
|
|
|
{name: "WriteDenied", check: checkDenyKeyringWrite},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "KeyringDefaultDenyPolicyWrite",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Keyring: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowKeyringRead},
|
|
|
|
{name: "WriteAllowed", check: checkAllowKeyringWrite},
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "KeyringDefaultDenyPolicyNone",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadDenied", check: checkDenyKeyringRead},
|
|
|
|
{name: "WriteDenied", check: checkDenyKeyringWrite},
|
2014-08-06 22:08:17 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "OperatorDefaultAllowPolicyDeny",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Operator: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadDenied", check: checkDenyOperatorRead},
|
|
|
|
// in version 1.2.1 and below this would have failed
|
|
|
|
{name: "WriteDenied", check: checkDenyOperatorWrite},
|
2016-02-24 09:26:16 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "OperatorDefaultAllowPolicyRead",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Operator: PolicyRead,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowOperatorRead},
|
|
|
|
// in version 1.2.1 and below this would have failed
|
|
|
|
{name: "WriteDenied", check: checkDenyOperatorWrite},
|
2016-12-02 04:31:50 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "OperatorDefaultAllowPolicyWrite",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Operator: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2016-12-13 07:05:11 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowOperatorRead},
|
|
|
|
{name: "WriteAllowed", check: checkAllowOperatorWrite},
|
2016-12-13 07:05:11 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "OperatorDefaultAllowPolicyNone",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{},
|
2016-12-13 07:05:11 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowOperatorRead},
|
|
|
|
{name: "WriteAllowed", check: checkAllowOperatorWrite},
|
2016-12-13 07:05:11 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "OperatorDefaultDenyPolicyDeny",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Operator: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2016-12-13 07:05:11 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadDenied", check: checkDenyOperatorRead},
|
|
|
|
{name: "WriteDenied", check: checkDenyOperatorWrite},
|
2016-12-13 07:05:11 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "OperatorDefaultDenyPolicyRead",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Operator: PolicyRead,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2016-12-13 07:05:11 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowOperatorRead},
|
|
|
|
{name: "WriteDenied", check: checkDenyOperatorWrite},
|
2016-12-13 07:05:11 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "OperatorDefaultDenyPolicyWrite",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Operator: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2016-12-07 04:05:15 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowOperatorRead},
|
|
|
|
{name: "WriteAllowed", check: checkAllowOperatorWrite},
|
2016-12-07 04:05:15 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "OperatorDefaultDenyPolicyNone",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{},
|
2016-12-07 04:05:15 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadDenied", check: checkDenyOperatorRead},
|
|
|
|
{name: "WriteDenied", check: checkDenyOperatorWrite},
|
2016-12-07 04:05:15 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "NodeDefaultDeny",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Nodes: []*NodeRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "root-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "root-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "root-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "override",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Nodes: []*NodeRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "child-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "child-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "child-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "override",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
2016-12-07 04:05:15 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "ReadAllDenied", prefix: "", check: checkDenyNodeReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "DefaultReadDenied", prefix: "nope", check: checkDenyNodeRead},
|
|
|
|
{name: "DefaultWriteDenied", prefix: "nope", check: checkDenyNodeWrite},
|
|
|
|
{name: "DenyReadDenied", prefix: "root-nope", check: checkDenyNodeRead},
|
|
|
|
{name: "DenyWriteDenied", prefix: "root-nope", check: checkDenyNodeWrite},
|
|
|
|
{name: "ROReadAllowed", prefix: "root-ro", check: checkAllowNodeRead},
|
|
|
|
{name: "ROWriteDenied", prefix: "root-ro", check: checkDenyNodeWrite},
|
|
|
|
{name: "RWReadAllowed", prefix: "root-rw", check: checkAllowNodeRead},
|
|
|
|
{name: "RWWriteAllowed", prefix: "root-rw", check: checkAllowNodeWrite},
|
|
|
|
{name: "DenySuffixReadDenied", prefix: "root-nope-prefix", check: checkDenyNodeRead},
|
|
|
|
{name: "DenySuffixWriteDenied", prefix: "root-nope-prefix", check: checkDenyNodeWrite},
|
|
|
|
{name: "ROSuffixReadAllowed", prefix: "root-ro-prefix", check: checkAllowNodeRead},
|
|
|
|
{name: "ROSuffixWriteDenied", prefix: "root-ro-prefix", check: checkDenyNodeWrite},
|
|
|
|
{name: "RWSuffixReadAllowed", prefix: "root-rw-prefix", check: checkAllowNodeRead},
|
|
|
|
{name: "RWSuffixWriteAllowed", prefix: "root-rw-prefix", check: checkAllowNodeWrite},
|
|
|
|
{name: "ChildDenyReadDenied", prefix: "child-nope", check: checkDenyNodeRead},
|
|
|
|
{name: "ChildDenyWriteDenied", prefix: "child-nope", check: checkDenyNodeWrite},
|
|
|
|
{name: "ChildROReadAllowed", prefix: "child-ro", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildROWriteDenied", prefix: "child-ro", check: checkDenyNodeWrite},
|
|
|
|
{name: "ChildRWReadAllowed", prefix: "child-rw", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildRWWriteAllowed", prefix: "child-rw", check: checkAllowNodeWrite},
|
|
|
|
{name: "ChildDenySuffixReadDenied", prefix: "child-nope-prefix", check: checkDenyNodeRead},
|
|
|
|
{name: "ChildDenySuffixWriteDenied", prefix: "child-nope-prefix", check: checkDenyNodeWrite},
|
|
|
|
{name: "ChildROSuffixReadAllowed", prefix: "child-ro-prefix", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildROSuffixWriteDenied", prefix: "child-ro-prefix", check: checkDenyNodeWrite},
|
|
|
|
{name: "ChildRWSuffixReadAllowed", prefix: "child-rw-prefix", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildRWSuffixWriteAllowed", prefix: "child-rw-prefix", check: checkAllowNodeWrite},
|
|
|
|
{name: "ChildOverrideReadAllowed", prefix: "override", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildOverrideWriteAllowed", prefix: "override", check: checkAllowNodeWrite},
|
2016-12-07 04:05:15 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "NodeDefaultAllow",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Nodes: []*NodeRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "root-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "root-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "root-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "override",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Nodes: []*NodeRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "child-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "child-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "child-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "override",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
2016-12-07 04:05:15 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "ReadAllDenied", prefix: "", check: checkDenyNodeReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "DefaultReadAllowed", prefix: "nope", check: checkAllowNodeRead},
|
|
|
|
{name: "DefaultWriteAllowed", prefix: "nope", check: checkAllowNodeWrite},
|
|
|
|
{name: "DenyReadDenied", prefix: "root-nope", check: checkDenyNodeRead},
|
|
|
|
{name: "DenyWriteDenied", prefix: "root-nope", check: checkDenyNodeWrite},
|
|
|
|
{name: "ROReadAllowed", prefix: "root-ro", check: checkAllowNodeRead},
|
|
|
|
{name: "ROWriteDenied", prefix: "root-ro", check: checkDenyNodeWrite},
|
|
|
|
{name: "RWReadAllowed", prefix: "root-rw", check: checkAllowNodeRead},
|
|
|
|
{name: "RWWriteAllowed", prefix: "root-rw", check: checkAllowNodeWrite},
|
|
|
|
{name: "DenySuffixReadDenied", prefix: "root-nope-prefix", check: checkDenyNodeRead},
|
|
|
|
{name: "DenySuffixWriteDenied", prefix: "root-nope-prefix", check: checkDenyNodeWrite},
|
|
|
|
{name: "ROSuffixReadAllowed", prefix: "root-ro-prefix", check: checkAllowNodeRead},
|
|
|
|
{name: "ROSuffixWriteDenied", prefix: "root-ro-prefix", check: checkDenyNodeWrite},
|
|
|
|
{name: "RWSuffixReadAllowed", prefix: "root-rw-prefix", check: checkAllowNodeRead},
|
|
|
|
{name: "RWSuffixWriteAllowed", prefix: "root-rw-prefix", check: checkAllowNodeWrite},
|
|
|
|
{name: "ChildDenyReadDenied", prefix: "child-nope", check: checkDenyNodeRead},
|
|
|
|
{name: "ChildDenyWriteDenied", prefix: "child-nope", check: checkDenyNodeWrite},
|
|
|
|
{name: "ChildROReadAllowed", prefix: "child-ro", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildROWriteDenied", prefix: "child-ro", check: checkDenyNodeWrite},
|
|
|
|
{name: "ChildRWReadAllowed", prefix: "child-rw", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildRWWriteAllowed", prefix: "child-rw", check: checkAllowNodeWrite},
|
|
|
|
{name: "ChildDenySuffixReadDenied", prefix: "child-nope-prefix", check: checkDenyNodeRead},
|
|
|
|
{name: "ChildDenySuffixWriteDenied", prefix: "child-nope-prefix", check: checkDenyNodeWrite},
|
|
|
|
{name: "ChildROSuffixReadAllowed", prefix: "child-ro-prefix", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildROSuffixWriteDenied", prefix: "child-ro-prefix", check: checkDenyNodeWrite},
|
|
|
|
{name: "ChildRWSuffixReadAllowed", prefix: "child-rw-prefix", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildRWSuffixWriteAllowed", prefix: "child-rw-prefix", check: checkAllowNodeWrite},
|
|
|
|
{name: "ChildOverrideReadAllowed", prefix: "override", check: checkAllowNodeRead},
|
|
|
|
{name: "ChildOverrideWriteAllowed", prefix: "override", check: checkAllowNodeWrite},
|
2016-12-07 04:05:15 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "SessionDefaultDeny",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Sessions: []*SessionRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "override",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Sessions: []*SessionRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "override",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
2016-12-13 04:20:28 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "DefaultReadDenied", prefix: "nope", check: checkDenySessionRead},
|
|
|
|
{name: "DefaultWriteDenied", prefix: "nope", check: checkDenySessionWrite},
|
|
|
|
{name: "DenyReadDenied", prefix: "root-nope", check: checkDenySessionRead},
|
|
|
|
{name: "DenyWriteDenied", prefix: "root-nope", check: checkDenySessionWrite},
|
|
|
|
{name: "ROReadAllowed", prefix: "root-ro", check: checkAllowSessionRead},
|
|
|
|
{name: "ROWriteDenied", prefix: "root-ro", check: checkDenySessionWrite},
|
|
|
|
{name: "RWReadAllowed", prefix: "root-rw", check: checkAllowSessionRead},
|
|
|
|
{name: "RWWriteAllowed", prefix: "root-rw", check: checkAllowSessionWrite},
|
|
|
|
{name: "DenySuffixReadDenied", prefix: "root-nope-prefix", check: checkDenySessionRead},
|
|
|
|
{name: "DenySuffixWriteDenied", prefix: "root-nope-prefix", check: checkDenySessionWrite},
|
|
|
|
{name: "ROSuffixReadAllowed", prefix: "root-ro-prefix", check: checkAllowSessionRead},
|
|
|
|
{name: "ROSuffixWriteDenied", prefix: "root-ro-prefix", check: checkDenySessionWrite},
|
|
|
|
{name: "RWSuffixReadAllowed", prefix: "root-rw-prefix", check: checkAllowSessionRead},
|
|
|
|
{name: "RWSuffixWriteAllowed", prefix: "root-rw-prefix", check: checkAllowSessionWrite},
|
|
|
|
{name: "ChildDenyReadDenied", prefix: "child-nope", check: checkDenySessionRead},
|
|
|
|
{name: "ChildDenyWriteDenied", prefix: "child-nope", check: checkDenySessionWrite},
|
|
|
|
{name: "ChildROReadAllowed", prefix: "child-ro", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildROWriteDenied", prefix: "child-ro", check: checkDenySessionWrite},
|
|
|
|
{name: "ChildRWReadAllowed", prefix: "child-rw", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildRWWriteAllowed", prefix: "child-rw", check: checkAllowSessionWrite},
|
|
|
|
{name: "ChildDenySuffixReadDenied", prefix: "child-nope-prefix", check: checkDenySessionRead},
|
|
|
|
{name: "ChildDenySuffixWriteDenied", prefix: "child-nope-prefix", check: checkDenySessionWrite},
|
|
|
|
{name: "ChildROSuffixReadAllowed", prefix: "child-ro-prefix", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildROSuffixWriteDenied", prefix: "child-ro-prefix", check: checkDenySessionWrite},
|
|
|
|
{name: "ChildRWSuffixReadAllowed", prefix: "child-rw-prefix", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildRWSuffixWriteAllowed", prefix: "child-rw-prefix", check: checkAllowSessionWrite},
|
|
|
|
{name: "ChildOverrideReadAllowed", prefix: "override", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildOverrideWriteAllowed", prefix: "override", check: checkAllowSessionWrite},
|
2016-12-13 04:20:28 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "SessionDefaultAllow",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Sessions: []*SessionRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "root-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "override",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Sessions: []*SessionRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-nope",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-ro",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "child-rw",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "override",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
2016-12-13 04:20:28 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "DefaultReadAllowed", prefix: "nope", check: checkAllowSessionRead},
|
|
|
|
{name: "DefaultWriteAllowed", prefix: "nope", check: checkAllowSessionWrite},
|
|
|
|
{name: "DenyReadDenied", prefix: "root-nope", check: checkDenySessionRead},
|
|
|
|
{name: "DenyWriteDenied", prefix: "root-nope", check: checkDenySessionWrite},
|
|
|
|
{name: "ROReadAllowed", prefix: "root-ro", check: checkAllowSessionRead},
|
|
|
|
{name: "ROWriteDenied", prefix: "root-ro", check: checkDenySessionWrite},
|
|
|
|
{name: "RWReadAllowed", prefix: "root-rw", check: checkAllowSessionRead},
|
|
|
|
{name: "RWWriteAllowed", prefix: "root-rw", check: checkAllowSessionWrite},
|
|
|
|
{name: "DenySuffixReadDenied", prefix: "root-nope-prefix", check: checkDenySessionRead},
|
|
|
|
{name: "DenySuffixWriteDenied", prefix: "root-nope-prefix", check: checkDenySessionWrite},
|
|
|
|
{name: "ROSuffixReadAllowed", prefix: "root-ro-prefix", check: checkAllowSessionRead},
|
|
|
|
{name: "ROSuffixWriteDenied", prefix: "root-ro-prefix", check: checkDenySessionWrite},
|
|
|
|
{name: "RWSuffixReadAllowed", prefix: "root-rw-prefix", check: checkAllowSessionRead},
|
|
|
|
{name: "RWSuffixWriteAllowed", prefix: "root-rw-prefix", check: checkAllowSessionWrite},
|
|
|
|
{name: "ChildDenyReadDenied", prefix: "child-nope", check: checkDenySessionRead},
|
|
|
|
{name: "ChildDenyWriteDenied", prefix: "child-nope", check: checkDenySessionWrite},
|
|
|
|
{name: "ChildROReadAllowed", prefix: "child-ro", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildROWriteDenied", prefix: "child-ro", check: checkDenySessionWrite},
|
|
|
|
{name: "ChildRWReadAllowed", prefix: "child-rw", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildRWWriteAllowed", prefix: "child-rw", check: checkAllowSessionWrite},
|
|
|
|
{name: "ChildDenySuffixReadDenied", prefix: "child-nope-prefix", check: checkDenySessionRead},
|
|
|
|
{name: "ChildDenySuffixWriteDenied", prefix: "child-nope-prefix", check: checkDenySessionWrite},
|
|
|
|
{name: "ChildROSuffixReadAllowed", prefix: "child-ro-prefix", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildROSuffixWriteDenied", prefix: "child-ro-prefix", check: checkDenySessionWrite},
|
|
|
|
{name: "ChildRWSuffixReadAllowed", prefix: "child-rw-prefix", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildRWSuffixWriteAllowed", prefix: "child-rw-prefix", check: checkAllowSessionWrite},
|
|
|
|
{name: "ChildOverrideReadAllowed", prefix: "override", check: checkAllowSessionRead},
|
|
|
|
{name: "ChildOverrideWriteAllowed", prefix: "override", check: checkAllowSessionWrite},
|
2016-12-13 04:20:28 +00:00
|
|
|
},
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
{
|
|
|
|
name: "Parent",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Keys: []*KeyRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo/",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "bar/",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PreparedQueries: []*PreparedQueryRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "other",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: []*ServiceRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "other",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "foo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Keys: []*KeyRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo/priv/",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "bar/",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "zip/",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PreparedQueries: []*PreparedQueryRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "bar",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: []*ServiceRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "bar",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
2016-12-13 04:20:28 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "ServiceReadAllDenied", prefix: "", check: checkDenyServiceReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "KeyReadDenied", prefix: "other", check: checkDenyKeyRead},
|
|
|
|
{name: "KeyWriteDenied", prefix: "other", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "other", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "KeyReadAllowed", prefix: "foo/test", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteAllowed", prefix: "foo/test", check: checkAllowKeyWrite},
|
|
|
|
{name: "KeyWritePrefixAllowed", prefix: "foo/test", check: checkAllowKeyWritePrefix},
|
|
|
|
{name: "KeyReadAllowed", prefix: "foo/priv/test", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteDenied", prefix: "foo/priv/test", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "foo/priv/test", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "KeyReadDenied", prefix: "bar/any", check: checkDenyKeyRead},
|
|
|
|
{name: "KeyWriteDenied", prefix: "bar/any", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "bar/any", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "KeyReadAllowed", prefix: "zip/test", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteDenied", prefix: "zip/test", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "zip/test", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "ServiceReadDenied", prefix: "fail", check: checkDenyServiceRead},
|
|
|
|
{name: "ServiceWriteDenied", prefix: "fail", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadAllowed", prefix: "other", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWriteAllowed", prefix: "other", check: checkAllowServiceWrite},
|
|
|
|
{name: "ServiceReadAllowed", prefix: "foo", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWriteDenied", prefix: "foo", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadDenied", prefix: "bar", check: checkDenyServiceRead},
|
|
|
|
{name: "ServiceWriteDenied", prefix: "bar", check: checkDenyServiceWrite},
|
|
|
|
{name: "PreparedQueryReadAllowed", prefix: "foo", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "foo", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadAllowed", prefix: "foobar", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "foobar", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadDenied", prefix: "bar", check: checkDenyPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "bar", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadDenied", prefix: "barbaz", check: checkDenyPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "barbaz", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadDenied", prefix: "baz", check: checkDenyPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "baz", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadDenied", prefix: "nope", check: checkDenyPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "nope", check: checkDenyPreparedQueryWrite},
|
2018-10-19 16:04:07 +00:00
|
|
|
{name: "ACLReadDenied", check: checkDenyACLRead},
|
|
|
|
{name: "ACLWriteDenied", check: checkDenyACLWrite},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "SnapshotDenied", check: checkDenySnapshot},
|
|
|
|
{name: "IntentionDefaultAllowDenied", check: checkDenyIntentionDefaultAllow},
|
2016-12-13 04:20:28 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "ComplexDefaultAllow",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2018-10-19 16:04:07 +00:00
|
|
|
legacyPolicy(&Policy{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Events: []*EventRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Event: "",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Event: "foo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Event: "bar",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Keys: []*KeyRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo/",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo/priv/",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "bar/",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "zip/",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "zap/",
|
|
|
|
Policy: PolicyList,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PreparedQueries: []*PreparedQueryRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "bar",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "zoo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: []*ServiceRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "foo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "bar",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "barfoo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
Intentions: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "intbaz",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
Intentions: PolicyDeny,
|
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
}),
|
2016-12-13 04:20:28 +00:00
|
|
|
},
|
2018-07-24 20:37:01 +00:00
|
|
|
checks: []aclCheck{
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "ServiceReadAllDenied", prefix: "", check: checkDenyServiceReadAll},
|
2018-07-24 20:37:01 +00:00
|
|
|
{name: "KeyReadAllowed", prefix: "other", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteAllowed", prefix: "other", check: checkAllowKeyWrite},
|
|
|
|
{name: "KeyWritePrefixAllowed", prefix: "other", check: checkAllowKeyWritePrefix},
|
|
|
|
{name: "KeyListAllowed", prefix: "other", check: checkAllowKeyList},
|
|
|
|
{name: "KeyReadAllowed", prefix: "foo/test", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteAllowed", prefix: "foo/test", check: checkAllowKeyWrite},
|
|
|
|
{name: "KeyWritePrefixAllowed", prefix: "foo/test", check: checkAllowKeyWritePrefix},
|
|
|
|
{name: "KeyListAllowed", prefix: "foo/test", check: checkAllowKeyList},
|
|
|
|
{name: "KeyReadDenied", prefix: "foo/priv/test", check: checkDenyKeyRead},
|
|
|
|
{name: "KeyWriteDenied", prefix: "foo/priv/test", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "foo/priv/test", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "KeyListDenied", prefix: "foo/priv/test", check: checkDenyKeyList},
|
|
|
|
{name: "KeyReadDenied", prefix: "bar/any", check: checkDenyKeyRead},
|
|
|
|
{name: "KeyWriteDenied", prefix: "bar/any", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "bar/any", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "KeyListDenied", prefix: "bar/any", check: checkDenyKeyList},
|
|
|
|
{name: "KeyReadAllowed", prefix: "zip/test", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteDenied", prefix: "zip/test", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "zip/test", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "KeyListDenied", prefix: "zip/test", check: checkDenyKeyList},
|
|
|
|
{name: "KeyReadAllowed", prefix: "foo/", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteAllowed", prefix: "foo/", check: checkAllowKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "foo/", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "KeyListAllowed", prefix: "foo/", check: checkAllowKeyList},
|
|
|
|
{name: "KeyReadAllowed", prefix: "", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteAllowed", prefix: "", check: checkAllowKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "KeyListAllowed", prefix: "", check: checkAllowKeyList},
|
|
|
|
{name: "KeyReadAllowed", prefix: "zap/test", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteDenied", prefix: "zap/test", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "zap/test", check: checkDenyKeyWritePrefix},
|
|
|
|
{name: "KeyListAllowed", prefix: "zap/test", check: checkAllowKeyList},
|
|
|
|
{name: "IntentionReadAllowed", prefix: "other", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWriteDenied", prefix: "other", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadAllowed", prefix: "foo", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWriteDenied", prefix: "foo", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadDenied", prefix: "bar", check: checkDenyIntentionRead},
|
|
|
|
{name: "IntentionWriteDenied", prefix: "bar", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadAllowed", prefix: "foobar", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWriteDenied", prefix: "foobar", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadDenied", prefix: "barfo", check: checkDenyIntentionRead},
|
|
|
|
{name: "IntentionWriteDenied", prefix: "barfo", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadAllowed", prefix: "barfoo", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWriteAllowed", prefix: "barfoo", check: checkAllowIntentionWrite},
|
|
|
|
{name: "IntentionReadAllowed", prefix: "barfoo2", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWriteAllowed", prefix: "barfoo2", check: checkAllowIntentionWrite},
|
|
|
|
{name: "IntentionReadDenied", prefix: "intbaz", check: checkDenyIntentionRead},
|
|
|
|
{name: "IntentionWriteDenied", prefix: "intbaz", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionDefaultAllowAllowed", check: checkAllowIntentionDefaultAllow},
|
|
|
|
{name: "ServiceReadAllowed", prefix: "other", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWriteAllowed", prefix: "other", check: checkAllowServiceWrite},
|
|
|
|
{name: "ServiceReadAllowed", prefix: "foo", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWriteDenied", prefix: "foo", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadDenied", prefix: "bar", check: checkDenyServiceRead},
|
|
|
|
{name: "ServiceWriteDenied", prefix: "bar", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadAllowed", prefix: "foobar", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWriteDenied", prefix: "foobar", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadDenied", prefix: "barfo", check: checkDenyServiceRead},
|
|
|
|
{name: "ServiceWriteDenied", prefix: "barfo", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadAllowed", prefix: "barfoo", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWriteAllowed", prefix: "barfoo", check: checkAllowServiceWrite},
|
|
|
|
{name: "ServiceReadAllowed", prefix: "barfoo2", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWriteAllowed", prefix: "barfoo2", check: checkAllowServiceWrite},
|
|
|
|
{name: "EventReadAllowed", prefix: "foo", check: checkAllowEventRead},
|
|
|
|
{name: "EventWriteAllowed", prefix: "foo", check: checkAllowEventWrite},
|
|
|
|
{name: "EventReadAllowed", prefix: "foobar", check: checkAllowEventRead},
|
|
|
|
{name: "EventWriteAllowed", prefix: "foobar", check: checkAllowEventWrite},
|
|
|
|
{name: "EventReadDenied", prefix: "bar", check: checkDenyEventRead},
|
|
|
|
{name: "EventWriteDenied", prefix: "bar", check: checkDenyEventWrite},
|
|
|
|
{name: "EventReadDenied", prefix: "barbaz", check: checkDenyEventRead},
|
|
|
|
{name: "EventWriteDenied", prefix: "barbaz", check: checkDenyEventWrite},
|
|
|
|
{name: "EventReadAllowed", prefix: "baz", check: checkAllowEventRead},
|
|
|
|
{name: "EventWriteDenied", prefix: "baz", check: checkDenyEventWrite},
|
|
|
|
{name: "PreparedQueryReadAllowed", prefix: "foo", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteAllowed", prefix: "foo", check: checkAllowPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadAllowed", prefix: "foobar", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteAllowed", prefix: "foobar", check: checkAllowPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadDenied", prefix: "bar", check: checkDenyPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "bar", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadDenied", prefix: "barbaz", check: checkDenyPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "barbaz", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadAllowed", prefix: "baz", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "baz", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadAllowed", prefix: "nope", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "nope", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadAllowed", prefix: "zoo", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteAllowed", prefix: "zoo", check: checkAllowPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadAllowed", prefix: "zookeeper", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteAllowed", prefix: "zookeeper", check: checkAllowPreparedQueryWrite},
|
2016-12-13 04:20:28 +00:00
|
|
|
},
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
{
|
|
|
|
name: "ExactMatchPrecedence",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Agents: []*AgentRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "foo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "football",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
AgentPrefixes: []*AgentRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "foot",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "fo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Keys: []*KeyRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "football",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
KeyPrefixes: []*KeyRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foot",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "fo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Nodes: []*NodeRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "foo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "football",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
NodePrefixes: []*NodeRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "foot",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "fo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Services: []*ServiceRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "foo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
Intentions: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "football",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
ServicePrefixes: []*ServiceRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "foot",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
Intentions: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Name: "fo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
Intentions: PolicyRead,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Sessions: []*SessionRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "foo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "football",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
SessionPrefixes: []*SessionRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "foot",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Node: "fo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Events: []*EventRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Event: "foo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Event: "football",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
EventPrefixes: []*EventRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Event: "foot",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Event: "fo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PreparedQueries: []*PreparedQueryRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "football",
|
|
|
|
Policy: PolicyDeny,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
PreparedQueryPrefixes: []*PreparedQueryRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foot",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "fo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
checks: []aclCheck{
|
2020-11-04 18:50:03 +00:00
|
|
|
{name: "NodeReadAllDenied", prefix: "", check: checkDenyNodeReadAll},
|
|
|
|
{name: "ServiceReadAllDenied", prefix: "", check: checkDenyServiceReadAll},
|
|
|
|
|
2018-10-19 16:04:07 +00:00
|
|
|
{name: "AgentReadPrefixAllowed", prefix: "fo", check: checkAllowAgentRead},
|
|
|
|
{name: "AgentWritePrefixDenied", prefix: "fo", check: checkDenyAgentWrite},
|
|
|
|
{name: "AgentReadPrefixAllowed", prefix: "for", check: checkAllowAgentRead},
|
|
|
|
{name: "AgentWritePrefixDenied", prefix: "for", check: checkDenyAgentWrite},
|
|
|
|
{name: "AgentReadAllowed", prefix: "foo", check: checkAllowAgentRead},
|
|
|
|
{name: "AgentWriteAllowed", prefix: "foo", check: checkAllowAgentWrite},
|
|
|
|
{name: "AgentReadPrefixAllowed", prefix: "foot", check: checkAllowAgentRead},
|
|
|
|
{name: "AgentWritePrefixDenied", prefix: "foot", check: checkDenyAgentWrite},
|
|
|
|
{name: "AgentReadPrefixAllowed", prefix: "foot2", check: checkAllowAgentRead},
|
|
|
|
{name: "AgentWritePrefixDenied", prefix: "foot2", check: checkDenyAgentWrite},
|
|
|
|
{name: "AgentReadPrefixAllowed", prefix: "food", check: checkAllowAgentRead},
|
|
|
|
{name: "AgentWritePrefixDenied", prefix: "food", check: checkDenyAgentWrite},
|
|
|
|
{name: "AgentReadDenied", prefix: "football", check: checkDenyAgentRead},
|
|
|
|
{name: "AgentWriteDenied", prefix: "football", check: checkDenyAgentWrite},
|
|
|
|
|
|
|
|
{name: "KeyReadPrefixAllowed", prefix: "fo", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "fo", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyReadPrefixAllowed", prefix: "for", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "for", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyReadAllowed", prefix: "foo", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWriteAllowed", prefix: "foo", check: checkAllowKeyWrite},
|
|
|
|
{name: "KeyReadPrefixAllowed", prefix: "foot", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "foot", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyReadPrefixAllowed", prefix: "foot2", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "foot2", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyReadPrefixAllowed", prefix: "food", check: checkAllowKeyRead},
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "food", check: checkDenyKeyWrite},
|
|
|
|
{name: "KeyReadDenied", prefix: "football", check: checkDenyKeyRead},
|
|
|
|
{name: "KeyWriteDenied", prefix: "football", check: checkDenyKeyWrite},
|
|
|
|
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "fo", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "fo", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "for", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "for", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadAllowed", prefix: "foo", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWriteAllowed", prefix: "foo", check: checkAllowNodeWrite},
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "foot", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "foot", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "foot2", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "foot2", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "food", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "food", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadDenied", prefix: "football", check: checkDenyNodeRead},
|
|
|
|
{name: "NodeWriteDenied", prefix: "football", check: checkDenyNodeWrite},
|
|
|
|
|
|
|
|
{name: "ServiceReadPrefixAllowed", prefix: "fo", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWritePrefixDenied", prefix: "fo", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadPrefixAllowed", prefix: "for", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWritePrefixDenied", prefix: "for", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadAllowed", prefix: "foo", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWriteAllowed", prefix: "foo", check: checkAllowServiceWrite},
|
|
|
|
{name: "ServiceReadPrefixAllowed", prefix: "foot", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWritePrefixDenied", prefix: "foot", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadPrefixAllowed", prefix: "foot2", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWritePrefixDenied", prefix: "foot2", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadPrefixAllowed", prefix: "food", check: checkAllowServiceRead},
|
|
|
|
{name: "ServiceWritePrefixDenied", prefix: "food", check: checkDenyServiceWrite},
|
|
|
|
{name: "ServiceReadDenied", prefix: "football", check: checkDenyServiceRead},
|
|
|
|
{name: "ServiceWriteDenied", prefix: "football", check: checkDenyServiceWrite},
|
|
|
|
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "fo", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "fo", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "for", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "for", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadAllowed", prefix: "foo", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWriteAllowed", prefix: "foo", check: checkAllowNodeWrite},
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "foot", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "foot", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "foot2", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "foot2", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadPrefixAllowed", prefix: "food", check: checkAllowNodeRead},
|
|
|
|
{name: "NodeWritePrefixDenied", prefix: "food", check: checkDenyNodeWrite},
|
|
|
|
{name: "NodeReadDenied", prefix: "football", check: checkDenyNodeRead},
|
|
|
|
{name: "NodeWriteDenied", prefix: "football", check: checkDenyNodeWrite},
|
|
|
|
|
|
|
|
{name: "IntentionReadPrefixAllowed", prefix: "fo", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWritePrefixDenied", prefix: "fo", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadPrefixAllowed", prefix: "for", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWritePrefixDenied", prefix: "for", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadAllowed", prefix: "foo", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWriteAllowed", prefix: "foo", check: checkAllowIntentionWrite},
|
|
|
|
{name: "IntentionReadPrefixAllowed", prefix: "foot", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWritePrefixDenied", prefix: "foot", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadPrefixAllowed", prefix: "foot2", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWritePrefixDenied", prefix: "foot2", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadPrefixAllowed", prefix: "food", check: checkAllowIntentionRead},
|
|
|
|
{name: "IntentionWritePrefixDenied", prefix: "food", check: checkDenyIntentionWrite},
|
|
|
|
{name: "IntentionReadDenied", prefix: "football", check: checkDenyIntentionRead},
|
|
|
|
{name: "IntentionWriteDenied", prefix: "football", check: checkDenyIntentionWrite},
|
|
|
|
|
|
|
|
{name: "SessionReadPrefixAllowed", prefix: "fo", check: checkAllowSessionRead},
|
|
|
|
{name: "SessionWritePrefixDenied", prefix: "fo", check: checkDenySessionWrite},
|
|
|
|
{name: "SessionReadPrefixAllowed", prefix: "for", check: checkAllowSessionRead},
|
|
|
|
{name: "SessionWritePrefixDenied", prefix: "for", check: checkDenySessionWrite},
|
|
|
|
{name: "SessionReadAllowed", prefix: "foo", check: checkAllowSessionRead},
|
|
|
|
{name: "SessionWriteAllowed", prefix: "foo", check: checkAllowSessionWrite},
|
|
|
|
{name: "SessionReadPrefixAllowed", prefix: "foot", check: checkAllowSessionRead},
|
|
|
|
{name: "SessionWritePrefixDenied", prefix: "foot", check: checkDenySessionWrite},
|
|
|
|
{name: "SessionReadPrefixAllowed", prefix: "foot2", check: checkAllowSessionRead},
|
|
|
|
{name: "SessionWritePrefixDenied", prefix: "foot2", check: checkDenySessionWrite},
|
|
|
|
{name: "SessionReadPrefixAllowed", prefix: "food", check: checkAllowSessionRead},
|
|
|
|
{name: "SessionWritePrefixDenied", prefix: "food", check: checkDenySessionWrite},
|
|
|
|
{name: "SessionReadDenied", prefix: "football", check: checkDenySessionRead},
|
|
|
|
{name: "SessionWriteDenied", prefix: "football", check: checkDenySessionWrite},
|
|
|
|
|
|
|
|
{name: "EventReadPrefixAllowed", prefix: "fo", check: checkAllowEventRead},
|
|
|
|
{name: "EventWritePrefixDenied", prefix: "fo", check: checkDenyEventWrite},
|
|
|
|
{name: "EventReadPrefixAllowed", prefix: "for", check: checkAllowEventRead},
|
|
|
|
{name: "EventWritePrefixDenied", prefix: "for", check: checkDenyEventWrite},
|
|
|
|
{name: "EventReadAllowed", prefix: "foo", check: checkAllowEventRead},
|
|
|
|
{name: "EventWriteAllowed", prefix: "foo", check: checkAllowEventWrite},
|
|
|
|
{name: "EventReadPrefixAllowed", prefix: "foot", check: checkAllowEventRead},
|
|
|
|
{name: "EventWritePrefixDenied", prefix: "foot", check: checkDenyEventWrite},
|
|
|
|
{name: "EventReadPrefixAllowed", prefix: "foot2", check: checkAllowEventRead},
|
|
|
|
{name: "EventWritePrefixDenied", prefix: "foot2", check: checkDenyEventWrite},
|
|
|
|
{name: "EventReadPrefixAllowed", prefix: "food", check: checkAllowEventRead},
|
|
|
|
{name: "EventWritePrefixDenied", prefix: "food", check: checkDenyEventWrite},
|
|
|
|
{name: "EventReadDenied", prefix: "football", check: checkDenyEventRead},
|
|
|
|
{name: "EventWriteDenied", prefix: "football", check: checkDenyEventWrite},
|
|
|
|
|
|
|
|
{name: "PreparedQueryReadPrefixAllowed", prefix: "fo", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWritePrefixDenied", prefix: "fo", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadPrefixAllowed", prefix: "for", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWritePrefixDenied", prefix: "for", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadAllowed", prefix: "foo", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteAllowed", prefix: "foo", check: checkAllowPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadPrefixAllowed", prefix: "foot", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWritePrefixDenied", prefix: "foot", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadPrefixAllowed", prefix: "foot2", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWritePrefixDenied", prefix: "foot2", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadPrefixAllowed", prefix: "food", check: checkAllowPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWritePrefixDenied", prefix: "food", check: checkDenyPreparedQueryWrite},
|
|
|
|
{name: "PreparedQueryReadDenied", prefix: "football", check: checkDenyPreparedQueryRead},
|
|
|
|
{name: "PreparedQueryWriteDenied", prefix: "football", check: checkDenyPreparedQueryWrite},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "ACLRead",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
ACL: PolicyRead,
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowACLRead},
|
|
|
|
// in version 1.2.1 and below this would have failed
|
|
|
|
{name: "WriteDenied", check: checkDenyACLWrite},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "ACLRead",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
ACL: PolicyWrite,
|
|
|
|
},
|
2018-10-19 16:04:07 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
checks: []aclCheck{
|
|
|
|
{name: "ReadAllowed", check: checkAllowACLRead},
|
|
|
|
// in version 1.2.1 and below this would have failed
|
|
|
|
{name: "WriteAllowed", check: checkAllowACLWrite},
|
|
|
|
},
|
|
|
|
},
|
2019-05-22 20:13:30 +00:00
|
|
|
{
|
|
|
|
name: "KeyWritePrefixDefaultDeny",
|
|
|
|
defaultPolicy: DenyAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
KeyPrefixes: []*KeyRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "fo",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo/",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "bar/",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "baz/",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "test/",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Keys: []*KeyRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo/bar",
|
|
|
|
Policy: PolicyWrite,
|
|
|
|
},
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "bar/baz",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2019-05-22 20:13:30 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
checks: []aclCheck{
|
|
|
|
// Ensure we deny access if the best match key_prefix rule does not grant
|
|
|
|
// write access (disregards both the default policy and any other rules with
|
|
|
|
// segments that may fall within the given kv prefix)
|
|
|
|
{name: "DeniedTopLevelPrefix", prefix: "foo", check: checkDenyKeyWritePrefix},
|
|
|
|
// Allow recursive KV writes when we have a prefix rule that allows it and no
|
|
|
|
// other rules with segments that fall within the requested kv prefix to be written.
|
|
|
|
{name: "AllowedTopLevelPrefix", prefix: "baz/", check: checkAllowKeyWritePrefix},
|
|
|
|
// Ensure we allow recursive KV writes when we have a prefix rule that would allow it
|
|
|
|
// and all other rules with segments prefixed by the kv prefix to be written also allow
|
|
|
|
// write access.
|
|
|
|
{name: "AllowedPrefixWithNestedWrite", prefix: "foo/", check: checkAllowKeyWritePrefix},
|
|
|
|
// Ensure that we deny recursive KV writes when they would be allowed for a prefix but
|
|
|
|
// denied by either an exact match rule or prefix match rule for a segment prefixed by
|
|
|
|
// the kv prefix being checked against.
|
|
|
|
{name: "DenyPrefixWithNestedRead", prefix: "bar/", check: checkDenyKeyWritePrefix},
|
|
|
|
// Ensure that the default deny policy is used when there is no key_prefix rule
|
|
|
|
// for the given kv segment regardless of any rules that would grant write access
|
|
|
|
// to segments prefixed by the kv prefix being checked against.
|
|
|
|
{name: "DenyNoPrefixMatch", prefix: "te", check: checkDenyKeyWritePrefix},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "KeyWritePrefixDefaultAllow",
|
|
|
|
defaultPolicy: AllowAll(),
|
|
|
|
policyStack: []*Policy{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
PolicyRules: PolicyRules{
|
|
|
|
Keys: []*KeyRule{
|
2020-06-16 17:19:31 +00:00
|
|
|
{
|
2019-10-15 20:58:50 +00:00
|
|
|
Prefix: "foo/bar",
|
|
|
|
Policy: PolicyRead,
|
|
|
|
},
|
2019-05-22 20:13:30 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
checks: []aclCheck{
|
|
|
|
// Ensure that we deny a key prefix write when a rule for a key within our prefix
|
|
|
|
// doesn't allow writing and the default policy is to allow
|
|
|
|
{name: "KeyWritePrefixDenied", prefix: "foo", check: checkDenyKeyWritePrefix},
|
|
|
|
// Ensure that the default allow policy is used when there is no prefix rule
|
|
|
|
// and there are no other rules regarding keys within that prefix to be written.
|
|
|
|
{name: "KeyWritePrefixAllowed", prefix: "bar", check: checkAllowKeyWritePrefix},
|
|
|
|
},
|
|
|
|
},
|
2016-12-13 04:20:28 +00:00
|
|
|
}
|
2018-07-24 20:37:01 +00:00
|
|
|
|
|
|
|
for _, tcase := range tests {
|
|
|
|
t.Run(tcase.name, func(t *testing.T) {
|
|
|
|
acl := tcase.defaultPolicy
|
|
|
|
for _, policy := range tcase.policyStack {
|
2019-10-15 20:58:50 +00:00
|
|
|
newACL, err := NewPolicyAuthorizerWithDefaults(acl, []*Policy{policy}, nil)
|
2018-07-24 20:37:01 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
acl = newACL
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, check := range tcase.checks {
|
|
|
|
checkName := check.name
|
|
|
|
if check.prefix != "" {
|
|
|
|
checkName = fmt.Sprintf("%s.Prefix(%s)", checkName, check.prefix)
|
|
|
|
}
|
|
|
|
t.Run(checkName, func(t *testing.T) {
|
2019-10-15 20:58:50 +00:00
|
|
|
check.check(t, acl, check.prefix, nil)
|
2018-07-24 20:37:01 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|
2016-12-13 04:20:28 +00:00
|
|
|
}
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
|
|
|
|
2018-10-19 16:04:07 +00:00
|
|
|
func TestRootAuthorizer(t *testing.T) {
|
|
|
|
require.Equal(t, AllowAll(), RootAuthorizer("allow"))
|
|
|
|
require.Equal(t, DenyAll(), RootAuthorizer("deny"))
|
|
|
|
require.Equal(t, ManageAll(), RootAuthorizer("manage"))
|
|
|
|
require.Nil(t, RootAuthorizer("foo"))
|
2018-07-24 20:37:01 +00:00
|
|
|
}
|
2016-12-13 04:20:28 +00:00
|
|
|
|
2018-07-24 20:37:01 +00:00
|
|
|
func TestACLEnforce(t *testing.T) {
|
|
|
|
type enforceTest struct {
|
|
|
|
name string
|
2019-10-15 20:58:50 +00:00
|
|
|
rule AccessLevel
|
|
|
|
required AccessLevel
|
|
|
|
expected EnforcementDecision
|
2016-12-13 04:20:28 +00:00
|
|
|
}
|
2018-07-24 20:37:01 +00:00
|
|
|
|
|
|
|
tests := []enforceTest{
|
|
|
|
{
|
|
|
|
name: "RuleNoneRequireRead",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessUnknown,
|
|
|
|
required: AccessRead,
|
|
|
|
expected: Default,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleNoneRequireWrite",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessUnknown,
|
|
|
|
required: AccessWrite,
|
|
|
|
expected: Default,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleNoneRequireList",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessUnknown,
|
|
|
|
required: AccessList,
|
|
|
|
expected: Default,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleReadRequireRead",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessRead,
|
|
|
|
required: AccessRead,
|
|
|
|
expected: Allow,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleReadRequireWrite",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessRead,
|
|
|
|
required: AccessWrite,
|
|
|
|
expected: Deny,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleReadRequireList",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessRead,
|
|
|
|
required: AccessList,
|
|
|
|
expected: Deny,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleListRequireRead",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessList,
|
|
|
|
required: AccessRead,
|
|
|
|
expected: Allow,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleListRequireWrite",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessList,
|
|
|
|
required: AccessWrite,
|
|
|
|
expected: Deny,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleListRequireList",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessList,
|
|
|
|
required: AccessList,
|
|
|
|
expected: Allow,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleWritetRequireRead",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessWrite,
|
|
|
|
required: AccessRead,
|
|
|
|
expected: Allow,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleWritetRequireWrite",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessWrite,
|
|
|
|
required: AccessWrite,
|
|
|
|
expected: Allow,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleWritetRequireList",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessWrite,
|
|
|
|
required: AccessList,
|
|
|
|
expected: Allow,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleDenyRequireRead",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessDeny,
|
|
|
|
required: AccessRead,
|
|
|
|
expected: Deny,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleDenyRequireWrite",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessDeny,
|
|
|
|
required: AccessWrite,
|
|
|
|
expected: Deny,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "RuleDenyRequireList",
|
2019-10-15 20:58:50 +00:00
|
|
|
rule: AccessDeny,
|
|
|
|
required: AccessList,
|
|
|
|
expected: Deny,
|
2018-07-24 20:37:01 +00:00
|
|
|
},
|
2016-12-13 04:20:28 +00:00
|
|
|
}
|
2018-07-24 20:37:01 +00:00
|
|
|
|
|
|
|
for _, tcase := range tests {
|
|
|
|
t.Run(tcase.name, func(t *testing.T) {
|
2019-10-15 20:58:50 +00:00
|
|
|
require.Equal(t, tcase.expected, enforce(tcase.rule, tcase.required))
|
2018-07-24 20:37:01 +00:00
|
|
|
})
|
2016-12-13 04:20:28 +00:00
|
|
|
}
|
|
|
|
}
|
2020-11-04 18:50:03 +00:00
|
|
|
|
|
|
|
func TestACL_ReadAll(t *testing.T) {
|
|
|
|
type testcase struct {
|
|
|
|
name string
|
|
|
|
rules string
|
|
|
|
check func(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext)
|
|
|
|
}
|
|
|
|
|
|
|
|
tests := []testcase{
|
|
|
|
{
|
|
|
|
name: "node:bar:read",
|
|
|
|
rules: `node "bar" { policy = "read" }`,
|
|
|
|
check: checkDenyNodeReadAll,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "node:bar:write",
|
|
|
|
rules: `node "bar" { policy = "write" }`,
|
|
|
|
check: checkDenyNodeReadAll,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "node:*:read",
|
|
|
|
rules: `node_prefix "" { policy = "read" }`,
|
|
|
|
check: checkAllowNodeReadAll,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "node:*:write",
|
|
|
|
rules: `node_prefix "" { policy = "write" }`,
|
|
|
|
check: checkAllowNodeReadAll,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service:bar:read",
|
|
|
|
rules: `service "bar" { policy = "read" }`,
|
|
|
|
check: checkDenyServiceReadAll,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service:bar:write",
|
|
|
|
rules: `service "bar" { policy = "write" }`,
|
|
|
|
check: checkDenyServiceReadAll,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service:*:read",
|
|
|
|
rules: `service_prefix "" { policy = "read" }`,
|
|
|
|
check: checkAllowServiceReadAll,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "service:*:write",
|
|
|
|
rules: `service_prefix "" { policy = "write" }`,
|
|
|
|
check: checkAllowServiceReadAll,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
body := func(t *testing.T, rules string, defaultPolicy Authorizer, check func(t *testing.T, authz Authorizer, prefix string, entCtx *AuthorizerContext)) {
|
|
|
|
t.Helper()
|
|
|
|
|
|
|
|
policy, err := NewPolicyFromSource("", 0, rules, SyntaxCurrent, nil, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
acl, err := NewPolicyAuthorizerWithDefaults(defaultPolicy, []*Policy{policy}, nil)
|
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
check(t, acl, "", nil)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, tc := range tests {
|
|
|
|
tc := tc
|
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
|
|
|
t.Run("default deny", func(t *testing.T) {
|
|
|
|
body(t, tc.rules, DenyAll(), tc.check)
|
|
|
|
})
|
|
|
|
t.Run("default allow", func(t *testing.T) {
|
|
|
|
body(t, tc.rules, AllowAll(), checkAllowNodeReadAll)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|