Skip to content

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

Merged
merged 15 commits into from
Aug 27, 2019
Merged

New Authentication mechanism #21

merged 15 commits into from
Aug 27, 2019

Conversation

ehdsouza
Copy link
Contributor

@ehdsouza ehdsouza commented Aug 16, 2019

This PR supports

  • the new authentication mechanism, an example:
from ibm_cloud_sdk_core.authenticators import BasicAuthenticator

assistant = AssistantV1(version='2018-07-10', 
                                        authenticator=BasicAuthenticator('<username>', '<password>'))
  • removed older python versions from travis
  • moved all code for get_authenticator_from_environment in utils file
  • The base service has request is broken up into: prepare_request and send. So the generator would be updated to:
        request = self.prepare_request(
            method='GET',
            url=url,
            headers=headers,
            params=params,
            accept_json=True)
        response = self.send(request)

Also updated the design doc: https://github.ibm.com/CloudEngineering/openapi-sdkgen/wiki/Core-SDK-Authentication-Design

@codecov
Copy link

codecov bot commented Aug 16, 2019

Codecov Report

Merging #21 into next will increase coverage by 2%.
The diff coverage is 97.81%.

Impacted file tree graph

@@           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
Impacted Files Coverage Δ
...oud_sdk_core/authenticators/basic_authenticator.py 100% <100%> (ø)
...loud_sdk_core/authenticators/cp4d_authenticator.py 100% <100%> (ø)
ibm_cloud_sdk_core/iam_token_manager.py 100% <100%> (ø) ⬆️
..._core/authenticators/bearer_token_authenticator.py 100% <100%> (ø)
ibm_cloud_sdk_core/jwt_token_manager.py 97.72% <100%> (-0.32%) ⬇️
ibm_cloud_sdk_core/authenticators/__init__.py 100% <100%> (ø)
ibm_cloud_sdk_core/cp4d_token_manager.py 100% <100%> (ø)
ibm_cloud_sdk_core/__init__.py 100% <100%> (ø) ⬆️
...d_sdk_core/authenticators/no_auth_authenticator.py 100% <100%> (ø)
ibm_cloud_sdk_core/authenticators/authenticator.py 66.66% <66.66%> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ed2147a...cec3609. Read the comment docs.

@ehdsouza ehdsouza changed the title Auth New Authentication mechanism Aug 16, 2019
@dpopp07
Copy link

dpopp07 commented Aug 16, 2019

Haven't looked at the code yet, but have a couple questions about the release strategy:

I see you're merging this into master, so will that trigger a release? Isn't this a breaking change? If this is going into the major release candidate for the core, perhaps it should go into a next branch or something like that.

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 BREAKING CHANGE tag on it?

@ehdsouza ehdsouza changed the base branch from master to next August 16, 2019 22:19
@ehdsouza
Copy link
Contributor Author

ehdsouza commented Aug 16, 2019

@dpopp07 I changed the base to next as I would be making more minor changes like updating the request library. Together, Ill merge it as an official major 1.0.0 release

Copy link

@dpopp07 dpopp07 left a 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

@padamstx
Copy link
Member

@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.
That will likely help us a bit during the review, plus it would be good to have examples for all the languages on the wiki :)

Copy link
Member

@mediumTaj mediumTaj left a 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.

Copy link
Contributor Author

@ehdsouza ehdsouza left a 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

Copy link
Member

@padamstx padamstx left a 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


# 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)
Copy link
Member

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.

Copy link

@dpopp07 dpopp07 left a 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()
Copy link

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

@ehdsouza ehdsouza requested a review from dpopp07 August 21, 2019 23:19
Copy link
Member

@padamstx padamstx left a 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 :)

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
Copy link
Member

Choose a reason for hiding this comment

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

s/Athenticator/Authenticator/ :)

Copy link

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!

Copy link

@dpopp07 dpopp07 left a 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!

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
Copy link

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.
Copy link

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

if config:
authenticator = contruct_authenticator(config)

# 3. From env variables
Copy link

Choose a reason for hiding this comment

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

Small typo

Suggested change
# 3. From env variables
# 2. From env variables

Copy link
Member

@mediumTaj mediumTaj left a comment

Choose a reason for hiding this comment

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

👍 looks good!

Copy link

@dpopp07 dpopp07 left a 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

Copy link

@dpopp07 dpopp07 left a comment

Choose a reason for hiding this comment

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

Looks good! 👍

@ehdsouza ehdsouza merged commit 7eb7e88 into next Aug 27, 2019
@ehdsouza ehdsouza deleted the auth branch August 27, 2019 13:48
@watson-github-bot
Copy link

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants