Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions agent/structs/acl_templated_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const (
ACLTemplatedPolicyNomadClientID = "00000000-0000-0000-0000-000000000009"
ACLTemplatedPolicyAllowServiceID = "00000000-0000-0000-0000-000000000010"
ACLTemplatedPolicyAllowPathID = "00000000-0000-0000-0000-000000000011"
ACLTemplatedPolicyEnableAgentID = "00000000-0000-0000-0000-000000000012"

ACLTemplatedPolicyServiceDescription = "Gives the token or role permissions to register a service and discover services in the Consul catalog. It also gives the specified service's sidecar proxy the permission to discover and route traffic to other services."
ACLTemplatedPolicyNodeDescription = "Gives the token or role permissions for a register an agent/node into the catalog. A node is typically a consul agent but can also be a physical server, cloud instance or a container."
Expand All @@ -52,6 +53,7 @@ const (
ACLTemplatedPolicyNomadClientDescription = "Gives the token or role permissions required for integration with a nomad client."
ACLTemplatedPolicyAllowServiceDescription = "Grants write access to a service prefix"
ACLTemplatedPolicyAllowPathDescription = "Grants write access to a key prefix"
ACLTemplatedPolicyEnableAgentDescription = "Grants write access to agent and node prefixes"

ACLTemplatedPolicyNoRequiredVariablesSchema = "" // catch-all schema for all templated policy that don't require a schema
)
Expand Down Expand Up @@ -126,6 +128,13 @@ var (
Template: ACLTemplatedPolicyAllowPath,
Description: ACLTemplatedPolicyAllowPathDescription,
},
api.ACLTemplatedPolicyEnableAgentName: {
TemplateID: ACLTemplatedPolicyEnableAgentID,
TemplateName: api.ACLTemplatedPolicyEnableAgentName,
Schema: ACLTemplatedPolicyServiceSchema,
Template: ACLTemplatedPolicyEnableAgent,
Description: ACLTemplatedPolicyEnableAgentDescription,
},
}
)

Expand Down
3 changes: 3 additions & 0 deletions agent/structs/acl_templated_policy_ce.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ var ACLTemplatedPolicyAllowService string
//go:embed acltemplatedpolicy/policies/ce/allow_path.hcl
var ACLTemplatedPolicyAllowPath string

//go:embed acltemplatedpolicy/policies/ce/enable_agent.hcl
var ACLTemplatedPolicyEnableAgent string

func (t *ACLToken) TemplatedPolicyList() []*ACLTemplatedPolicy {
if len(t.TemplatedPolicies) == 0 {
return nil
Expand Down
20 changes: 20 additions & 0 deletions agent/structs/acl_templated_policy_ce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,26 @@ service "api" {
service_prefix "api-" {
policy = "write"
}
`,
},
},
"criteo-enable-agent-template": {
templatedPolicy: &ACLTemplatedPolicy{
TemplateID: ACLTemplatedPolicyEnableAgentID,
TemplateName: api.ACLTemplatedPolicyEnableAgentName,
TemplateVariables: &ACLTemplatedPolicyVariables{
Name: "api",
},
},
expectedPolicy: &ACLPolicy{
Description: "synthetic policy generated from templated policy: criteo/enable_agent",
Rules: `
agent_prefix "api" {
policy = "write"
}
node_prefix "api" {
policy = "write"
}
`,
},
},
Expand Down
7 changes: 7 additions & 0 deletions agent/structs/acltemplatedpolicy/policies/ce/enable_agent.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

agent_prefix "{{ .Name }}" {
policy = "write"
}
node_prefix "{{ .Name }}" {
policy = "write"
}
1 change: 1 addition & 0 deletions api/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const (
ACLTemplatedPolicyNomadClientName = "builtin/nomad-client"
ACLTemplatedPolicyAllowServiceName = "criteo/allow_service"
ACLTemplatedPolicyAllowPathName = "criteo/allow_path"
ACLTemplatedPolicyEnableAgentName = "criteo/enable_agent"
)

type ACLLink struct {
Expand Down
2 changes: 1 addition & 1 deletion version/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.22.3-criteo1
1.22.3-criteo2
Loading