Skip to content

auth_proxy: apps under path prefixes, guest routes, login lists - #59

Merged
junjihashimoto merged 1 commit into
mainfrom
feat/proxy-subpath
Nov 29, 2026
Merged

junjihashimoto merged 1 commit into
mainfrom
feat/proxy-subpath

Conversation

@junjihashimoto

Copy link
Copy Markdown
Contributor

Why

The goal is one host name, one auth_proxy and one OAuth app per machine, with several apps living side by side under path prefixes (/manager/, /grafana/, /tavern/, …). Three things were missing for that:

  • passing a path on without its prefix, for apps that cannot live below a path;
  • routes that need no sign-in, such as a guest area;
  • letting a route in for several users at once.

What

--user-map lines are now LOGIN PATH-PREFIX UPSTREAM [strip].

strip

  • The upstream gets the path without the prefix: /manager/x becomes /x, and /manager becomes /.
  • The prefix goes in X-Forwarded-Prefix. A client-sent X-Forwarded-Prefix is dropped, like every X-Forwarded-*.
  • A Location: /… the upstream answers with gets the prefix back. Absolute URLs and //host are left alone.
  • Without strip, the path is passed on unchanged, as before.

LOGIN

  • One login, or several separated by commas (alice,bob).
  • * is every signed-in user.
  • - is everyone, with no sign-in. A session, if there is one, still sets X-Forwarded-User.

Without a session

  • Any route but a - one asks to sign in first: a redirect, or 401 under the API prefix. Before, it answered 403, but signing in may open the route.
  • A signed-in login with no route still gets 403.

Sign-in

  • One sign-in covers every route, because the session cookie has Path=/.
  • Without --allowed-users, every login named in the map may sign in, comma lists included.

Matching is unchanged: the longest prefix wins, compared by whole segments after canonicalPath?, and deny wins a tie.

Tests

auth_spec (LEANTEA_TLS=1 locally): 168 passed, 0 failed. The 8 new checks cover:

  • strip with X-Forwarded-Prefix, both under the prefix and at the prefix itself;
  • 403 for a signed-in user who is not on the login list;
  • a sign-in redirect (with next) for an anonymous request to a signed-in route;
  • a - route reached both anonymously and with a session;
  • the Location rewrite;
  • one session across the /, /manager and /guest routes;
  • stripPrefix and relocate;
  • table parsing, including that an unknown option and an empty login are refused.

The full lake build passes.

Already in place (item 5 of the request)

  • Gate and proxy hardening: canonical paths, and dropping _-spelled identity headers.
  • Login CSRF: the state cookie.
  • WebSocket and state-changing requests: refused from another origin.
  • E-mail addresses used as logins only when email_verified is true.

So one host name, one auth_proxy and one OAuth app can front several
apps on a machine, a --user-map line now takes:

- `strip` after the upstream: the upstream gets the path without the
  prefix (/manager/x -> /x) and the prefix in X-Forwarded-Prefix, and a
  Location: /... it answers with gets the prefix back.
- `-` as LOGIN: no sign-in needed (a guest area); a session, if any,
  still sets X-Forwarded-User. Any other route still asks to sign in
  first when there is no session, rather than answering 403.
- several logins separated by commas; `*` is every signed-in user.

Without --allowed-users the named logins may sign in, lists included.
One sign-in covers every route (the session cookie is Path=/).
auth_spec covers each, with one session across routes.
@junjihashimoto
junjihashimoto merged commit a788d55 into main Nov 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant