The Simplest Way to Make Kong and SAML Work Like They Should
Running kong and saml together lets teams verify user identities at the edge. The identity provider checks the user, and Kong enforces group rules on routes. This pairing gives teams one central login flow for many web apps. Users sign in once and reach internal tools without extra password prompts. Security teams keep all user group rules inside their main identity store. How kong and saml handle logins and data flow The login flow starts when a user visits a protected route in Kong. Kong s
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 kong and saml together lets teams verify user identities at the edge. The identity provider checks the user, and Kong enforces group rules on routes.
This pairing gives teams one central login flow for many web apps. Users sign in once and reach internal tools without extra password prompts. Security teams keep all user group rules inside their main identity store.
How kong and saml handle logins and data flow
The login flow starts when a user visits a protected route in Kong. Kong sees no active session and sends the browser to the identity provider. The user logs in with their work email and multi-factor token. Then the identity provider builds a signed XML response with user details.
The browser posts this signed XML message back to the Kong endpoint. Kong checks the cryptographic signature against a stored public certificate. If the signature matches, Kong reads the user attributes and group names. Kong then creates a local session and forwards the request upstream.
Upstream apps do not need to parse XML assertions on their own. Instead, Kong passes the verified email and role names as plain HTTP headers. App teams read those headers to decide what data the user can view. This design keeps XML parsing out of individual microservices and backend APIs.
Common failure modes and how to scope roles
Certificate rotation is a common failure point in this setup. When the identity provider updates its signing key, logins fail right away. Teams must update the public key in Kong at the exact same time. Clock skew between servers can also reject valid assertions during login checks.
Broad role mapping creates another big risk for backend services. If every user gets a single generic role, sensitive routes stay exposed. Attackers who steal one session cookie can then call admin APIs. Shared test accounts also hide which real person ran a harmful write action.
SAML 2.0 + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Teams fix this by scoping SAML group claims to narrow Kong routes. Map read-only groups to GET methods and admin groups to write methods. Set short session timeouts so stolen browser cookies expire fast. Strip incoming identity headers at the edge so outsiders cannot spoof roles.
Network paths between Kong and backend apps also need strict controls. If an app accepts traffic from anywhere, users can skip the SAML check. Lock down backend firewalls so only Kong nodes can send requests. Log the user email and group name on every single API call.
Why edge logins stop short of database and admin queries
Browser assertions work well for web apps and standard REST APIs. Yet engineers also run raw queries against databases and internal servers. Standard SAML flows do not cover command line tools or database clients. Teams often fall back to shared passwords or static keys for those tasks.
When teams use shared database users, audit logs lose the real user identity. You can see that an update happened, but not who ran it. Sensitive fields like emails, phone numbers, card numbers, and national IDs stay exposed. Data masking that rewrites matched fields in results must happen at the query level.
Add runtime guardrails and masking beside your databases and APIs
Login rules, role grants, and CI checks govern who connects to your stack. Yet any allowed script, engineer, or AI agent still runs commands with the full scope of its role. For workloads on Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes, SSH, or internal HTTP services, hoop.dev sits beside the service as an open-source proxy, a sidecar for your database or API.
Before a query runs, hoop.dev guardrails check the statement against your rules. An AI Analyzer you configure can score intent or hold risky calls for human review. Next, hoop.dev data masking rewrites sensitive fields in responses, and each verdict is logged per listener. Explore the MIT-licensed project on GitHub.
Frequently asked questions
Can open source Kong use SAML without plugins?
Open source Kong needs a community plugin or an external auth service for SAML. Enterprise tiers include native support, while open source teams often run a small helper app.
How do backend apps read user details after login?
Kong extracts attributes from the XML assertion and sets them as HTTP headers. Backend apps read headers like user email and group names on each request.
What happens when a user leaves the company?
The admin disables the user in the identity provider to stop new logins. Teams should also keep Kong session lifetimes short so active sessions end fast.
Related guides
In this post