feat(vault): add get_tfa_code (email + authenticator)#12
Merged
Conversation
Mirrors cloudcruise-js: VaultClient.get_tfa_code(permissioned_user_id, domain) calls GET /vault/tfa-code and returns a VaultTfaCode. Adds the VaultTfaCode dataclass, the module-level convenience wrapper, top-level export, and a README example. authenticator -> generated TOTP (+expires_in_seconds); email -> latest received code (+received_at); SMS/magic-link -> 409 (not supported).
Greptile SummaryThis PR adds a vault helper for retrieving current 2FA codes. It changes:
Confidence Score: 5/5This looks safe to merge.
Reviews (3): Last reviewed commit: "fix(vault): redact code in VaultTfaCode ..." | Re-trigger Greptile |
Default dataclass repr printed the live code, so debug-logging the object would leak a valid TOTP/email code. Custom __repr__ shows code='<redacted>'; the value is still accessible via the .code attribute.
eckfel
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
VaultClient.get_tfa_code(permissioned_user_id, domain)to the Python SDK, mirroring the newcloudcruise-jsmethod (PR #12) and wrapping the backend endpointGET /vault/tfa-code(monorepo PR #7017, merged + verified on staging).Usage
Behavior (auto-detected by the credential's
tfa_method)expires_in_secondsset.received_atset.409.Changes
cloudcruise/vault/client.py—get_tfa_codemethod (validates params, GETs/vault/tfa-code, maps toVaultTfaCode, drops unknown fields for forward-compat).cloudcruise/vault/types.py—VaultTfaCodedataclass.cloudcruise/vault/__init__.py+cloudcruise/__init__.py— module-levelget_tfa_codeconvenience +VaultTfaCodeexport.cloudcruise/vault/README.md— usage example.Notes
ruffclean on the changed files; functional test confirms the request path, response mapping, and param validation. (Pre-existing ruff/mypy findings in unrelated files are untouched.)