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

Published
Length
3 min read

Luis Felipe Dias

All posts

You pair keycloak and metabase to give your team single sign-on for business charts. Keycloak handles user log in, and Metabase runs SQL queries against your data stores. This setup lets analysts explore tables without sharing local passwords across the company. Your security team keeps one central place to add or remove user accounts. When someone leaves the team, you disable their account in one single place. Still, linking identity to an analytics app only solves half of the security puzzle.

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.

You pair keycloak and metabase to give your team single sign-on for business charts. Keycloak handles user log in, and Metabase runs SQL queries against your data stores.

This setup lets analysts explore tables without sharing local passwords across the company. Your security team keeps one central place to add or remove user accounts. When someone leaves the team, you disable their account in one single place. Still, linking identity to an analytics app only solves half of the security puzzle. You must also control how the analytics app talks to your backend databases.

How user log in and data flow between keycloak and metabase

Keycloak acts as the central identity store for your whole engineering and data team. Users open the analytics app in a browser and redirect to Keycloak first. They enter their password and pass a second factor check inside Keycloak. Then Keycloak sends a signed identity assertion back to the analytics app.

The analytics app reads this assertion to know who the user is. It also reads group names from the assertion to set up internal app permissions. You map these identity groups to local app groups inside the analytics tool. This mapping decides which charts, folders, and dashboards a given user can view.

Once the user clicks a dashboard, the data flow shifts to the database. The analytics app builds a SQL query and sends it to the database. Here is where many production setups lose track of the actual human user. The database sees the analytics app account instead of the person who logged in.

Common failure modes with shared accounts and broad permissions

Most teams link their analytics app to the database with one shared service account. Every chart and ad-hoc query runs under that single database user name. If an analyst runs a slow or risky query, the database log blames the app. You have to dig through two separate log systems to find the real person.

That shared database account often holds read rights across every table in the schema. Even if you hide a folder in the app, the SQL editor creates risk. Anyone with SQL editor rights in the app inherits the full database role. They can query sensitive tables that hold customer emails, phone numbers, or card numbers.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Token and group drift between the two tools also causes strange access bugs. If a group name changes in Keycloak, the analytics app mapping can break. Users might log in fine but land in a default group with wrong rights. You should audit your group mappings on a regular schedule to catch drift early.

Scoping database roles and network paths for analytics

Start by splitting your database roles into small, clear sets of table permissions. Create one database role for finance tables and another role for product event tables. Never let the analytics app use a superuser account or a write-enabled role. Stick to strict read-only database roles for every analytics link you set up.

Next, lock down the network path between the analytics server and the database host. Place both systems inside a private network segment that blocks public internet traffic. Use firewall rules so the database only accepts traffic from known internal hosts. Rotate the database credentials on a fixed schedule to limit the life of leaked keys.

For sensitive tables, apply data masking so queries rewrite matched fields in results. When an analyst runs a query, masking replaces emails and national IDs with safe text. This lets teams build aggregate charts while keeping raw personal fields out of spreadsheets.

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

How do I map Keycloak groups to Metabase permissions?

Include group membership claims in the identity response that Keycloak sends during log in. Then turn on group sync in Metabase and match each group name to a role.

Why do database logs only show the Metabase service account?

Metabase pools database sessions using one stored credential for each connected data source. The database only sees that shared credential unless you check app logs for user IDs.

How can I protect sensitive columns from Metabase SQL queries?

Give Metabase a restricted database role that only reads approved views or safe tables. You can also apply dynamic data masking to rewrite card numbers and phone numbers.

The query runs. The emails stay hidden.