Skip to content

feat: tenant path middleware - #321

Open
johanseto wants to merge 2 commits into
masterfrom
jlc/tenant-path-middleware
Open

feat: tenant path middleware#321
johanseto wants to merge 2 commits into
masterfrom
jlc/tenant-path-middleware

Conversation

@johanseto

@johanseto johanseto commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Descrotion

Fix tenant restriction middleware settings lookup and add coverage for path-based access control

Summary

This change adds tenant restriction middleware and adds unit tests to cover expected access behavior.

What changed

  • Updated TenantRestrictionPathMiddleware to read TENANT_RESTRICTION_PATHS from Django settings at request time instead of caching them during initialization.
  • Added unit tests covering:
    • redirecting unauthenticated users from restricted paths
    • allowing authenticated users through restricted paths
    • allowing non-restricted paths without redirect

TEsts

Configure settings with

MIDDLEWARE.append("eox_nelp.middleware.TenantRestrictionPathMiddleware")
TENANT_RESTRICTION_PATHS = [
    "/courses",
]

Check the page without session force you to be logged,

Before

2026-08-14_17-10

After

Screencast.from.14-08-26.17.15.53.webm

#Testing

Validated with:

./venv/bin/python -m pytest eox_nelp/tests/test_middleware.py -q

Result:

  • 8 passed
  • 0 failed

jira story: https://edunext.atlassian.net/browse/FUTUREX-1842?atlOrigin=eyJpIjoiNTk0M2UyMDUwNzFkNGQ4Y2JjNGU5ZDQ3YjFjZDFhZTMiLCJwIjoiaiJ9

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant