Skip to content

Add Cloud SQL IAM database authentication support to CloudSQL MySQL and PostgreSQL plugins - #705

Open
vishwasvaidya-cloudsufi wants to merge 2 commits into
developfrom
cloudsql-iam-auth
Open

vishwasvaidya-cloudsufi wants to merge 2 commits into
developfrom
cloudsql-iam-auth

Conversation

@vishwasvaidya-cloudsufi

Copy link
Copy Markdown
Contributor

Summary

Adds Cloud SQL IAM database authentication support to CloudSQL MySQL and CloudSQL PostgreSQL plugins (Connector, Batch Source, Batch Sink, and Action) for both Public and Private instances, while defaulting to Basic authentication for full backward compatibility.

Key Changes

  • Config, UI & Docs (cloudsql-mysql-plugin, cloudsql-postgresql-plugin):
    • Added authenticationType (basic / iam, default basic) and macro-enabled serviceAccountEmail across Connector, Source, Sink, and Action configs, widget JSONs (hiding Username/Password when IAM is selected), and plugin docs.
    • Derived DB usernames automatically from serviceAccountEmail (before @ for MySQL; without .gserviceaccount.com for PostgreSQL).
    • Public instances: sets enableIamAuth=true, cloudSqlTargetPrincipal=<serviceAccountEmail>, placeholder password, and (for PostgreSQL) defaults sslmode=disable via putIfAbsent to prevent pgjdbc hangs while preserving explicit overrides.
    • Private instances: omits password and socket-factory properties for use with Cloud SQL Auth Proxy v2 (--auto-iam-authn).
  • Validation & Shared Helpers (database-commons):
    • Added IAM helpers and validation in CloudSQLUtil (design-time + post-macro runtime validation across Connector, Source, Sink, and Action, plus auth-aware canConnect()).
    • Updated ConnectionConfig / AbstractDBConnectorConfig to resolve getUser()/getPassword() via getters and skip null passwords in Properties.
  • Tests:
    • Added unit tests in CloudSQLUtilTest, CloudSQLMySQLIamAuthTest, and CloudSQLPostgreSQLIamAuthTest, and updated connector integration tests for -DauthenticationType=iam.

Verification

  • Unit tests, Checkstyle, RAT & Enforcer (JDK 11): mvn test -pl database-commons,cloudsql-mysql-plugin,cloudsql-postgresql-plugin — all passed (102 / 13 / 14 unit tests).
  • End-to-End on Private CDF 6.11.2: Verified CloudSQLMySQL against a Private Cloud SQL MySQL 8.4 instance via Cloud SQL Auth Proxy v2 (--private-ip --auto-iam-authn) with no DB password — Connector (test, browse, sample), Source → Trash Preview & full Dataproc batch run (COMPLETED), Action, and negative macro validation all passed.

Evidence Screenshot

image

…reSQL plugins

- Support IAM database authentication (authenticationType=iam, serviceAccountEmail) in CloudSQL MySQL and PostgreSQL Connector, Batch Source, Batch Sink, and Action plugins, defaulting to Basic auth for backward compatibility.
- Support both Public instances (Cloud SQL JDBC Socket Factory enableIamAuth + cloudSqlTargetPrincipal impersonation, plus PostgreSQL sslmode=disable via putIfAbsent) and Private instances (Cloud SQL Auth Proxy v2 --auto-iam-authn).
- Validate IAM authentication at design time and runtime (post-macro resolution) and make Connector canConnect() authentication-aware.
- Update ConnectionConfig / AbstractDBConnectorConfig to use getUser()/getPassword() getters and avoid null password entries in Properties.
- Update widget JSONs, plugin documentation, unit tests, and connector integration tests.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Cloud SQL IAM database authentication support for the CloudSQL MySQL and PostgreSQL plugins, updating configurations, documentation, widgets, and validation logic across actions, sources, sinks, and connectors. Review feedback suggests refining macro validation in CloudSQLUtil to correctly handle resolved macros at runtime, and safely handling potentially null connectionTimeout values in the action configurations to prevent parsing errors.

URLDecoder.decode() changed its NumberFormatException wording in JDK 11
("Error at index 0 in" vs JDK 8 "For input string"). Match the common
URLDecoder prefix so E2E substring verification passes on JDK 11.
@vishwasvaidya-cloudsufi
vishwasvaidya-cloudsufi requested review from sahusanket and removed request for sahusanket December 4, 2026 07:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant