Users, and who gets to reach what: access control in ProxyAuth
Was this useful?
0 unique visitors
“Is this request allowed?” hides two separate questions: may this account log in here at all, and may this logged-in account reach this route. ProxyAuth answers them at two different points in a request’s life, with opposite defaults. Mixing them up is the most common way to misconfigure access, so both deserve a proper look.
Where accounts live
An account is either an entry in config.json or a row in PostgreSQL
or MySQL. Route protection does not care which: both have the same
shape, and a request is checked against both.
{
"users": [
{
"username": "alice",
"password": "$argon2id$v=19$m=19456,t=2,p=1$...",
"allow": ["203.0.113.0/24"],
"roles": ["admin"],
"groups": ["ops"],
"must_change_password": false
}
]
}
| Field | Role |
|---|---|
username, password | required. A plaintext password is replaced by its Argon2id hash on first startup. |
allow | per-account IP/CIDR allow-list. Outside it, a correct password is still refused. |
roles | route access control, and forwarded as X-User-Roles. |
groups | route access control only, no header side effect. |
email | reset addresses, one flagged primary. |
otpkey | base32 TOTP secret, normally written by enrollment, not by hand. |
must_change_password | next login goes to the reset page instead of a session. |
For database accounts, email is set with repeated --email flags and
an optional --primary-email on db-add-user. That list is
authoritative, not merged: omitting it clears what was on file.
config.json therefore holds key material — secret, token_admin,
database password, every otpkey. Restrict it to run_user and back it
up like a private key. proxyauth prepare sets those permissions on a
fresh install.
Gate one: may this account log in on this vhost?
Checked once, at login, before any session exists:
vhosts:
- vhost: ["admin.example.com"]
allow_users: ["alice"]
allow_groups: ["ops"]
allow_roles: ["admin"]
exclude_users: ["contractor-temp"]
The evaluation:
- Username in
exclude_users? Denied, whatever else is true. allow_users,allow_groupsandallow_rolesall empty? Denied.- Username listed, or member of an allowed group, or holder of an allowed role? Login proceeds. Otherwise denied.
Point 2 is the one to remember: a vhost that names nobody accepts no login. Adding a new domain to a live instance does not hand it every account in the system. You open it by naming who belongs.
Routes with no vhost sit outside this mechanism: there is no vhost to
authorize against, and login proceeds on credentials alone.
Gate two: may this logged-in account reach this route?
Checked on every request to the route:
routes:
- prefix: "/admin"
target: "http://127.0.0.1:8000"
required_login: true
groups: ["ops"]
roles: ["admin"]
username, groups and roles combine as an OR: one match is
enough. And here the default flips: all three empty means any
authenticated account.
The asymmetry is deliberate. Gate one decides who is vetted at all, so silence means no. Gate two decides how far a vetted visitor goes, so silence means “not narrowing further”.
The classic mistakes follow directly:
- leaving a vhost’s allow-lists empty expecting “anyone who can log in” — nobody can;
- setting
groupson a route expecting it to also restrict who can log in — it does not; that is gate one’s job.
Layering the two
vhosts:
- vhost: ["intranet.example.com"]
allow_groups: ["staff", "contractors"] # gate one
routes:
- prefix: "/"
target: "http://127.0.0.1:8000"
required_login: true # any vetted account
- prefix: "/finance"
target: "http://127.0.0.1:8000"
required_login: true
groups: ["finance"] # gate two narrows
allow_ips: ["10.20.0.0/16"] # and the network too
Longest prefix wins, so /finance is matched before / whatever the
order in the file.
roles versus groups
Both gate routes, and a user needs only one match. The difference is what leaves ProxyAuth:
X-User: alice
X-User-Roles: admin,ops
X-User-Groups: engineering
roles predates route-level access control; it was originally only a
header for the backend’s own authorization logic, and it still is. Use
it when the backend needs to know. Use groups when the grouping only
means something to the gateway.
In the database, this shows: groups are a real parent table with a
foreign key, so a typo cannot create a phantom group and a rename is one
UPDATE. Roles are free text, because an unknown role is a legitimate
value for a backend to interpret.
Prove it: the audit CLI
The access decision is a single function that reports why access was granted — by username, by a named group, by a named role, or because the route is open. The CLI calls that same function, so it cannot drift from what the proxy enforces.
proxyauth routes-audit # what secures each route
proxyauth check-access --username alice # ✓ / ✗ per route, with the reason
proxyauth check-routes # concrete accounts per route
proxyauth users --list
proxyauth groups --list
proxyauth roles --list
check-routes flags a route whose group or role matches no current
account — usually a typo, sometimes a leftover.
Run check-access after every change to a vhost’s allow-lists. It is
the fastest way to catch gate one being closed when you meant it open.
Around the two gates
Other protections do not care about identity and sit beside these
checks: ip_blocklists before routing, redirect_protect before
authentication, route allow_ips/deny_ips, allow_methods, request
filters, rate limiting and CSRF.
And one case changes the model entirely: on a vhost with oidc:, route
username/groups/roles stop applying, because the backend owns the
decision. Gate one still applies there — it runs inside
/oidc/authorize.
Closed until you open it at the vhost, open until you narrow it at the route. Two gates, two defaults, one decision function — and a CLI that tells you exactly which rule let someone in.