The Simplest Way to Make Azure Active Directory and Firestore Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams link azure active directory and firestore by trading Microsoft login tokens for Google sessions. This setup lets workers and apps read or write documents using one main identity. Many groups store user accounts in Microsoft cloud systems while running apps on Google Cloud. When you join these two tools, you remove the need for separate database logins. A worker logs in once on the Microsoft side. Then Google checks that token and grants the right database permissions. How logins and rul

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.

Teams link azure active directory and firestore by trading Microsoft login tokens for Google sessions. This setup lets workers and apps read or write documents using one main identity.

Many groups store user accounts in Microsoft cloud systems while running apps on Google Cloud. When you join these two tools, you remove the need for separate database logins. A worker logs in once on the Microsoft side. Then Google checks that token and grants the right database permissions.

How logins and rules flow between azure active directory and firestore

The login flow starts when a user or app signs in to Microsoft. Microsoft checks the user and sends back a signed token with group details. Your app or backend sends this token to Google Cloud workload identity pools. Google checks the Microsoft signature against the trusted issuer details you set up.

Once Google trusts the token, it maps the Microsoft user or group to a role. You can also use Firebase Auth with OpenID Connect to take the Microsoft token directly. In that flow, Firebase makes a custom token that carries the Microsoft group claims. Firestore security rules then read those claims on every document request.

If a user belongs to the support group, the rule allows read queries on tickets. If the user is in the billing group, the rule allows write actions on invoices. Data flows back to the user only when the rule check passes. Every step relies on the original Microsoft login status.

Common failure modes and how to scope roles

A common mistake is downloading a static Google service account key for the app. Teams often put this single file on servers to skip the token exchange setup. That static key gives broad database rights to anyone who finds the file. Worse, all database queries show up in the logs under one shared bot name.

When an error or bad write happens, you cannot tell which person ran the query. Another risk comes from broad IAM roles assigned at the Google project level. If you map a whole Microsoft tenant to a broad editor role, every user gets full rights. That setup bypasses fine-grained document rules inside the database.

Active Directory + Azure RBAC: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, stop using downloaded JSON key files for your apps and engineers. Use workload identity federation so Google only trusts short-lived tokens from your Microsoft directory. Scope each Microsoft group ID to the smallest possible role in Google Cloud. Use document security rules to check custom claims for client queries.

Also lock down the network path between your app hosts and the Google APIs. Set up private service controls so database traffic stays inside trusted cloud networks. Check that your logs record the mapped user identity on every read and write. When databases store fields like emails, phone numbers, or card numbers, masking rewrites matched fields in results.

How to keep group claims in sync across both clouds

Group memberships change often when workers switch teams or leave the company. If your token lives too long, a worker might keep old database rights for hours. Set short token lifetimes in your Microsoft app settings to limit this gap. When a token expires, the client must ask Microsoft for a fresh one.

Watch out for users who belong to dozens of groups in Microsoft. Large group lists can hit size limits inside standard identity tokens. Filter the group claims in Microsoft so only database-related groups go into the token. This keeps the token small and makes your security rules easy to read.

Govern statements and responses across databases and APIs

Good config and scoped roles are needed setup. They do not check single queries in flight or mask sensitive fields in returned rows. Across Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, and internal HTTP endpoints, hoop.dev runs beside each supported service as an open-source proxy, a sidecar for your database or API.

First, hoop.dev guardrails block banned queries before they run. Then hoop.dev data masking rewrites matched sensitive values in responses in memory. The audit trail records every statement and verdict per resource. Furthermore, hoop.dev holds SOC 2 Type II and is open source on GitHub.

Frequently asked questions

Can users log in to Firestore with Microsoft accounts without static keys?

Yes, you can link Microsoft logins using OpenID Connect or workload identity federation. Both methods trade short-lived tokens so you never need to save static key files.

How do Microsoft groups control access to specific database documents?

Microsoft puts group IDs inside the login token during sign-in. Your database rules or cloud roles read those group IDs to allow or block each request.

What happens in Firestore when you disable a user in Azure Active Directory?

Microsoft stops issuing new tokens for that user right away. Once the current short-lived token expires, the database blocks all new reads and writes.

The query runs. The emails stay hidden.