Skip to content

Create optional provider config setting for using or disabling the child token - #775

Merged
benashz merged 5 commits into
hashicorp:mainfrom
tstraley:optional-child-token-config
Dec 6, 2021
Merged

Create optional provider config setting for using or disabling the child token#775
benashz merged 5 commits into
hashicorp:mainfrom
tstraley:optional-child-token-config

Conversation

@tstraley

@tstraley tstraley commented May 25, 2020

Copy link
Copy Markdown
Contributor

This adds a new (often requested) vault provider configuration setting which can allow users to disable the creation of the intermediate child token (strongly discouraged, but made available for the cases that need it).

provider "vault" {
    address = "https://vault.testdomain"
    create_intermediate_child_token = false
}

(Open to changing the name of this config item, or related env var, but I like to be verbose with settings that typically shouldn't be adjusted without reading the documentation).

Community Note

  • Please vote on this pull request by adding a 👍 reaction to the original pull request comment to help the community and maintainers prioritize this request
  • Please do not leave "+1" comments, they generate extra noise for pull request followers and do not help prioritize the request

Closes #29
Closes #722
Relates #550
Relates #368
Relates #192

Relates to the following as well:
hashicorp/terraform#16457
hashicorp/terraform#14839
https://groups.google.com/forum/#!topic/terraform-tool/wtlLrKVQlAo

Release note for CHANGELOG:

provider: Add skip_child_token provider configuration setting to control the use of ephemeral child tokens.

Output from acceptance testing:

$ make testacc TESTARGS='-run TestAccChildToken'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run TestAccChildToken -timeout 120m
?   	github.com/terraform-providers/terraform-provider-vault	[no test files]
?   	github.com/terraform-providers/terraform-provider-vault/cmd/coverage	[no test files]
testing: warning: no tests to run
PASS
ok  	github.com/terraform-providers/terraform-provider-vault/util	0.012s [no tests to run]
=== RUN   TestAccChildToken
--- PASS: TestAccChildToken (1.15s)
PASS
ok  	github.com/terraform-providers/terraform-provider-vault/vault	1.168s

@hashicorp-cla

hashicorp-cla commented Nov 25, 2020

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@nikolaishields

Copy link
Copy Markdown

@tstraley Thankyou so much for the contribution! looks like the only thing holding this back is for you to sign the CLA as mentioned above by @hashicorp-cla. Don't want to be a bother, but me and my team could really use this once its merged upstream.

@nikolaishields

nikolaishields commented Jan 26, 2021

Copy link
Copy Markdown

After further investigation it appears that @tstraley has been largely inactive on github for 6+ months, with the only blocker being that they have not accepted the hashicorp CLA.

@tstraley

tstraley commented Feb 9, 2021

Copy link
Copy Markdown
Contributor Author

@nikolaishields - thanks for the bumps, this had fallen way off my radar. I am now seeking approval from my employer's license review board before I can accept the hashicorp CLA and get this moved on.

@tstraley

tstraley commented Mar 3, 2021

Copy link
Copy Markdown
Contributor Author

Can I please get reviews from the maintainers of this project? I believe this is ready for merge (long overdue). Thanks :)

@tstraley

Copy link
Copy Markdown
Contributor Author

@catsby @tomhjp @tvoran @jasonodonnell - is this something any of you could look at?

@matttrach

Copy link
Copy Markdown

I think this could resolve several other feature requests, what do you think @tyrannosaurus-becks ?

@matttrach

Copy link
Copy Markdown

As for the security concern, in many use cases an encrypted Terraform backend could mitigate a lot of the risk.

@tyrannosaurus-becks

Copy link
Copy Markdown
Contributor

Hi @matttrach , I'm no longer involved with this project and have moved on from HashiCorp.

@matttrach

Copy link
Copy Markdown

We will miss you @tyrannosaurus-becks !
@jasonodonnell would you mind taking a look?

@surendarkumavat

surendarkumavat commented May 21, 2021

Copy link
Copy Markdown

@tstraley Many Thanks for your contribution on this. With the remote disk encrypted backend becoming the norm, this has become a much awaited feature. Maintainers(@catsby @tomhjp @tvoran @jasonodonnell ), any updates on the ETA?

@rmgpinto

rmgpinto commented Jul 13, 2021

Copy link
Copy Markdown

Can this be merged and released please?

@rmgpinto

Copy link
Copy Markdown

Or is there a way to merge this change locally and replace the hashicorp provider?

@jasonodonnell
jasonodonnell self-requested a review July 13, 2021 22:36
@rmgpinto

Copy link
Copy Markdown

@jasonodonnell can this be approved please? It's just a small change on 3 files.

@jasonodonnell

jasonodonnell commented Jul 21, 2021

Copy link
Copy Markdown
Contributor

Hi @rmgpinto, we're still discussing the security implications of this change internally and haven't reached a decision yet. This PR is high quality and it looks good from a code perspective, but the exposure of Vault tokens via Terraform state files and logs are definitely concerning (even when the defaults are security focused).

