Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature: DRF Permission Class #680

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

thubamamba
Copy link

When using Django Rest Framework with django-tenant-users, an example of how to ensure that TenantUser.tenants can only access their respective resources.

In this case, the use case is with SimpleJWT like so:

REST_FRAMEWORK = {
    "NON_FIELD_ERRORS_KEY": "errors",
    "DEFAULT_AUTHENTICATION_CLASSES": [
        "rest_framework_simplejwt.authentication.JWTAuthentication",
    ],
    "DEFAULT_PERMISSION_CLASSES": [
        "rest_framework.permissions.IsAuthenticated",
    ],
    "DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
    "PAGE_SIZE": 10,
}

@Dresdn
Copy link
Collaborator

Dresdn commented Sep 12, 2024

Did you push the right commit @thubamamba? I'm just seeing a bunch of import re-formatting.

@thubamamba thubamamba force-pushed the feature/drf-permission-class-example branch from aa57f08 to c015458 Compare September 13, 2024 06:36
@thubamamba
Copy link
Author

Sorry, I got caught up and didn't push at the time, i just made a push @Dresdn, please let me know if you have some code change requests.

@thubamamba
Copy link
Author

Hey @Dresdn, hope you're well. Just checking if all is good with this PR. 🙏🏽

@Dresdn
Copy link
Collaborator

Dresdn commented Sep 17, 2024

Thanks for ping and PR @thubamamba!

After reviewing it, I think we’re not quite aligned on the scope. The current PR adds a new app for DRF, but the setup is mostly standard DRF boilerplate, and doesn’t incorporate anything specific to django-tenant-users.

What I was envisioning was a more targeted example, like a custom PermissionClass that ensures a TenantUser can only access resources for tenants they belong to, addressing your original issue about users being restricted to their specific tenants.

If you could focus the implementation on that along with documentation, it would better showcase how django-tenant-users integrates with DRF.

Feel free to update the PR with this in mind!

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.

2 participants