The Simplest Way to Make BigQuery and SAML Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Pairing bigquery and saml lets your team log in with single sign-on credentials. SAML checks user identity while BigQuery runs data queries based on cloud roles. This setup links your identity provider straight to your Google Cloud workspace. Analysts log in once and run SQL queries without static keys. Admins manage group memberships in one central directory for the whole company. When someone leaves the team, revoking their directory account stops their database queries. How bigquery and sa

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.

Pairing bigquery and saml lets your team log in with single sign-on credentials. SAML checks user identity while BigQuery runs data queries based on cloud roles.

This setup links your identity provider straight to your Google Cloud workspace. Analysts log in once and run SQL queries without static keys. Admins manage group memberships in one central directory for the whole company. When someone leaves the team, revoking their directory account stops their database queries.

How bigquery and saml handle login and data flow

BigQuery does not read SAML assertions straight from your identity provider. Instead, Google Cloud uses workforce identity federation to bridge the two systems. Your user tries to log in to their cloud console or desktop tool. Google Cloud sends the user to your SAML identity provider to sign in.

The identity provider checks the user password and multi-factor prompt. Then it sends a signed SAML response back to Google Cloud. Google Cloud reads the attributes and group claims inside that XML message. It maps those claims to cloud roles that control dataset permissions.

Once the login succeeds, the user gets a short-lived cloud session token. Their SQL client uses this token to send queries to the BigQuery engine. BigQuery checks the cloud role before it reads any table or view. The query runs and returns results to the user over an encrypted link.

Common failure modes with shared accounts and broad roles

Many teams struggle when connecting desktop BI tools or local scripts to SAML. Some legacy tools do not support browser-based SAML login flows out of the box. To work around this, engineers often create a shared cloud service account. They download a static JSON key file and share it across the team.

This shortcut breaks the whole point of using single sign-on for data. Every query in the audit log now shows the same service account name. You cannot tell which person ran an expensive or risky query. Worse, static key files end up on laptops and inside code repos.

SAML 2.0 + BigQuery IAM: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Overbroad group mapping is another common flaw in production setups. Teams map a single SAML group to a wide project editor role. Every analyst in that group can then read raw tables with sensitive fields. If a table holds emails, phone numbers, or card numbers, anyone can query them.

To fix this, ban downloadable service account keys across your cloud projects. Require every human user to log in through the SAML workforce pool flow. Map specific SAML groups to narrow roles at the dataset level. Grant read permissions only on the exact datasets a team needs for work.

Scoping network paths and protecting query results

Good identity rules are only half of a safe data setup. You also need to control where users can run queries from. Set up context rules that check the user device and IP address. Block SAML login attempts that come from unknown networks or unmanaged laptops.

Keep audit logs turned on for both your identity provider and cloud data. Log every login event alongside every SQL job that touches your datasets. Check these logs often to spot odd query volume or off-hours activity. Clear logs help your security team trace incidents back to a real user.

You should also protect sensitive columns inside your tables before queries finish. Raw tables often contain emails, phone numbers, card numbers, or national IDs. Relying only on table-level roles leaves these fields exposed to broad analyst groups. Masking rewrites matched fields in results before they reach the user screen.

Add runtime guardrails and masking beside your databases and APIs

Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.

Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.

Frequently asked questions

Does BigQuery support SAML logins directly?

No, BigQuery relies on Google Cloud workforce identity federation to read SAML assertions. Google Cloud handles the SAML exchange and issues a session token for queries.

Why do teams still use service account keys with SAML?

Some third-party SQL clients and scripts lack support for browser SAML login flows. Teams fall back to static keys instead of setting up federated token flows.

How can we stop analysts from pulling sensitive columns?

Scope SAML groups to narrow dataset roles and apply data masking to results. Masking rewrites emails, phone numbers, and card numbers before the query output returns.

The query runs. The emails stay hidden.