SAML Load Balancer

Published
Length
3 min read

Luis Felipe Dias

All posts

You set up a saml load balancer by linking your load balancer to your identity provider. The load balancer then checks user logins before it sends traffic to your backend web apps. Most teams use this setup to add single sign-on to older internal tools. Still, broad group rules often give users full entry to every path behind the balancer. How a saml load balancer works in practice A saml load balancer sits at the edge of your network and takes incoming web traffic. When a user visits an inte

SAML 2.0: the complete guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free white paper. No spam. Unsubscribe anytime.

You set up a saml load balancer by linking your load balancer to your identity provider. The load balancer then checks user logins before it sends traffic to your backend web apps. Most teams use this setup to add single sign-on to older internal tools. Still, broad group rules often give users full entry to every path behind the balancer.

How a saml load balancer works in practice

A saml load balancer sits at the edge of your network and takes incoming web traffic. When a user visits an internal app, the load balancer stops the first web request. It checks for a valid session cookie on the user browser right away. If no cookie exists, the load balancer sends the user to the identity provider.

The user then enters a name, password, and second factor at the identity provider screen. Once the login succeeds, the identity provider creates a signed XML file called an assertion. This file holds the user email, group names, and role details for that session. The browser sends this signed XML file back to the load balancer callback path.

Next, the load balancer checks the digital signature using a public key from the provider. If the signature matches, the load balancer sets a session cookie for the user. It also puts the user email and group names into HTTP headers. Then it sends the request to a healthy backend web server in the pool.

Managing sessions and user groups at the edge

Teams must also plan how the load balancer tracks active sessions across many nodes. If you run more than one balancer node, each node must read the same session state. Some teams use signed cookies so any node can check the session on its own. Other teams store session data in a shared memory store behind the edge nodes.

You also have to map identity provider groups to the right backend server pools. Most teams write routing rules that check the group header before sending traffic forward. For example, finance users go to the billing app while engineers go to admin tools. Keep these group lists small so users do not gain extra rights by mistake.

SAML 2.0: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

What edge login solves and what it misses

Putting SAML on your load balancer solves a big problem for internal web apps. You do not have to write login code into every single backend web app. Old tools that lack modern login support get single sign-on and multi-factor checks fast. When someone leaves the team, you block their account in one central place.

Still, a load balancer only checks who logs in at the front door. Once a user passes the check, the balancer sends all requests to the backend app. It does not inspect what individual API calls, database queries, or commands do in flight. It also cannot mask sensitive fields like emails, phone numbers, or card numbers in responses.

Also, backend apps often trust the HTTP headers from the load balancer without extra checks. If a user has a valid session, they can run risky actions inside the app. Standard load balancer logs only show web paths and status codes for each request. They do not record the full context of data changes or admin actions.

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

Why use SAML on a load balancer instead of OIDC?

Many enterprise identity systems and older corporate apps already run on SAML standards. Using SAML on the load balancer lets you reuse those existing group rules and certificates.

How do backend apps know which user is logged in?

The load balancer reads the SAML assertion and writes user traits into HTTP request headers. Your backend app reads those headers to see the user email and group names.

What happens when the SAML certificate expires?

The load balancer will reject all new login responses if the signing key expires. Teams must rotate certificates in both the identity provider and the load balancer before expiration.

Save the open-source gateway.

hoop is MIT-licensed infrastructure for controlling how AI agents reach production data. Star hoophq/hoop so you can inspect it, deploy it, or share it when your team starts governing agent access.