The Simplest Way to Make Caddy and Onelogin Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

Using caddy and onelogin together puts single sign-on in front of your web apps. Caddy handles web traffic and TLS, while OneLogin checks who each user is. This setup lets your team log in once to reach internal tools. You do not need to build sign-in pages for every single app. Instead, the web server checks user identity before it sends traffic upstream. How caddy and onelogin handle sign-ins and permissions Caddy works as a fast web server that manages TLS certificates by itself. OneLogin

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.

Using caddy and onelogin together puts single sign-on in front of your web apps. Caddy handles web traffic and TLS, while OneLogin checks who each user is.

This setup lets your team log in once to reach internal tools. You do not need to build sign-in pages for every single app. Instead, the web server checks user identity before it sends traffic upstream.

How caddy and onelogin handle sign-ins and permissions

Caddy works as a fast web server that manages TLS certificates by itself. OneLogin serves as the central place where you store users, groups, and roles. They talk to each other using standard web sign-in protocols like OpenID Connect.

When a user visits a protected web page, Caddy stops the request first. It sees that the user does not have an active session cookie yet. Caddy then sends the browser over to the OneLogin sign-in page.

The user types in their password and finishes a multi-factor check in OneLogin. OneLogin then sends a signed token back to the web server. A third-party login plugin in Caddy reads this token and checks the signature.

Next, the server reads the user claims inside the token. These claims list the user email, group names, and assigned team roles. Caddy turns these claims into plain HTTP headers and passes them to the app.

Your internal app reads those headers to see who is making the request. This flow keeps password checks out of your app code. It also gives your security team one place to turn off user accounts.

Common failure modes and how to scope roles

Many teams make mistakes when they first link their web server and identity provider. A common error is giving every user in OneLogin the exact same broad role. If any employee can reach admin tools, one stolen password puts systems at risk.

Another frequent issue is setting session lifetimes way too long in the auth plugin. Long sessions mean a fired user might keep working in an app for days. You should set short token lifetimes so the server re-checks status often.

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

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Teams also forget to block direct network paths to the backend web apps. If an engineer can skip Caddy and hit the app port, sign-in checks fail. You must lock down the network so the app only takes traffic from Caddy.

Shared service accounts cause big problems in this workflow too. Teams often create one shared login for background scripts or alert tools. When a script breaks something, the logs do not show which person ran it.

Header spoofing is another risk you must fix right away. If Caddy does not strip incoming identity headers, a user can fake their role. Always tell the web server to clear old user headers before adding new ones.

How to keep logs clean and protect data

Good logging helps you track who used an app and what they did. Caddy can write a log line for every single web request it handles. By default, these logs only show network addresses and web paths.

You should set up your logs to include the user ID from OneLogin. Tying the user email to each web request makes security reviews much faster. You can see right away which person opened a sensitive page at night.

Be careful not to log secret session cookies or raw auth tokens. If those tokens end up in central log files, other staff might steal them. Tell your server to drop auth headers before it writes the log line.

When apps return sensitive records, data masking can rewrite matched fields in results. Masking replaces emails, phone numbers, card numbers, and national IDs before they leave. This keeps private customer details safe during daily support work.

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

Does Caddy support OneLogin out of the box?

No, the standard Caddy binary does not include a built-in OpenID Connect client. You must build Caddy with a community auth plugin or run a separate forward auth service.

How do I pass OneLogin groups to my backend app?

You set up OneLogin to include user group names inside the token claims. The Caddy auth plugin reads those claims and writes them into HTTP request headers for your app.

What happens when you remove a user in OneLogin?

OneLogin blocks the user from getting new tokens right away. Still, the user can still use the app until their current Caddy session cookie expires.

The query runs. The emails stay hidden.