l***@gmail.com
2018-11-13 22:16:24 UTC
Django-tenants is a package to provide multi-tenancy in Django through
Postgres schemas (https://github.com/tomturner/django-tenants/)
Django-tenants relies on setting the schema on the connection in order to
make queries to the right Postgres schema. When you want to secure your
consumers with user permissions, django-tenants needs to be properly routed
in order to retrieve the right users from database, otherwise the user in
scope is not properly populated for permission checking.
In order to overcome this, I have redefined (in a not DRY way, aka
copy/paste) `get_user`, `TenantAuthMiddleware` and
`TenantAuthMiddlewareStack`, just because I basically need to wrap
`get_user` inside `with scope["tenant"]` (provided I put the tenant in the
scope before, in a custom router.)
Is there any way to provide a hook so this can be achieved in a DRY way?
Postgres schemas (https://github.com/tomturner/django-tenants/)
Django-tenants relies on setting the schema on the connection in order to
make queries to the right Postgres schema. When you want to secure your
consumers with user permissions, django-tenants needs to be properly routed
in order to retrieve the right users from database, otherwise the user in
scope is not properly populated for permission checking.
In order to overcome this, I have redefined (in a not DRY way, aka
copy/paste) `get_user`, `TenantAuthMiddleware` and
`TenantAuthMiddlewareStack`, just because I basically need to wrap
`get_user` inside `with scope["tenant"]` (provided I put the tenant in the
scope before, in a custom router.)
Is there any way to provide a hook so this can be achieved in a DRY way?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c547563c-a8a6-416c-bf59-54907f512c77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+***@googlegroups.com.
To post to this group, send email to django-***@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c547563c-a8a6-416c-bf59-54907f512c77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.