GoogleCloudPlatform / GoogleCloudPlatform/cloud-sql-python-connector

Make user optional when passing enable_iam_auth

オープン
#310 コメント 2 件 リアクション 2 件 担当者 1 名 @hessjcg に割り当て済み GitHub で見る
priority: p2 type: feature request
主要言語
Python
スター
344
フォーク
89
平均マージ
5時間 33分
マージ済み PR(30日)
2

説明

## Feature Description

If I'm using this in an environment like cloud run, there really only is one account - the currently active service account. I think the default assumption is that the user that is going to be doing the proxying is also the one that is being logged in, so it's quite redundant to have to get the current service account, and then chop off the `gserviceaccount.com` as required.

A cleaner API would be to simply no longer have user required when enable_iam_auth is passed, and have the connector correctly detect service account emails and appropriately chop them, cleanly abstracting away the internals.

That would take the common use case from
```
account = detect_account()
if account.endswith(".iam.gserviceaccount.com"):
account = account.replace(".gserviceaccount.com", "")
connector.connect(MY_DB_STR, "pg8000", user=account, db=MY_DB, enable_iam_auth=True)
```
to the extremely elegant `connector.connect(MY_DB_STR, "pg8000", db=MY_DB, enable_iam_auth=True)`

## Alternatives Considered
We could continue to keep this redundant, but it's forcing the calling code to still be dealing with GCP internals.

Thank you for your consideration :P

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。