Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix acls when peering and partitions are both enabled #1733

Merged
merged 4 commits into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
3 changes: 3 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1273,6 +1273,9 @@ workflows:
context: consul-ci
requires:
- dev-upload-docker
- acceptance-gke-1-23:
requires:
- dev-upload-docker
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will remove before merging.


nightly-cleanup:
triggers:
Expand Down
2 changes: 2 additions & 0 deletions control-plane/subcommand/server-acl-init/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ func (c *Command) meshGatewayRules() (string, error) {
meshGatewayRulesTpl := `mesh = "write"
{{- if .EnablePeering }}
peering = "read"
{{- if eq .PartitionName "default" }}
partition_prefix "" {
peering = "read"
}
{{- end }}
{{- end }}
{{- if .EnableNamespaces }}
namespace "default" {
{{- end }}
Expand Down
42 changes: 37 additions & 5 deletions control-plane/subcommand/server-acl-init/rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ func TestMeshGatewayRules(t *testing.T) {
Name string
EnableNamespaces bool
EnablePeering bool
PartitionName string
Expected string
}{
{
Expand Down Expand Up @@ -230,13 +231,45 @@ namespace_prefix "" {
}`,
},
{
Name: "Peering is enabled",
Name: "Peering is enabled with unspecified partition name (oss case)",
EnablePeering: true,
Expected: `mesh = "write"
peering = "read"
service "mesh-gateway" {
policy = "write"
}
node_prefix "" {
policy = "read"
}
service_prefix "" {
policy = "read"
}`,
},
{
Name: "Peering is enabled with partition explicitly specified as default (ent default case)",
EnablePeering: true,
PartitionName: "default",
Expected: `mesh = "write"
peering = "read"
partition_prefix "" {
peering = "read"
}
service "mesh-gateway" {
policy = "write"
}
node_prefix "" {
policy = "read"
}
service_prefix "" {
policy = "read"
}`,
},
{
Name: "Peering is enabled with partition explicitly specified as non-default (ent non-default case)",
EnablePeering: true,
PartitionName: "non-default",
Expected: `mesh = "write"
peering = "read"
service "mesh-gateway" {
policy = "write"
}
Expand All @@ -253,9 +286,6 @@ partition_prefix "" {
EnableNamespaces: true,
Expected: `mesh = "write"
peering = "read"
partition_prefix "" {
peering = "read"
}
namespace "default" {
service "mesh-gateway" {
policy = "write"
Expand All @@ -277,7 +307,9 @@ namespace_prefix "" {
cmd := Command{
flagEnableNamespaces: tt.EnableNamespaces,
flagEnablePeering: tt.EnablePeering,
consulFlags: &flags.ConsulFlags{},
consulFlags: &flags.ConsulFlags{
Partition: tt.PartitionName,
},
}

meshGatewayRules, err := cmd.meshGatewayRules()
Expand Down