Skip to content

Feature: Add password_creator parameter for dynamic or expiring credentials #139

@DolevGabay

Description

@DolevGabay

Problem

AWS RDS IAM authentication tokens expire every 15 minutes, which makes it impossible to use asyncmy with connection pools that create new connections after token expiry.

Proposed solution

Add an optional password_creator argument to Connection.
If provided, this can be a callable or coroutine returning a fresh password/token each time a new connection is established.

Example

async def create_token():
    return boto3.client("rds").generate_db_auth_token(
        DBHostname="mydb.cluster.amazonaws.com",
        Port=3306,
        DBUsername="dbuser",
        Region="us-east-1",
    )

conn = await asyncmy.connect(
    host="mydb.cluster.amazonaws.com",
    user="dbuser",
    password_creator=create_token,
)

Benefits

Enables using AWS RDS IAM authentication seamlessly.
Works with any short-lived or rotating credential system.
Fully backward-compatible (still supports static password).

Status

Implementation and tests ready in PR feature/password-creator.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions