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

User interface fails without session middleware #347

Closed
claradaia opened this issue Jun 5, 2019 · 5 comments
Closed

User interface fails without session middleware #347

claradaia opened this issue Jun 5, 2019 · 5 comments

Comments

@claradaia
Copy link

Hello, guys. I am trying to integrate silk with my existing app which does not use the atuhentication or sessions middleware. Because of that, I get the following error when I try to access /silk:

...
   File "/usr/local/lib/python3.6/site-packages/silk/views/summary.py", line 78, in get
     c = self._create_context(request)
   File "/usr/local/lib/python3.6/site-packages/silk/views/summary.py", line 57, in _create_context
     raw_filters = request.session.get(self.filters_key, {})
 AttributeError: 'WSGIRequest' object has no attribute 'session'

Is there a workaround? I considered just copying the views and tweaking until it worked, but looking at the code I wonder if the sessions are essential for the proper function of the interface. If so, maybe add a warning about that to the docs?

@mgaligniana
Copy link
Member

mgaligniana commented Dec 26, 2022

Hello!

  • As SessionMiddleware is used to persist the filters, could be a fix hide them on the UI if that is not present?

  • Regarding the AuthenticationMiddleware I think is more complicated because is used inside of user_passes_test; any possible solution? Or documentate that is required is enough?

If the changes are OK I would like to implement them!

Thank you!

@mgaligniana
Copy link
Member

@SebCorbin sorry for the ping! But let me know if the ideas above makes sense for you, thank you!

@SebCorbin
Copy link
Contributor

@mgaligniana I suggest

  • make the form agnostic from session if SessionMiddleware is not present (the test muse be hasattr(request, 'session')
  • as for AuthenticationMiddleware the SILKY_AUTHENTICATION should be enough to configure silk without auth but a simple access request.user in user_passes_test may raise an AttributeError so we may need to change that
  • add some tests with these left out in MIDDLEWARE setting using self.modify_settings or override_settings

@mgaligniana
Copy link
Member

It has been half year but finally I added some progress! Sorry for the delay 🙏

I think I completed all your suggestions @SebCorbin! Let me know if they make sense for you and any change required.

Thank you!

@mgaligniana
Copy link
Member

I think we can close this issue?

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

No branches or pull requests

3 participants