Skip to content

Enforce login on tenant domains in OrganizationMiddleware and add tests#10

Open
oumafreddy wants to merge 1 commit intomasterfrom
codex/review-organizationmiddleware-implementation
Open

Enforce login on tenant domains in OrganizationMiddleware and add tests#10
oumafreddy wants to merge 1 commit intomasterfrom
codex/review-organizationmiddleware-implementation

Conversation

@oumafreddy
Copy link
Copy Markdown
Owner

Motivation

  • Ensure tenant (per-organization) sites require authentication before processing requests to prevent anonymous access to tenant domains.
  • Clarify middleware processing order by enforcing authentication early for tenant requests.

Description

  • Updated apps/core/middleware.py OrganizationMiddleware to return a redirect to the login page when a request.tenant is present and the request.user is not authenticated, moving the authentication enforcement earlier in the request flow.
  • Preserved existing tenant-access controls for authenticated users, including logout and an error message when a user lacks access to the current tenant.
  • Added tests in apps/users/tests/test_organization_middleware.py to cover anonymous access on the public site, required login for tenant sites, and allowed access for authenticated users belonging to the tenant.

Testing

  • Ran the new middleware tests with python manage.py test apps.users.tests.test_organization_middleware and all tests passed.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant