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 globbing dis/allowed_policies_glob in token roles #7277

Merged
merged 3 commits into from Sep 21, 2021

Conversation

nvx
Copy link
Contributor

@nvx nvx commented Aug 8, 2019

Based off the existing work in PR #5815 rebased onto latest master.

This adds globbing support to the allowed_policies and disallowed_policies token role fields. This functionality is opt-in, controlled by the role flag allow_glob_policies, to preserve existing behaviour modelled after allow_glob_domains in the pki secrets engine.

@hashicorp-cla
Copy link

hashicorp-cla commented Aug 8, 2019

CLA assistant check
All committers have signed the CLA.

@jefferai
Copy link
Member

Not sure Boolean flags is better than simply having separate config params. One issue with this flag is it necessarily must apply to allowed and disallowed. It's simpler though.

@nvx
Copy link
Contributor Author

nvx commented Aug 13, 2019

Not sure Boolean flags is better than simply having separate config params. One issue with this flag is it necessarily must apply to allowed and disallowed. It's simpler though.

Separate config params as in having both an allowed_policies and an allowed_policies_glob param for example?

If so I did consider this but then it seems unlikely that someone would want to mix the glob and non glob versions in practice (since not using a glob character in a policy would be the same behaviour in both _glob and non-glob fields) and for consistency with other parts of vault (the pki secrets engine uses a flag like this implementation to toggle globbing on hostnames).

The only benefit I could see to separate fields would be if someone has a policy with a * character in it already, but that seems unlikely that someone would want to use glob matching while also having glob characters in policy names as there is a very high chance of human error in that instance. That said, we can't change the default behaviour for this reason though, and an explicit opt-in requirement however implemented is safest.

@nvx
Copy link
Contributor Author

nvx commented Sep 2, 2019

Any update on merging this @jefferai? I notice there's a go race test that failed, but from what I can tell it looks to be unrelated to this PR but happy to fix it up if that's not the case.

@nvx
Copy link
Contributor Author

nvx commented Feb 5, 2020

Is there anything blocking this getting merged? @catsby?

@NoodlesRomanof
Copy link

Any movement on this? Would be useful.

@nvx
Copy link
Contributor Author

nvx commented Feb 9, 2021

Any update on this? This is one of the oldest PR's now.

Due to the time it's been since I opened this I'm not sure if it would cleanly merge into master, but if it's possible to get this merged I'm happy to rebase the PR onto HEAD if needed but I won't bother if it's just going to sit again for years.

@nvx
Copy link
Contributor Author

nvx commented Feb 9, 2021

I'm also happy to move this to use separate fields rather than a flag to control the behaviour (although I note using a flag matches the pki secrets engine hence using that option originally) if that's what's blocking this from being merged.

@hsimon-hashicorp
Copy link
Contributor

Thanks @pmmukh for bringing this one up! This has in fact been sitting for a while, so I'm going to take this back to our engineers and see how the team wants to move forward. Apologies for the delay!

@nvx
Copy link
Contributor Author

nvx commented Sep 7, 2021

Thanks @pmmukh for bringing this one up! This has in fact been sitting for a while, so I'm going to take this back to our engineers and see how the team wants to move forward. Apologies for the delay!

Happy to do the work to get this merge-able again if there's a way forward to get this merged! Would be super useful to simplify a few workflows in my team.

@pmmukh
Copy link
Contributor

pmmukh commented Sep 14, 2021

Hi @nvx! Yeah we've been chatting internally, and I think the current approach of a boolean config to enable globbing makes sense to us, so if you could please update this PR and resolve the conflicts, I'll be happy to give it a review!

@nvx
Copy link
Contributor Author

nvx commented Sep 15, 2021

Hi @nvx! Yeah we've been chatting internally, and I think the current approach of a boolean config to enable globbing makes sense to us, so if you could please update this PR and resolve the conflicts, I'll be happy to give it a review!

