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 verifying recovery keys #1095

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Allow verifying recovery keys #1095

wants to merge 1 commit into from

Conversation

wilsonge
Copy link

@wilsonge wilsonge commented Oct 17, 2023

Currently the recovery mechanism only works for rekey's but not for recovery keys. This uses the same parameter we use elsewhere in the file to facilitate that

Documentation for the new path being used here: https://developer.hashicorp.com/vault/api-docs/system/rekey-recovery-key#submit-verification-key

Resolves #1097

@wilsonge wilsonge requested a review from a team as a code owner October 17, 2023 14:17
@briantist briantist added enhancement a new feature or addition system backend generally related to the Vault system backend routes labels Oct 18, 2023
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Merging #1095 (8a8f167) into main (8829ff2) will decrease coverage by 0.08%.
The diff coverage is 70.00%.

@@            Coverage Diff             @@
##             main    #1095      +/-   ##
==========================================
- Coverage   87.09%   87.02%   -0.08%     
==========================================
  Files          64       64              
  Lines        3146     3152       +6     
==========================================
+ Hits         2740     2743       +3     
- Misses        406      409       +3     
Files Coverage Δ
hvac/api/system_backend/key.py 84.94% <70.00%> (-2.42%) ⬇️

Copy link
Contributor

@briantist briantist left a comment

Choose a reason for hiding this comment

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

Hi @wilsonge welcome! Thanks for submitting this. I haven't looked too closely yet and it will take some time before I'm able to. In the meantime, I would also like to see tests and documentation/examples for the change included in the PR.

Hopefully there's existing tests and documentation you could extend (I haven't looked yet); if not I understand that adding it from scratch could be a burden.

@@ -320,7 +320,7 @@ def read_backup_keys(self, recovery_key=False):
url=api_path,
)

def cancel_rekey_verify(self):
def cancel_rekey_verify(self, recovery_key=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def cancel_rekey_verify(self, recovery_key=False):
def cancel_rekey_verify(self, *, recovery_key=False):

Let's make all of these keyword-only. The ability to pass a naked boolean value could be unclear, and future-looking, I'd like to try to avoid adding new positional parameters where possible, because it makes adding new parameters or changing ones in the future more strict since re-ordering is a breaking change.

Copy link
Author

Choose a reason for hiding this comment

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

Are you willing to trade off the consistency of how we're implementing this in the other methods further up which already have the same parameter. If you're happy for the inconsistency happy to roll it out.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for pointing that out, I didn't see the other methods. I guess we'll leave them positional for consistency.

If I had a comprehensive plan/guidance written out about this I might've gone the other way, but I haven't been able to write that yet.

@wilsonge
Copy link
Author

Hopefully there's existing tests and documentation you could extend (I haven't looked yet); if not I understand that adding it from scratch could be a burden.

There aren't :) I did check before I submitted. None of the recovery key based methods are documented or tested sadly.

@briantist
Copy link
Contributor

Hopefully there's existing tests and documentation you could extend (I haven't looked yet); if not I understand that adding it from scratch could be a burden.

There aren't :) I did check before I submitted. None of the recovery key based methods are documented or tested sadly.

It looks like we have some docs here: https://github.com/hvac/hvac/blob/main/docs/usage/system_backend/key.rst (published: https://hvac.readthedocs.io/en/stable/usage/system_backend/key.html)

And integration tests here: https://github.com/hvac/hvac/blob/main/tests/integration_tests/api/system_backend/test_key.py

@briantist briantist self-assigned this Oct 21, 2023
@briantist briantist added this to the 2.1.0 milestone Oct 21, 2023
@briantist briantist added minor Used as part of release-drafter's version-resolver configuration hacktoberfest-accepted PR is accepted for hacktoberfest labels Oct 30, 2023
@briantist briantist removed this from the 2.1.0 milestone Dec 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement a new feature or addition hacktoberfest-accepted PR is accepted for hacktoberfest minor Used as part of release-drafter's version-resolver configuration system backend generally related to the Vault system backend routes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is HVAC unable to verify a re-key operation with the recovery_key=True flag?
2 participants