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

Unauthorized Exception not working with Werkzeug >= 15.0 #1245

Closed
biscaldis opened this issue Mar 28, 2019 · 8 comments
Closed

Unauthorized Exception not working with Werkzeug >= 15.0 #1245

biscaldis opened this issue Mar 28, 2019 · 8 comments
Milestone

Comments

@biscaldis
Copy link

@biscaldis biscaldis commented Mar 28, 2019

I'm using the demo code of Python Eve, nothing changed except for MongoDB settings. I'm trying run-auth.py in order to test basic authentication. I want Eve to raise unauthorized exception and return 401 error to the requester. Unfortunately seems that, using Werkzueg >= 15.0 the code crashes returning 500. Seems that Werkzueg changed the way to handle Unauthorized exceptions, more details here

Credit: Thanks to dmitrybelyakov which replied to my SO question.


Expected Behavior

Requester gets 401 Unauthorized.

Actual Behavior

Exception raised, the server returns 500.

[2019-03-28 12:55:32,082] ERROR in app: Exception on / [GET]
Traceback (most recent call last):
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/eve/methods/common.py", line 317, in rate_limited
    return f(*args, **kwargs)
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/eve/auth.py", line 79, in decorated
    return auth.authenticate()
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/eve/auth.py", line 152, in authenticate
    abort(401, description="Please provide proper credentials", response=resp)
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/werkzeug/exceptions.py", line 752, in abort
    return _aborter(status, *args, **kwargs)
  File "/home/biscas/code/Tools/eve-demo/venv/lib/python3.6/site-packages/werkzeug/exceptions.py", line 733, in __call__
    raise self.mapping[code](*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'response'

Environment

  • Python version: Python 3.6.7
  • Eve version: Eve==0.8.1
@nicolaiarocci
Copy link
Member

@nicolaiarocci nicolaiarocci commented Mar 28, 2019

Hi Stefano,

Thanks for reporting it. We are aware of Werkzeug breaking backward compatibility, see #1238 which is a work in progress. In Eve 0.8.2 (not released yet) we pinned to 0.14.1. As suggested in the SO question, for the time being your best bet falling back to v0.14.

@biscaldis
Copy link
Author

@biscaldis biscaldis commented Mar 29, 2019

Hi Nicola,

Thanks for your answer. Yes, I solved my issue changing the Project requirements.
Didn't saw the PR, sorry about that.

@nicolaiarocci nicolaiarocci added this to the 0.8.2 milestone Apr 3, 2019
@nicolaiarocci
Copy link
Member

@nicolaiarocci nicolaiarocci commented Apr 3, 2019

Alright, I took the plunge and upgraded Eve to support werkzeug 0.15.1+. This is a breaking change: v0.8.2 will require you to upgrade to werkzeug v0.15.1.

@masrayie
Copy link

@masrayie masrayie commented Apr 25, 2019

is it solved ? how to make it solved ? my wekzeug version is already v.0.15.2

thanks

@nicolaiarocci
Copy link
Member

@nicolaiarocci nicolaiarocci commented Apr 25, 2019

@masrayie you need Eve v0.9+

@masrayie
Copy link

@masrayie masrayie commented Apr 25, 2019

how to upgrade ? because i still new in eve, thank you

@nicolaiarocci
Copy link
Member

@nicolaiarocci nicolaiarocci commented Apr 25, 2019

pip install eve --upgrade

@masrayie
Copy link

@masrayie masrayie commented Apr 25, 2019

thanks !

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

Successfully merging a pull request may close this issue.

None yet
3 participants