All that said this is on our immediate radar and we'll make a decision very soon. Thanks for your patience on this!

@rmgpinto

Copy link
Copy Markdown

Thanks for the quick feedback!

@alan2wong

Copy link
Copy Markdown

@jasonodonnell, could you provide some insight as to what the security implications are for this particular PR?

@tstraley

tstraley commented Oct 9, 2021

Copy link
Copy Markdown
Contributor Author

@jasonodonnell giving this a bump.

I want to call out that all of the security considerations are well documented and this isn't something that users would use unless they need it and understand those risks. Having the option available has been a major request for many years now, and I'm not hearing any reason this should be held up further.

Please let me know if you'd like me to resolve the new merge conflicts and re-push so this can finally land.

@ghost

ghost commented Nov 8, 2021

Copy link
Copy Markdown

@tstraley thank you for this. Just commenting here for an update, so I could just terraform apply --auto-approve all the way when approved.

@benashz
benashz self-requested a review November 18, 2021 19:19
@benashz

benashz commented Nov 18, 2021

Copy link
Copy Markdown
Collaborator

@tstraley we are taking another look at this PR. Would you mind rebasing it off of main?

Thanks,

Ben

Adds setting and documentation for create_intermediate_child_token
provider configuration item. This defaults to true and is strongly
discouraged to disable. When disabled, it allows users to use the
vault terraform provider without the provided token creating
ephermeral child token.
Adds tests for the `create_intermediate_child_token`
vault provider config setting.

Also refactors a couple test helper functions to avoid
duplicate code in common testing patterns.
@tstraley
tstraley force-pushed the optional-child-token-config branch from 2a704f1 to e73ac1b Compare November 24, 2021 02:14
@tstraley

Copy link
Copy Markdown
Contributor Author

@benashz - just rebased, resolved conflicts, and pushed updated version up. Please have a look and let me know if you'd like any changes.

Happy 🦃

@benashz benashz added this to the 3.1.0 milestone Nov 24, 2021

@benashz benashz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is looking pretty good so far. I have provided some initial feedback.

Thanks,

Ben

Comment thread vault/provider.go Outdated
Comment thread vault/provider.go Outdated
Comment thread vault/provider.go Outdated
Comment thread vault/provider_test.go
Comment thread vault/provider_test.go Outdated
Comment thread vault/provider_test.go Outdated
Comment thread website/docs/index.html.markdown Outdated
Comment thread website/docs/index.html.markdown Outdated
Comment thread vault/provider_test.go Outdated
Comment thread vault/provider_test.go
Per pull request review from @benashz
This name change includes a flip in the logic: if skipping the
creation of the child token is true, we do not create it and
assign it, if false we follow the default behavior of using
the child token. Tests and documentation were updated to match.

@benashz benashz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looking good! Just a few minor suggestions.

Comment thread vault/provider.go Outdated
Comment thread vault/provider_test.go Outdated
Comment thread vault/provider_test.go
Comment thread vault/provider_test.go
Comment thread vault/provider_test.go Outdated
@benashz
benashz self-requested a review November 29, 2021 16:10
@tstraley
tstraley force-pushed the optional-child-token-config branch from c060b9b to 650ef8c Compare November 30, 2021 00:29
@tstraley

tstraley commented Dec 2, 2021

Copy link
Copy Markdown
Contributor Author

@benashz just giving this a gentle bump for re-review.

Comment thread website/docs/index.html.markdown Outdated
@benashz
benashz self-requested a review December 6, 2021 16:27

@benashz benashz left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So we just need to address the documentation comment, then +1.

Thank you for your contribution to HashiCorp!

@benashz
benashz merged commit cbfbceb into hashicorp:main Dec 6, 2021
@benashz

benashz commented Dec 6, 2021

Copy link
Copy Markdown
Collaborator

Thanks again @tstraley for all the effort on this PR. It's much appreciated!

andybaran added a commit to andybaran/terraform-provider-vault that referenced this pull request Feb 17, 2026
Based on review of 7 highly-commented PRs (hashicorp#1815, hashicorp#1821, hashicorp#902, hashicorp#2128,
hashicorp#1877, hashicorp#2548, hashicorp#775) on hashicorp/terraform-provider-vault:

- Use d.Get() instead of d.GetOk() for boolean field validation per
  SDKv2 best practice (d.GetOk returns (false,false) for booleans set
  to false, a known limitation flagged in PRs hashicorp#1815 and hashicorp#2128)
- Add grace_period validation when dual_account_mode is enabled (must
  be > 0; catches misconfiguration at provider level before Vault API)
- Add standby field test assertions (standby_username, standby_dn,
  standby_password) to dual-account data source acceptance test per
  PR hashicorp#2128 reviewer feedback: 'make assertions about what we expect'
- Clarify grace_period docs: required when dual_account_mode is true,
  must be >= 5s and < rotation_period
- Fix data source docs section header consistency

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Feature Request: add provider argument use_child_token to control child token creation Vault provider is unable to access data with a non-root token

10 participants