The Simplest Way to Make AWS Redshift and Keycloak Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Teams pair aws redshift and keycloak to manage database log in rules from one central identity service. This setup lets analysts run SQL queries with their company credentials instead of static database passwords. Keycloak acts as the central identity provider for your staff. AWS Redshift acts as the cloud data warehouse for your company. When you link them, Keycloak sends user identity details and group names to AWS. Then AWS Redshift checks those group names and gives the user matching databa

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 aws redshift and keycloak to manage database log in rules from one central identity service. This setup lets analysts run SQL queries with their company credentials instead of static database passwords.

Keycloak acts as the central identity provider for your staff. AWS Redshift acts as the cloud data warehouse for your company. When you link them, Keycloak sends user identity details and group names to AWS. Then AWS Redshift checks those group names and gives the user matching database permissions.

How log in and roles flow between aws redshift and keycloak

The log in flow starts when a user opens a SQL client tool. The client tool asks Keycloak to verify the user identity. Keycloak checks the user password and any second factor step. After a good check, Keycloak creates a signed assertion or token.

That token holds the user email and group claims. The client sends this token to the AWS identity service. AWS reads the token and maps the user to an IAM role. Next, AWS Redshift creates or maps a database user from that role.

Database admins can map Keycloak groups straight to database groups inside the cluster. When an engineer changes teams in Keycloak, their warehouse permissions update on the next log in. Admins do not need to create or delete local accounts by hand. This workflow keeps team permissions in sync across both tools.

Common failure modes and how to scope roles

Many teams hit trouble when they rely on shared service accounts for reporting apps. When ten people share one login, audit logs cannot show who ran a bad query. Broad tokens also create risk if a laptop gets lost or stolen. If a token lasts too long, an attacker can read data for hours.

Unlogged queries cause another big issue for security teams. Native database logs might show a mapped role name instead of a real person. If sensitive fields like emails, phone numbers, or card numbers live in tables, broad roles expose them. You need clear rules to keep data safe.

Keycloak + AWS IAM Policies: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

To fix this, scope every Keycloak group to the smallest needed database role. Give read permissions only to the specific schemas a team needs for daily work. Set short token lifetimes in Keycloak so sessions expire fast. Lock down network paths so only approved networks can reach the cluster port.

Managing sensitive data and query visibility

Identity mapping solves the log in problem, but it does not filter row or column data by itself. Analysts with read roles can still pull tables with national IDs or card numbers. Data masking rules help by rewriting matched fields in query results before the user reads them.

You should also track every query back to an individual user identity from Keycloak. Good logs record the exact SQL text, the user email, and the time of the run. Reviewing these logs helps teams spot slow queries and unusual data exports early.

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

How does Keycloak pass group roles to AWS Redshift?

Keycloak puts user group names inside SAML assertions or OIDC tokens during the log in step. AWS reads those claim values and assigns the matching database groups for that session.

Why should teams avoid shared database accounts for BI tools?

Shared accounts hide which person ran a specific query in the audit log. Using individual Keycloak identities gives you a clear trail for every read and write action.

What happens when you remove a user in Keycloak?

When you disable a user in Keycloak, they cannot get a new token to log in. Existing active database sessions will end once their current token expires.

The query runs. The emails stay hidden.