我試圖在基本身份驗證的我的應用程序中啓用「用戶限制的資源訪問」。 http://python-eve.org/authentication.html#user-restricted-resource-access用戶限制的資源訪問
的問題是,因爲我啓用它,我得到的API「500錯誤」
如果我火了無基本身份驗證PARAMS的API我得到一個壞證書錯誤每個HTTP請求,所以基本驗證工作正常。
這是前夜DEBUG輸出:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1836, in __call__
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1820, in wsgi_app
response = self.make_response(self.handle_exception(e))
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1403, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1817, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1477, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1381, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1475, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python2.7/dist-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1461, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/local/lib/python2.7/dist-packages/Eve-0.3-py2.7.egg/eve/methods/common.py", line 226, in rate_limited
return f(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/Eve-0.3-py2.7.egg/eve/auth.py", line 43, in decorated
if not auth.authorized(roles, resource_name, request.method):
File "/usr/local/lib/python2.7/dist-packages/Eve-0.3-py2.7.egg/eve/auth.py", line 97, in authorized
allowed_roles, resource, method)
**File "/home/maanuel/emberv/eve/run.py", line 12, in check_auth
self.set_request_auth_value(account['_id'])
AttributeError: 'BCryptAuth' object has no attribute 'set_request_auth_value'**
這似乎是set_request_auth_class
缺少
我使用的是easy_install的
[GitHub存儲庫中的bcrypt示例](https://github.com/nicolaiarocci/eve/blob/develop/examples/security/bcrypt.py)看起來簡單得多。 –
我擁有它! 來自'eve.auth'類的'set_request_auth_class()'方法在v 0.4中首次可用,而不是在我使用的v.03中。在0.3中,它是一個名爲'request_auth_value'的類屬性,您必須設置。 - >查看changelog http://python-eve.org/changelog.html#version-0-4 – user3636288
聽起來像你有一個[self-answer](http://meta.stackexchange.com/questions/ 17463/can-i-answer-my-own-questions-even-if-i-know-the-answer-before-asking)即將到來! –