Skip to content

feat: operator login and logout on tenant and console hosts - #147

Merged
OriginDevIT merged 1 commit into
mainfrom
feat/operator-login
Sep 7, 2026
Merged

feat: operator login and logout on tenant and console hosts#147
OriginDevIT merged 1 commit into
mainfrom
feat/operator-login

Conversation

@OriginDevIT

Copy link
Copy Markdown
Owner

Closes #127. Blocks nothing else in block 2; PR 4 follows.

Login and logout on both host kinds, authenticating Operator through a form that lowercases the email before authenticate(). Anonymous requests to a protected admin path redirect to login with next preserved; authenticated-without-membership keeps returning 404 on a surface, and the admin index shows a neutral landing that renders identically regardless of memberships held on other tenants.

Cookies pinned host-only, HttpOnly, SameSite Lax. Secure is gated on a new OSDS_SECURE_COOKIES variable rather than DEBUG, so an HTTP-only install has a deliberate way out. SECURE_PROXY_SSL_HEADER is set, without which the CSRF origin check compares https against http behind TLS termination and every login POST is a 403.

SetupCookieSecurityMiddleware drops Secure from the session and CSRF cookies on setup routes while setup is incomplete. Without it the first wizard POST is a 403 and the unlock flag never persists, making first boot impossible over plain http. The gate is the route plus incomplete setup, with no request.is_secure() reference, and it self-destructs when completion stops the setup URLconf resolving.

Three rows added to decisions.md section 4: authentication writes to no log, SECURE_PROXY_SSL_HEADER set while CSRF_TRUSTED_ORIGINS is not, and the wizard cookie relaxation.

23 new tests, 263 total. Verified in a browser on non-loopback hosts over plain http, which is the only way to see the Secure-flag behaviour — the test client ignores it. That pass also produced #142, #143, #144, #145 and #146, none of which block this.

Login and logout forms on both host kinds, authenticating Operator via a form that lowercases the submitted email before authenticate(). Anonymous requests to a protected admin path redirect to login with next; authenticated-without-membership still returns 404 on a surface and a neutral landing on the admin index, identical regardless of memberships held on other tenants. Session and CSRF cookies pinned host-only, HttpOnly, SameSite Lax, and Secure behind a new OSDS_SECURE_COOKIES variable rather than DEBUG. SECURE_PROXY_SSL_HEADER set so the CSRF origin check works behind TLS termination. A middleware drops Secure from the session and CSRF cookies on setup routes while setup is incomplete, without which first boot over plain http cannot pass CSRF. Slashless /admin redirects with the query string preserved. Verified in a browser on non-loopback hosts over plain http.

Closes #127

Signed-off-by: Matthew Wren <info@origindev.com>
@OriginDevIT
OriginDevIT merged commit 056cab1 into main Sep 7, 2026
1 check passed
@OriginDevIT
OriginDevIT deleted the feat/operator-login branch September 7, 2026 15:27
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.

No operator login form

1 participant