-
Notifications
You must be signed in to change notification settings - Fork 45
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
Support auth param string for Basic authentication #15
Conversation
### 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.
pulsar/__init__.py
Outdated
@@ -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): |
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.
We should also accept the method
argument here, otherwise it might not be obvious that you can pass it in the json string
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 agreed.
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.
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
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 likeAuthenticationOauth2
so that no changes are needed if the upstream C++ client's implementation changed, likeapache/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
andtest_invalid_basic_auth
are extended for this change.