-
Notifications
You must be signed in to change notification settings - Fork 29
refactor: use shared code for IAM based authenticators #118
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
Conversation
Codecov Report
@@ Coverage Diff @@
## main #118 +/- ##
==========================================
+ Coverage 98.77% 98.92% +0.14%
==========================================
Files 18 20 +2
Lines 737 746 +9
==========================================
+ Hits 728 738 +10
+ Misses 9 8 -1
Continue to review full report at Codecov.
|
I am thinking about one more thing that could improve the project structure: put all the token managers into a single directory, just like the authenticators. Not sure would this break anything or not, I only found this. |
if you move the token manager files to a new "token_managers" directory, couldn't you just update the
|
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.
Looks good! I spotted one minor thing that needs to be changed but I'll approve now to avoid a re-review. It looks like this refactoring work will greatly reduce the amount of new code needed for the ContainerAuthenticator and (later on) the VPCInstanceAuthenticator. I've found the same thing in the Java core as well and I suspect @dpopp07 is seeing the same in the Node core. @dpopp07 Thank you for the idea to do this refactoring :)
Attributes: | ||
token_manager (TokenManager): Retrives and manages IAM tokens from the endpoint specified by the url. | ||
""" | ||
authentication_type = 'iam' |
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.
This won't apply to all IAM-based authenticators, so it probably belongs only in the IamAuthenticator class.
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.
I second Phil's comment but otherwise, looks good! 👍
More info: - Surround top-level function and class definitions with two blank lines: https://www.python.org/dev/peps/pep-0008/#blank-lines - Imports grouping and ordering: https://www.python.org/dev/peps/pep-0008/#imports
I've pushed More info:
(Since there is a lot of changes (number of files) in the last commit, it makes the overall diff a bit messy, sorry for that! I didn't want to create a separate PR for this.) |
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.
Latest changes LGTM!
@@ -95,7 +96,7 @@ def request_token(self) -> dict: | |||
A dictionary containing the bearer token to be subsequently used service requests. | |||
""" | |||
headers = { | |||
'Content-type': 'applicaton/x-www-form-urlencoded', | |||
'Content-type': 'application/x-www-form-urlencoded', |
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.
wow, the misspelled "applicaton" didn't cause a problem before??? :)
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.
I was surprised too! The container authenticator tests will cover this, so I didn't change the tests here.
🎉 This PR is included in version 3.11.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This PR introduces two new classes:
IAMRequestBasedTokenManager
andIAMRequestBasedAuthenticator
. These contain common functionalities for IAM auth based flows.I haven't changed the tests on purpose. (Well, there is a minor change to fix the codecov patch check). The reason is to make sure that no interface change has been made, so everything is working just like before.