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

allow ACL policies to be associated with workload identity #14140

Merged
merged 3 commits into from
Aug 22, 2022

Conversation

tgross
Copy link
Member

@tgross tgross commented Aug 16, 2022

The original design for workload identities and ACLs allows for operators to
extend the automatic capabilities of a workload by using a specially-named
policy. This has shown to be potentially unsafe because of naming collisions, so
instead we'll allow operators to explicitly attach a policy to a workload
identity.

This changeset adds workload identity fields to ACL policy objects and threads
that all the way down to the command line. It also a new secondary index to the
ACL policy table on namespace and job so that claim resolution can efficiently
query for related policies.


Fixes #13995

cc @schmichael @apollo13 @angrycub I've got this in draft while I do some end-to-end verification but the overall design seems sound enough for a first look if you've got comments.

@@ -0,0 +1,3 @@
```release-note:improvement
cli: `acl policy info` output format has changed to improve readability with large policy documents
Copy link
Member Author

@tgross tgross Aug 16, 2022

Choose a reason for hiding this comment

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

This is the only bit of this that's changing behavior of already-shipped code outside of Secure Variables and Workload Identity work (which will get its own changelog entry once we're ready to wrap everything up). If we want to be fussy we can pull this out to its own PR but it's a tiny change that won't get backported so seemed safe to keep here.

@tgross
Copy link
Member Author

tgross commented Aug 16, 2022

Some end-to-end testing:

$ WI=<token extracted from a running job=httpd>
$ NOMAD_TOKEN=$WI nomad operator api '/v1/vars'
Permission denied%

$ echo '{"Items": {"name": "Tim"}}' | nomad operator api -X PUT "/v1/var/example"
$ nomad operator api '/v1/var/example?namespace=default'
{"CreateIndex":34,"CreateTime":1660675347090671505,"Items":{"name":"Tim"},"ModifyIndex":34,"ModifyTime":1660675347090671505,"Namespace":"default","Path":"example"}%

# not allowed, as expected
$ NOMAD_TOKEN=$WI nomad operator api '/v1/var/example?namespace=default'
Permission denied%

# attach the operator policy to the job
$ nomad acl policy apply -namespace default -job httpd operator ./operator.hcl
Successfully wrote "operator" ACL policy!

$ NOMAD_TOKEN=$WI nomad operator api '/v1/var/example' | jq .
{
  "CreateIndex": 34,
  "CreateTime": 1660675347090671505,
  "Items": {
    "name": "Tim"
  },
  "ModifyIndex": 34,
  "ModifyTime": 1660675347090671505,
  "Namespace": "default",
  "Path": "example"
}

# add a job-specific secret
$ echo '{"Items": {"name": "Tim"}}' | nomad operator api -X PUT "/v1/var/nomad/jobs/httpd"

# read it as expected
$ NOMAD_TOKEN=$WI nomad operator api '/v1/var/nomad/jobs/httpd' | jq .
{
  "CreateIndex": 40,
  "CreateTime": 1660675566715335400,
  "Items": {
    "name": "Tim"
  },
  "ModifyIndex": 40,
  "ModifyTime": 1660675566715335400,
  "Namespace": "default",
  "Path": "nomad/jobs/httpd"
}

api/acl.go Outdated Show resolved Hide resolved
@tgross tgross requested a review from shoenig August 19, 2022 20:31
Copy link
Member

@shoenig shoenig left a comment

Choose a reason for hiding this comment

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

LGTM! just the usual suggestions

command/acl_policy_apply.go Outdated Show resolved Hide resolved
api/acl.go Outdated Show resolved Hide resolved
command/acl_policy_apply.go Outdated Show resolved Hide resolved
nomad/structs/structs.go Outdated Show resolved Hide resolved
The original design for workload identities and ACLs allows for operators to
extend the automatic capabilities of a workload by using a specially-named
policy. This has shown to be potentially unsafe because of naming collisions, so
instead we'll allow operators to explicitly attach a policy to a workload
identity.

This changeset adds workload identity fields to ACL policy objects and threads
that all the way down to the command line. It also a new secondary index to the
ACL policy table on namespace and job so that claim resolution can efficiently
query for related policies.
@tgross tgross force-pushed the sv-attach-acl-policy-to-job branch from b9eb888 to 22920e1 Compare August 22, 2022 20:13
@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 120 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
theme/variables Variables feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

secure vars implicit ACL policy expects invalid name
3 participants