-
Notifications
You must be signed in to change notification settings - Fork 29
New Authentication mechanism #21
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 @@
## next #21 +/- ##
=======================================
+ Coverage 95.75% 97.76% +2%
=======================================
Files 9 16 +7
Lines 448 492 +44
=======================================
+ Hits 429 481 +52
+ Misses 19 11 -8
Continue to review full report at Codecov.
|
Haven't looked at the code yet, but have a couple questions about the release strategy: I see you're merging this into That is, unless this is the only change you want to go into the next major release. If that's the case, we can just do the major release with this PR like @padamstx did with Java. Either way, shouldn't one of the commit messages have the |
@dpopp07 I changed the base to |
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 looks pretty good but needs some changes to adhere to the design and stay consistent with the other SDKs
@ehdsouza I haven't had a chance to look at the changes in detail yet, but could you add python code examples to the design wiki. |
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 think Dustin covered everything :)
One question about making the authenticate function consistent.
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.
@dpopp07 @mediumTaj thanks for the review comments. Ill make the necessary changes.
@padamstx Ill update the doc with examples shortly
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 left a bunch of comments pointing out where things deviate from the design.
Please read through the details of the design wiki (https://github.ibm.com/CloudEngineering/openapi-sdkgen/wiki/Core-SDK-Authentication-Design) and update the code to comply with that as much as you can.
Thanks
ibm_cloud_sdk_core/base_service.py
Outdated
|
||
# 2. Credentials from credential file | ||
if display_name and not self.username and not self.token_manager: | ||
if display_name and not self.authenticator: | ||
service_name = display_name.replace(' ', '_').lower() | ||
self._load_from_credential_file(service_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.
Nope, we don't do this from BaseService any more.
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.
Looking good but I have a few more changes to request
self.token_manager = IAMTokenManager( | ||
apikey, url, client_id, client_secret, disable_ssl_verification, | ||
headers, proxies) | ||
self.validate() |
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 wonder if you should validate before you create the token manager, so that you're not passing a null value for apikey if none is given. Probably doesn't make a big difference though
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.
LGTM; I could only find one little typo to complain about :)
ibm_cloud_sdk_core/base_service.py
Outdated
2) Credentials loaded from credentials file if present | ||
3) Credentials loaded from VCAP_SERVICES environment variable if available and use_vcap_services is True | ||
:attr str url: The url for service api calls | ||
:attr Athenticator authenticator: The authenticator for authentication |
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.
s/Athenticator/Authenticator/ :)
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 think this still needs to be fixed!
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.
A couple small docs items to address still but otherwise, looks good!
ibm_cloud_sdk_core/base_service.py
Outdated
2) Credentials loaded from credentials file if present | ||
3) Credentials loaded from VCAP_SERVICES environment variable if available and use_vcap_services is True | ||
:attr str url: The url for service api calls | ||
:attr Athenticator authenticator: The authenticator for authentication |
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 think this still needs to be fixed!
@@ -81,5 +90,23 @@ def set_iam_authorization_info(self, iam_client_id, iam_client_secret): | |||
If these values are not supplied, then a default Authorization header | |||
is used. |
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.
Last little docs change, there is no default header anymore
ibm_cloud_sdk_core/utils.py
Outdated
if config: | ||
authenticator = contruct_authenticator(config) | ||
|
||
# 3. From env variables |
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.
Small typo
# 3. From env variables | |
# 2. From env variables |
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!
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.
Changes need to be made now that we are changing the design
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! 👍
🎉 This PR is included in version 1.0.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This PR supports
get_authenticator_from_environment
in utils filerequest
is broken up into:prepare_request
andsend
. So the generator would be updated to:Also updated the design doc: https://github.ibm.com/CloudEngineering/openapi-sdkgen/wiki/Core-SDK-Authentication-Design