Skip to content

Support auth param string for Basic authentication #15

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 3 commits into from
Oct 13, 2022

Conversation

BewareMyPower
Copy link
Contributor

Motivation

apache/pulsar#17482 supported basic authentication for Python client, but the AuthenticationBasic class accepts two positional arguments as the username and password. It's not good for extension. We should accept an auth param string like AuthenticationOauth2 so that no changes are needed if the upstream C++ client's implementation changed, like
apache/pulsar-client-cpp#37.

Modifications

To be compatible with the existing API, change the first two arguments to keyword arguments. Then, add the 3rd keyword argument to represent the auth param string.

Verifications

test_basic_auth and test_invalid_basic_auth are extended for this change.

### Motivation

apache/pulsar#17482 supported basic
authentication for Python client, but the `AuthenticationBasic` class
accepts two positional arguments as the username and password. It's not
good for extension. We should accept an auth param string like
`AuthenticationOauth2` so that no changes are needed if the upstream C++
client's implementation changed, like
apache/pulsar-client-cpp#37.

### Modifications

To be compatible with the existing API, change the first two arguments
to keyword arguments. Then, add the 3rd keyword argument to represent
the auth param string.

### Verifications

`test_basic_auth` and `test_invalid_basic_auth` are extended for this
change.
@BewareMyPower BewareMyPower added the enhancement New feature or request label Oct 13, 2022
@BewareMyPower BewareMyPower self-assigned this Oct 13, 2022
@@ -347,18 +347,32 @@ class AuthenticationBasic(Authentication):
"""
Basic Authentication implementation
"""
def __init__(self, username, password):
def __init__(self, username=None, password=None, auth_params_string=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

We should also accept the method argument here, otherwise it might not be obvious that you can pass it in the json string

Copy link
Member

Choose a reason for hiding this comment

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

I agreed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. PTAL again @merlimat @nodece

Copy link
Member

@nodece nodece left a comment

Choose a reason for hiding this comment

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

LGTM

@merlimat merlimat merged commit 51d3846 into apache:main Oct 13, 2022
@merlimat merlimat added this to the 3.0.0 milestone Oct 13, 2022
@BewareMyPower BewareMyPower deleted the bewaremypower/basic-auth-param branch October 13, 2022 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants