The Simplest Way to Make Firestore and LDAP Work Like They Should

Published
Length
4 min read

Luis Felipe Dias

All posts

Teams pair Firestore and LDAP in production by mapping corporate directory groups to cloud database roles. This workflow lets engineers and apps read and write document data using existing company logins. Firestore runs as a cloud document database that relies on Google identity tokens and security rules. LDAP acts as an on-premise or private cloud directory that stores users and group memberships. Because these two systems speak different protocols, they cannot talk to each other out of the bo

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 pair Firestore and LDAP in production by mapping corporate directory groups to cloud database roles. This workflow lets engineers and apps read and write document data using existing company logins.

Firestore runs as a cloud document database that relies on Google identity tokens and security rules. LDAP acts as an on-premise or private cloud directory that stores users and group memberships. Because these two systems speak different protocols, they cannot talk to each other out of the box. You must link them through a federation flow that translates directory groups into cloud identity claims.

How firestore and ldap handle logins, roles, and data flow

To make Firestore and LDAP work together, you first sync or federate your LDAP directory. Most teams link their LDAP server to Google Cloud Identity or Firebase login using SAML or OIDC. When a user logs in, the identity provider checks their username and password against LDAP. After a valid check, the provider reads the user's LDAP group attributes and issues a signed token.

That signed token carries custom claims or group roles over to Google Cloud. Firestore checks those claims inside its security rules or through Google Cloud IAM roles. If the token shows the user belongs to a database admin group, Firestore allows the write request. If the user only belongs to a read group, the database blocks any update or delete calls.

Data flows only after this identity check finishes. The client app sends the query along with the user token over an encrypted connection. Firestore evaluates the security rules against the token claims before touching the stored documents. When the rules pass, the database returns the matching documents to the client app.

Common failure modes and how to scope roles

Many teams skip full federation because setting up directory sync takes time and careful testing. Instead, they create a single Google Cloud service account key and share it across the team. Developers put this static key on their laptops or inside backend apps to run database queries. This shortcut breaks the link back to the original LDAP user.

Shared service account keys create major blind spots in your security logs. When an engineer runs a destructive delete query, the cloud audit log only shows the shared service account. You cannot tell which LDAP user ran the command or why they needed that data. Worse, if someone leaves the company, disabling their LDAP account does not revoke the shared cloud key.

Overbroad permissions cause another common failure. Teams often map a giant LDAP engineering group to a full Firestore owner role. Every developer then gets permission to read sensitive production collections, including emails, phone numbers, and card numbers. If an attacker steals one developer login, they gain full control over every production document.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, scope your LDAP groups down to specific job duties and database collections. Create separate directory groups for read-only support staff, backend apps, and database admins. Map each group to the smallest possible IAM role or custom security rule claim. Also, restrict network paths using private cloud routing so only approved networks can reach your directory and database.

Auditing and protecting sensitive document fields

Even with strict group mapping, engineers still need to inspect production documents during incidents. Cloud audit logs for document reads can grow fast and become hard to search by LDAP username. Teams need clear visibility into who queried which collection and when the query happened.

You should also protect sensitive customer fields during routine debugging sessions. Document databases often store user profiles that contain emails, phone numbers, card numbers, and national IDs. Applying data masking rewrites matched fields in results before they reach the engineer's screen. This lets support teams fix document structure bugs while keeping personal data safe.

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 Firestore talk to an LDAP server directly?

No, Firestore cannot query an LDAP server on its own. You must link LDAP to Google Cloud Identity or Firebase Auth to issue tokens that Firestore understands.

What happens when we remove a user from an LDAP group?

When you remove a user from an LDAP group, the directory sync updates their cloud identity profile. Once their current token expires, Firestore blocks them from running queries tied to that old group.

How do we stop engineers from sharing service account keys for Firestore?

Disable service account key creation in your Google Cloud team policy. Force all engineers and apps to log in through your federated LDAP flow using short-lived tokens.

Short role checks help teams work fast. Simple rules make each review clear. Good logs keep every team safe. Scoped keys stop bad changes early.

Teams test new role rules in staging first. Clear owner lists speed up each audit. Small role scopes cut down on risk. Regular log checks catch drift right away.

The query runs. The emails stay hidden.