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

Changing default values for sys.initialize parameters secret_shares and secret_threshold #1063

Merged
merged 5 commits into from Oct 13, 2023

Conversation

briantist
Copy link
Contributor

@briantist briantist commented Sep 17, 2023

Fixes #1030

For more details see:

Because we set default values for secret_shares and secret_threshold in the initialize call, it's not possible to make the API request without values set.

Unfortunately, there are certain cases in the API call where these values must not be set, when using certain auto-unseal configurations, in which only recovery_shares and recovery_threshold should be set, and Vault will reject the call if the other two are set as well.

Breaking change

We're changing the default value of these parameters to None along with the rest.

In v2.0.0, if secret_shares is None, and recovery_shares is also None, then we will set secret_shares to 5 (which was the default previously), and issue a warning.
Likewise with secret_threshold and recovery_threshold, where secret_threshold will be set to 3 (the previous default) when both of those parameters are None.

In v3.0.0 we will remove the default fallback.

This is very unlikely to actually be a breaking change in v2.0.0 but it could be if all of the following are true:

  • there are any versions of the API call where setting both sets of parameters is actually valid (unconfirmed if this is even possible)
  • you are making such a call
  • you are only setting recovery_shares and/or recovery_threshold while relying on the defaults for secret_shares and/or secret_threshold

Action needed

If you currently call the initialize method relying on the previous default values, you should update to using explicit values right away. This can be done right away, even in already released versions.

With hvac>=2,<3, relying on defaults will work (with above caveats) but will issue a deprecation warning.

In hvac>=3 default values will no longer be provided and your calls will probably break unless you specify your values explicitly.

@briantist briantist added bug system backend generally related to the Vault system backend routes breaking-change labels Sep 17, 2023
@briantist briantist added this to the 2.0.0 milestone Sep 17, 2023
@briantist briantist self-assigned this Sep 17, 2023
@codecov
Copy link

codecov bot commented Sep 17, 2023

Codecov Report

Merging #1063 (6ad5f9f) into main (eaa862e) will increase coverage by 1.48%.
Report is 4 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1063      +/-   ##
==========================================
+ Coverage   85.08%   86.57%   +1.48%     
==========================================
  Files          65       65              
  Lines        3145     3187      +42     
==========================================
+ Hits         2676     2759      +83     
+ Misses        469      428      -41     
Files Coverage Δ
hvac/api/system_backend/init.py 100.00% <100.00%> (+43.75%) ⬆️

... and 5 files with indirect coverage changes

@briantist briantist added the announcement Announces some change or future change to be aware of label Sep 17, 2023
@briantist briantist changed the title Sys/init auto unseal Changing default values for sys.initialize parameters secret_shares and secret_threshold Sep 17, 2023
@briantist briantist marked this pull request as ready for review September 17, 2023 21:32
@briantist briantist requested a review from a team as a code owner September 17, 2023 21:32
Copy link

@kaypeter87 kaypeter87 left a comment

Choose a reason for hiding this comment

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

I think this is a good compromise. Plus deprecation warnings have been implemented 👍 LGTM

if recovery_threshold is not None:
if recovery_threshold > recovery_shares:
error_msg = "value for recovery_threshold argument must be less than or equal to recovery_shares argument"
raise ParamValidationError(error_msg)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why use an explicit error_msg variable here when the current file has previously not done so? Its not a breaking instance of code just stylistic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

looking at left side in the side-by-side diff, it seems it's because the previous code did in fact use this variable, and I just changed the message minimally but didn't remove use of the var. I don't feel strongly about it, if you want to put in a suggested change in the comment that removes the variable I'll probably accept it.

Copy link
Contributor

@Tylerlhess Tylerlhess left a comment

Choose a reason for hiding this comment

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

Code looks good from my side just a single stylistic inconsistency.

@briantist
Copy link
Contributor Author

been a little while since CI ran so I'm going to close/re-open to kick off CI again

@briantist briantist closed this Oct 13, 2023
@briantist briantist reopened this Oct 13, 2023
@briantist briantist merged commit 42736b3 into hvac:main Oct 13, 2023
66 checks passed
@briantist briantist deleted the sys/init-auto-unseal branch October 13, 2023 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
announcement Announces some change or future change to be aware of breaking-change bug system backend generally related to the Vault system backend routes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vault Initialization fails when using azurekeyvault for auto unsealing
3 participants