The Simplest Way to Make Active Directory and Cloud SQL Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Integrating active directory and cloud sql lets teams log into cloud databases using existing corporate groups. This setup stops engineers from sharing static database passwords across production networks. Teams want one source of truth for user identity. They already store staff accounts and group memberships inside directory servers. Their data sits inside Google Cloud managed database instances. Connecting these two systems links daily database work to a real person. Security teams can then

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

Integrating active directory and cloud sql lets teams log into cloud databases using existing corporate groups. This setup stops engineers from sharing static database passwords across production networks.

Teams want one source of truth for user identity. They already store staff accounts and group memberships inside directory servers. Their data sits inside Google Cloud managed database instances. Connecting these two systems links daily database work to a real person. Security teams can then check who ran each query and revoke rights fast.

How active directory and cloud sql exchange identity and roles

Identity flows start inside the directory service when an engineer joins a team. Admins place the user account into a specific directory group. That group syncs to Google Cloud or maps to database roles. When the engineer wants to read data, the system checks their directory status first. If the account is active, the user gets permission to open a database session.

Inside Cloud SQL for PostgreSQL, role design works differently than self-hosted servers. Because it is a managed service, customers cannot create users with true superuser attributes. Instead, Google provides a specific role called cloudsqlsuperuser that holds some high-level rights. This role lets admins create certain extensions, event triggers, and replication users. The default postgres admin user belongs to cloudsqlsuperuser and can create roles and databases. Still, a Google-managed system user called cloudsqladmin holds the actual superuser rights. Customers cannot delete or change these built-in Cloud SQL system roles.

When directory users log in, they must map to safe local roles. Admins should never map regular directory groups straight to the default admin role. Instead, they create narrow roles inside the database for reading or writing specific tables. Directory groups then map to these narrow roles during login.

Common failure modes and how to scope database roles

Many teams try to link directory groups to databases and hit network hurdles. Directory servers often live in private data centers or separate virtual networks. If network paths break, engineers fall back to shared local database accounts. They set a password on the default postgres user and share it in chat. Once three people share one login, audit logs lose their value. You can see a bad query, but you do not know who ran it.

Overly broad group mapping is another common mistake in production setups. Teams often map a single engineering directory group to the cloudsqlsuperuser role. This gives every developer the power to create new roles or change replication settings. A simple mistake during a debug session can then break production data flows.

Active Directory + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, split database permissions by job task and data sensitivity. Create a read-only role for daily checks and a write role for fixes. Keep the default postgres user locked down for rare setup tasks only. Make sure you set a strong password on the default postgres user right away. Review directory group members every month so former staff lose database rights on time. Also, add data masking to rewrite sensitive fields like emails, phone numbers, and card numbers.

Auditing sessions across directory groups and database instances

Mapping directory identities to database roles is only half the security job. Teams also need clear logs showing what each directory user did inside the database. Native database logs can grow large and take a lot of work to parse. If an engineer leaves the company, you must cut off their active sessions fast. Waiting for a directory sync cycle can leave a window of risk open.

Security teams should review both login events and query logs every week. Match every database action back to a specific directory user account. Check that no team member uses the built-in admin account for daily work. Keep network paths private so database ports never sit open on the public internet.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can directory users get full superuser rights in Cloud SQL for PostgreSQL?

No, customers cannot create or use accounts with true superuser attributes in this service. The highest customer role is cloudsqlsuperuser, while Google keeps true superuser rights on cloudsqladmin.

What happens to the default postgres user when you create an instance?

The default postgres user is created without a password and belongs to cloudsqlsuperuser. You must set a password for it before anyone can use it to log in.

How should teams protect sensitive columns during engineering queries?

Use narrow roles and apply data masking to rewrite matched fields in query results. Masking can rewrite emails, phone numbers, card numbers, and national IDs during live sessions.

The query runs. The emails stay hidden.