The Simplest Way to Make Compass and Keycloak Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Running Compass and Keycloak in production links a desktop database app to central user sign-in. This setup lets developers read and write document data using their single sign-on accounts. Teams use Compass to inspect collections, build queries, and check index speed on their laptops. They use Keycloak to manage user accounts, groups, and sign-in rules across the company. Linking both tools stops teams from sharing static database passwords over chat or email. Instead, every engineer logs in w

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.

Running Compass and Keycloak in production links a desktop database app to central user sign-in. This setup lets developers read and write document data using their single sign-on accounts.

Teams use Compass to inspect collections, build queries, and check index speed on their laptops. They use Keycloak to manage user accounts, groups, and sign-in rules across the company. Linking both tools stops teams from sharing static database passwords over chat or email. Instead, every engineer logs in with their own work identity before running any database query.

How Compass and Keycloak handle sign-in and permissions

A clear workflow between Compass and Keycloak starts with standard identity protocols. When an engineer opens the desktop app, they pick the federated sign-in option. The desktop client sends the user to the identity server to log in. Keycloak checks the user password and asks for a second factor if rules require it.

After a valid login, the identity server issues a signed token with group claims. Compass sends this token to the database server to start the work session. The database server checks the token signature against the public keys from the identity provider. It then reads the group claims and maps the user to internal database roles.

This flow keeps password checks out of the database and inside the identity server. Admins can add or remove a user from a group in one central place. The next time that user logs in, their database permissions update right away. Data flows back to the desktop client only if the assigned role allows that read.

Common failure modes and how to scope roles

Even with central sign-in, teams often fall back to risky habits during busy weeks. One common failure mode is keeping old shared service accounts active alongside federated login. Engineers use these shared logins when their personal token expires in the middle of debugging. Shared accounts erase the audit trail because logs show one generic name for everyone.

Broad group claims create a second major risk for production data. Teams often map a single engineering group to a full admin role on the database. This gives every developer the power to drop collections or change user records. If an attacker steals one laptop token, they gain full control over production tables.

Keycloak + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Unlogged desktop queries also create blind spots for security and compliance teams. Standard identity logs only show that a user signed in at a specific time. They do not record which documents the user read or changed during that session. Sensitive fields like emails, phone numbers, card numbers, and national IDs return in plain text. Without field-level masking that rewrites matched fields in results, raw personal data sits on laptops.

To fix these gaps, admins must scope roles down to the smallest needed action. Create separate identity groups for read-only tasks, data fixes, and schema changes. Map each group to a strict database role that touches only specific collections. Set short token lifetimes so stolen tokens stop working after a few minutes. Restrict network paths so laptops cannot reach database ports from public networks.

Auditing and protecting data in desktop workflows

Identity groups control who enters the database, but they do not inspect live queries. Security teams still need a clear record of every command run from a desktop app. Centralizing query logs lets auditors trace every read and write back to one person.

Adding field masking to the workflow also protects personal data during daily support tasks. When an engineer queries a user table, masking rules rewrite emails and card numbers. The engineer fixes the bug using safe sample values while real customer data stays protected.

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

Linking them removes static database passwords from developer laptops and local config files. When someone leaves the team, disabling their main account cuts off database sessions right away.

How should teams structure groups for database roles?

Build groups around specific job tasks rather than broad department names. Give most engineers a read-only role and require separate approval for write permissions.

What happens when an identity token expires during a session?

The desktop client must fetch a fresh token before running the next database command. If the user account is still active, the refresh step happens in a few seconds.

The query runs. The emails stay hidden.