-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: support basic user/password auth with MySQLEngine
#17
Conversation
# override MySQLEngine._connector to allow a new Connector to be initiated | ||
MySQLEngine._connector = 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.
this is required for testing purposes because MySQLEngine._connector
is a class attribute to be re-used across engines. However, the Cloud SQL Python Connector does not allow the same connector to be called with enable_iam_auth
set to False and then also be called with it set to True which happens when you create an engine with basic auth and then again with defaulting to iam authn.
I think customers would use one or the other, i don't see a use-case for customers wanting to use both.
) | ||
iam_database_user = _get_iam_principal_email(credentials) | ||
# if user and password are given, use basic auth | ||
if user and password: |
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.
should we throw an error if they specify user and not password (or vica versa)?
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.
added an error, catching it up a level using XOR logic in the .from_instance()
class method for easier developer experience with stacktrace coming from a public method instead of the internal _create_connector_engine
Adding basic user/password auth support to
MySQLEngine.from_instance()
through optionaluser
andpassword
args.