Corvia / django-tenant-users

Adds global user authentication and tenant-specific permissions to django-tenants.
https://django-tenant-users.rtfd.io
MIT License
333 stars 64 forks source link

TenantAccessMiddleware and unauthenticated users #600

Closed jgentil closed 3 months ago

jgentil commented 3 months ago

Could you help me understand the decision around why unauthenticated users can always access a tenant, but authenticated users have to have specific permission to? I don't quite understand that at all. I would expect this middleware to reject all unauthenticated users to protect the tenant?

Dresdn commented 3 months ago

The idea behind it was to fall back to Django's authentication session if not authenticated, but if authenticated, prevent automatically having access to TenantA and TenantB, if not using a permission middleware.

There are cases for everything, and this was one example as an optional middleware to showcase how it can be done since a few folks asked.

jgentil commented 3 months ago

Makes sense. Thanks for the explanation!