Proposal: per-connection credential provider for short-lived MySQL credentials

Ouverte
#1,768 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 10 jours

Personne n'a encore pris cette issue.

Évaluation

Difficulté
5/5
Temps estimé
Plus d'une semaine
Accessibilité débutants
35/100
Type d'issue
Fonctionnalité
Clarté
Plutôt claire
Activité
Active
Stack technique
go, mysql

Piste de recherche

Commencez par suivre les points d’entrée go/mysql ConnectionConfig, Password.MigrationContext, CliPasswordProvider et ApplyCredentials. Suivez ensuite les chemins de connexion de reconnexion décrits dans database/sql, failover, cut-over et binlog-reader, puis déterminez comment le provider proposé serait invoqué avant chaque tentative. Le travail est considéré comme terminé lorsque le comportement de l’API et la priorité sont définis et couverts pour chaque chemin de connexion pertinent.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Problem

Managed MySQL services and other credential providers supply short-lived database credentials: e.g. AWS IAM for RDS, GCP Cloud SQL IAM, and HashiCorp Vault's database secrets engine.  Currently, gh-ost captures a password once and reuses it for the life of the migration, so there is no way to supply a renewed valid credential when a new connection is dialed mid-migration.

New connections are opened in at least the following cases:

• database/sql re-dials after ErrBadConn or a server-side wait_timeout 
• a failover forces reconnection
• the cut-over takes a fresh pinned connection for its lock
• the binlog reader is rebuilt after a streaming failure surfaces

Proposed API and scope

// go/mysql
type PasswordProvider func(ctx context.Context, key InstanceKey) (string, error)

ConnectionConfig.PasswordProvider takes precedence over  Password.MigrationContext. CliPasswordProvider is copied into the connection config by ApplyCredentials. The provider is called immediately before each connection attempt.

This is deliberately an API for programs embedding  gh-ost . It does not add built-in cloud IAM support or a credential-fetching CLI flag, and introduces no cloud SDK dependency. An embedding caller implements it with an AWS SigV4 token, an Entra or Cloud SQL access token, a Vault lease, a password command, or a closure over a static string.

Example: embedding with AWS RDS IAM

ctx.CliPasswordProvider = func(c context.Context, key mysql.InstanceKey)
  (string, error) {
        return auth.BuildAuthToken(
                c, key.DisplayString(), awsConfig.Region, ctx.CliUser, awsConfig.Credentials,
        )
    }
ctx.CliAllowCleartextPasswords = true
ctx.UseTLS = true
ctx.TLSCACertificate = "/etc/ssl/certs/rds-ca-bundle.pem"

Would a library hook be an acceptable first interface, or would you prefer a CLI-facing mechanism such as a credentials file or a password command?

Langage dominant
Go
Étoiles
13.6k
Forks
1.4k
Merge moyen
9 j 19 h
PR mergées (30 j)
1

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de github/gh-ost

Toutes les issues de github/gh-ost

Issues similaires

Plus d'issues Go

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.