Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: bq/span iam auth (#12122)

Danny Xua1d2eea723b0
diff --git a/backend/plugin/db/bigquery/bigquery.go b/backend/plugin/db/bigquery/bigquery.go
index 9e3a5bc563..f0f099fc0b 100644
--- a/backend/plugin/db/bigquery/bigquery.go
+++ b/backend/plugin/db/bigquery/bigquery.go
@@ -55,7 +55,11 @@ func (d *Driver) Open(ctx context.Context, _ storepb.Engine, config db.Connectio
d.connCtx = config.ConnectionContext
d.databaseName = config.Database
- client, err := bigquery.NewClient(ctx, config.Host, option.WithCredentialsJSON([]byte(config.Password)))
+ var o []option.ClientOption
+ if config.AuthenticationType != storepb.DataSourceOptions_GOOGLE_CLOUD_SQL_IAM {
+ o = append(o, option.WithCredentialsJSON([]byte(config.Password)))
+ }
+ client, err := bigquery.NewClient(ctx, config.Host, o...)
if err != nil {
return nil, err
}
diff --git a/backend/plugin/db/spanner/spanner.go b/backend/plugin/db/spanner/spanner.go
index f16a724ad2..fc32f436c2 100644
--- a/backend/plugin/db/spanner/spanner.go
+++ b/backend/plugin/db/spanner/spanner.go
@@ -61,17 +61,22 @@ func (d *Driver) Open(ctx context.Context, _ storepb.Engine, config db.Connectio
}
d.config = config
d.connCtx = config.ConnectionContext
+
+ var o []option.ClientOption
+ if config.AuthenticationType != storepb.DataSourceOptions_GOOGLE_CLOUD_SQL_IAM {
+ o = append(o, option.WithCredentialsJSON([]byte(config.Password)))
+ }
if config.Database != "" {
d.databaseName = d.config.Database
dsn := getDSN(d.config.Host, d.config.Database)
- client, err := spanner.NewClient(ctx, dsn, option.WithCredentialsJSON([]byte(config.Password)))
+ client, err := spanner.NewClient(ctx, dsn, o...)
if err != nil {
return nil, err
}
d.client = client
}
- dbClient, err := spannerdb.NewDatabaseAdminClient(ctx, option.WithCredentialsJSON([]byte(config.Password)))
+ dbClient, err := spannerdb.NewDatabaseAdminClient(ctx, o...)
if err != nil {
return nil, err
}