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

Đang mở
#1,768 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 10 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
go, mysql

Hướng nghiên cứu

Bắt đầu bằng cách lần theo các entry point go/mysql ConnectionConfig, Password.MigrationContext, CliPasswordProvider và ApplyCredentials. Tiếp theo, lần theo các đường dẫn kết nối dùng cho việc kết nối lại được mô tả trong database/sql, failover, cut-over và binlog-reader, rồi xác định provider được đề xuất sẽ được gọi như thế nào trước mỗi lần thử. Công việc được xem là hoàn tất khi hành vi của API và thứ tự ưu tiên được xác định và bao quát cho từng đường dẫn kết nối liên quan.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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?

Ngôn ngữ chính
Go
Star
13.6k
Fork
1.4k
Merge trung bình
9 ngày 19 giờ
Pull request đã merge (30 ngày)
1

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của github/gh-ost

Tất cả issue của github/gh-ost

Issue tương tự

Thêm issue về Go

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.