-
Notifications
You must be signed in to change notification settings - Fork 418
Add support for password functions (useful for RDS IAM auth) #554
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
@@ -601,6 +601,11 @@ def connection_lost(self, exc): | |||
raise asyncio.TimeoutError | |||
|
|||
connected = _create_future(loop) | |||
|
|||
params_input = params | |||
if callable(params.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.
Please also add support for coroutines (via inspect.iscoroutinefunction()
) to support async callbacks.
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.
Good point, updated the branch with support for async password callbacks and an additional test for that case as well.
await self._try_connect( | ||
user='password_user', | ||
password=get_wrongpassword) | ||
|
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 like flake8 is unhappy about the extra newline here
await self._try_connect( | ||
user='password_user', | ||
password=get_wrongpassword) | ||
|
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.
... and here
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. Please add a note about this to the connect()
docstring. Thanks!
@HLFrye Thanks so much for this change. I have a question though regarding RDS IAM before I open a new issue. I haven't been able to get this to connect to our RDS instance despite our callable generating valid tokens. I actually can't figure out how to get asyncpg to connect using a generated auth token at all, either by passing our callable or by generating the token and passing it directly into the
I've confirmed that I can use our same connection code to connect to a different postgres database using a standard password, and also that all of the values used and the token generated are valid and can be used to connect via psycopg2 and psql. The code is about as simple as possible:
where Any help would be greatly appreciated! |
Resolves this issue: #553