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

Create anonymous-policy and token from non-default partitions. #966

Merged
merged 6 commits into from
Jan 24, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ commands:
type: string
consul-k8s-image:
type: string
default: "docker.mirror.hashicorp.services/hashicorpdev/consul-k8s-control-plane:latest"
default: "ashwinvenkatesh/consul-k8s@sha256:9b46fae446fcf99c715d9063231857eef5525830f2cd3cdcb46266c84db11deb"
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 be deleted before merge.

go-path:
type: string
default: "/home/circleci/.go_workspace"
Expand Down
22 changes: 15 additions & 7 deletions control-plane/subcommand/server-acl-init/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,21 @@ func (c *Command) Run(args []string) int {
}

if c.createAnonymousPolicy(isPrimary) {
err := c.configureAnonymousPolicy(consulClient)
// When the default partition is in a VM, the anonymous policy does not allow cross-partition
// DNS lookups. The anonymous policy in the default partition needs to be updated in order to
// support this use-case. Creating a separate anonymous token client that updates the anonymous
// policy and token in the default partition ensures this works.
anonTokenConfig := clientConfig
if c.flagEnablePartitions {
anonTokenConfig.Partition = consulDefaultPartition
}
anonTokenClient, err := consul.NewClient(anonTokenConfig)
if err != nil {
c.log.Error(err.Error())
return 1
}

err = c.configureAnonymousPolicy(anonTokenClient)
if err != nil {
c.log.Error(err.Error())
return 1
Expand Down Expand Up @@ -793,12 +807,6 @@ type Config struct {
// createAnonymousPolicy returns whether we should create a policy for the
// anonymous ACL token, i.e. queries without ACL tokens.
func (c *Command) createAnonymousPolicy(isPrimary bool) bool {
// Don't try to create the anonymous policy in non-default partitions because
// non-default partitions will use the anonymous policy from the default
// partition.
if c.flagEnablePartitions && c.flagPartitionName != "default" {
return false
}
// If isPrimary is not set then we're in a secondary DC.
// In this case we assume that the primary datacenter has already created
// the anonymous policy and attached it to the anonymous token.
Expand Down