Will do. I just noticed strutil has moved out of this repo and into https://github.com/hashicorp/go-secure-stdlib though. This PR currently adds two funcs StrListSubsetGlob and RemoveGlobs to the strutil package. Should I throw in a PR there to add those funcs first then once that's merged update this PR to leverage it. Or just make some helper funcs to achieve the same task inside the vault/token_store.go file instead for ease of the PR. If the former I wouldn't be able to finish updating this PR until the go-secure-stdlib changes have been merged though, so if it's easy enough to get stuff merged in that repo that seems like the best option.

Working under the assumption that getting go-secure-stdlib updated isn't hard I've submitted hashicorp/go-secure-stdlib#8

@pmmukh
Copy link
Contributor

pmmukh commented Sep 15, 2021

Ah, thanks for pointing out this requires changes in https://github.com/hashicorp/go-secure-stdlib! We discussed the process around changes to that repo, and how we'd like to handle this is the former approach you put out, to merge the changes into go-secure-stdlib first, then use that code in this PR. I'll go ahead and give that PR a review, then once merged we can cut a new release on that lib and use that here.

vault/token_store.go Outdated Show resolved Hide resolved
@nvx nvx requested a review from a team September 17, 2021 07:11
@vercel vercel bot temporarily deployed to Preview – vault September 17, 2021 07:11 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook September 17, 2021 07:11 Inactive
…ame as allowed_policies and disallowed_policies but allow glob matching.
@vercel vercel bot temporarily deployed to Preview – vault-storybook September 17, 2021 07:20 Inactive
@vercel vercel bot temporarily deployed to Preview – vault September 17, 2021 07:20 Inactive
@nvx nvx changed the title Allow globbing dis/allowed_policies in token roles with flag Allow globbing dis/allowed_policies_glob in token roles Sep 17, 2021
@nvx
Copy link
Contributor Author

nvx commented Sep 17, 2021

This has been updated to be allowed_policies_glob and disallowed_policies_glob. Rebased onto the latest main and squished to a single commit to hide the sausage making.

In the end due to having to change some logic to work for both allowed_policies and allowed_policies_glob I no longer need any changes to stdlib now too.

vault/token_store.go Outdated Show resolved Hide resolved
vault/token_store.go Show resolved Hide resolved
vault/token_store_test.go Outdated Show resolved Hide resolved
vault/token_store_test.go Outdated Show resolved Hide resolved
vault/token_store_test.go Outdated Show resolved Hide resolved
vault/token_store_test.go Outdated Show resolved Hide resolved
@pmmukh
Copy link
Contributor

pmmukh commented Sep 17, 2021

Another thing, could you please update the docs in https://github.com/hashicorp/vault/blob/main/website/content/api-docs/auth/token.mdx as well ?

@pmmukh
Copy link
Contributor

pmmukh commented Sep 17, 2021

Ah also, I think this PR needs a changelog added

@nvx
Copy link
Contributor Author

nvx commented Sep 18, 2021

@pmmukh All done. Let me know if I've missed anything or if anything new pops up!

@nvx
Copy link
Contributor Author

nvx commented Sep 19, 2021

Just fixed up a missing go fmt in the tests. Squashed it into the previous commit for cleanliness.

Copy link
Contributor

@pmmukh pmmukh left a comment

Choose a reason for hiding this comment

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

some nits, but overall lgtm!

website/content/api-docs/auth/token.mdx Outdated Show resolved Hide resolved
vault/token_store_test.go Outdated Show resolved Hide resolved
vault/token_store_test.go Show resolved Hide resolved
Copy link
Contributor

@ncabatoff ncabatoff left a comment

Choose a reason for hiding this comment

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

Prat asked me to have a look at this PR as well. Given the sensitive nature of this part of the code, I looked at the changes quite closely and they look good to me. I did not scrutinize the test changes in great detail, I merely satisfied myself that they looked to be testing the right things, and I trust Prat to find any implementation issues with them.

@pmmukh
Copy link
Contributor

pmmukh commented Sep 21, 2021

Thanks for the 👀 and double checking the PR, nick!

@pmmukh pmmukh merged commit 68065df into hashicorp:main Sep 21, 2021
@nvx nvx deleted the feature/token-glob-policy branch September 22, 2021 00:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants