-
Notifications
You must be signed in to change notification settings - Fork 373
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
Implements TOTP API #873
base: main
Are you sure you want to change the base?
Implements TOTP API #873
Conversation
docs/usage/secrets_engines/totp.rst
Outdated
'mykey', | ||
url="otpauth://totp/Google:test@gmail.com?secret=Y64VEVMBTSXCYIWRSHRNDZW62MPGVU2G&issuer=Google" | ||
) | ||
print('New TOTP key response: {}'.format(create_key_response)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: To simplify the docs a little bit, do you mind using f-strings in your examples? Since the next release will be 3.6 and greater, I'd like for HVAC to start using modern Python as much as possible.
print(f'New TOTP key response: {create_key_response}')
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, the change looks good to me. I suggested several things that I would like to be addressed before approving.
Thanks again for working on adding support for this secrets engine!
hvac/constants/totp.py
Outdated
DEFAULT_MOUNT_POINT = "totp" | ||
ALLOWED_ALGORITHMS = ['SHA1', 'SHA256', 'SHA512'] | ||
ALLOWED_DIGITS = [6, 8] | ||
ALLOWED_SKEW = [0, 1] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a newline at the end of the file here
hvac/api/secrets_engines/totp.py
Outdated
) | ||
|
||
return self._adapter.get(url=api_path) | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: What is the pass
for here?
hvac/api/secrets_engines/totp.py
Outdated
|
||
if generate: | ||
if issuer == "" or account_name == "": | ||
error_msg = 'required issuer and account_name when generate is true, got "{issuer}", "{account_name}"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: format
would no longer be necessary if f-strings were used on this line and the other error_msg
lines below.
hvac/api/secrets_engines/totp.py
Outdated
) | ||
) | ||
else: | ||
if url == "": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: I think it would be better to evaluate url
for truthiness here.
if not url:
from unittest import TestCase | ||
from hvac.api.system_backend import mount | ||
|
||
from parameterized import parameterized, param |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Import order should follow PEP-8
- Standard library imports.
- Related third party imports.
- Local application/library specific imports.
https://peps.python.org/pep-0008/#imports
parameterized should go between lines 2 and 3. The hvac imports should be grouped together. All groups should be separated by one space.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mount
auto imported, not needed, removed
Codecov Report
@@ Coverage Diff @@
## main #873 +/- ##
==========================================
- Coverage 81.98% 77.78% -4.20%
==========================================
Files 65 66 +1
Lines 3019 3587 +568
==========================================
+ Hits 2475 2790 +315
- Misses 544 797 +253
|
all suggestions should be addressed 76d0fc1 |
This PR needs to be formatted with Black. I would advise an interactive rebase of your commits, running black for each commit. |
085b858
to
9dbfa98
Compare
Hi @xunzhou , Similar to #874: The Since your PR was opened before this change, I have:
This PR and the other has been waiting on changes for a while, please let us know if you still interested in finishing them up! |
Implements TOTP API as in https://www.vaultproject.io/api/secret/totp
Including Tests and Docs
Closes #791