Skip to content

Honor deactivation behind a proxy and keep built-in roles - #43

Merged
bricke merged 1 commit into
mainfrom
fix/proxy-users
Oct 9, 2026
Merged

bricke merged 1 commit into
mainfrom
fix/proxy-users

Conversation

@bricke

@bricke bricke commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Fixes #28. Affects only trusted-proxy mode (YARDMASTER_AUTH=proxy).

Deactivation was ignored. ProxyUser returned the account without checking Active. POST /api/admin/users/{id}/active succeeded and the user list showed the person as deactivated, but they kept full access to the UI and the gateway.

  • ProxyUser now returns ErrInactive. The UI answers 403 and the gateway 401, both saying the account is deactivated.
  • The Users page offers Deactivate/Reactivate for proxy users, with dialog text that says the proxy signing them in doesn't override it.

Built-in accounts were rewritten. ProxyUser stored the proxy's role on any account with that name, including built-in accounts from before YardMaster moved behind the proxy.

  • A proxy user admin without the admin role demoted the built-in admin. One with it promoted a built-in user.
  • Going back to built-in sign-in kept both changes, and with no admin left, the first-run setup screen would open again.
  • For built-in accounts, the proxy's role now applies to the request only. It is stored only on accounts the proxy created.

First-visit race. Two concurrent first requests for a new name raced on the insert, and the loser got a UNIQUE error (401). The insert now uses ON CONFLICT DO NOTHING and reads the row back.

The Identity section of docs/architecture.md describes the behaviour.

Tests: TestProxyUsers, TestProxyUserFirstSightRace and TestDeactivatedProxyUserIsShutOut. Each problem above reproduces on the old code.

Behind a trusted proxy, ProxyUser returned the account without checking
Active. Deactivating a proxy user through the API succeeded and listed
them as deactivated, but they kept full access to the UI and the
gateway. They are now refused, with a message naming the reason, and
the Users page offers Deactivate for proxy users too.

ProxyUser also wrote the proxy's role onto any account with that name,
including built-in ones from before YardMaster moved behind the proxy.
A proxy user named admin without the admin role demoted the built-in
admin, and one with it promoted a built-in user. Going back to built-in
sign-in kept those changes, even reopening first-run setup with no
admin left. The proxy's role now applies to the request only for
built-in accounts, and is stored only on accounts the proxy created.

Two first visits at once raced on the insert, and the loser got a
UNIQUE error; the insert now ignores the conflict and reads the row.

Fixes #28
@bricke
bricke merged commit 4701154 into main Oct 9, 2026
3 checks 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.

Proxy mode ignores deactivation, and proxy users can take over builtin accounts

1 participant