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

django authentication and permissions #119

Open
nimaansary opened this issue Aug 27, 2020 · 1 comment
Open

django authentication and permissions #119

nimaansary opened this issue Aug 27, 2020 · 1 comment

Comments

@nimaansary
Copy link

I want to check user permissions and then give him access!
how can i add middleware to django-revproxy

@nl-emmanuellodovice
Copy link

nl-emmanuellodovice commented Oct 27, 2020

I think this can easily be done by overriding get_request_headers and raising a PermissionDenied exception if the user does not have permission

class YourView(ProxyView):
    
    def get_request_headers(self):
          if not hasattr(self.request, 'user') or not self.request.user.has_perm("myapp.permission_code"):
                raise PermissionDenied()
          return super().get_request_headers()

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

No branches or pull requests

2 participants