eve

Multi-User Restricted Access with Python Eve

随声附和 提交于 2019-12-12 23:05:08
问题 Currently, Eve v0.4 supports User-Restricted Resource Access via the 'auth_field', but it seems to be designed to automatically handle the single-owner case. How would you enable multi-user restricted access, where a user is allowed to view the resource if their id was included in an array of permitted ids? Potentially with multiple lists for separate read and write permissions. 回答1: I wrote a small hack for EVE which is adding this functionality. Maybe it's a little bit tricky, but it works.

Can I dynamically create db instances for use with mongo_prefix?

风流意气都作罢 提交于 2019-12-12 16:48:15
问题 mongo_prefix looks ideally designed for simple and effective data separation, it seems though you need to pre-define your available prefixes in settings.py. Is it possible to create a new prefix dynamically - for example to create a new instance per user on creation of that user? 回答1: The authentication base class has the set_mongo_prefix() method that allows you to set the active db based on the current user. This snippet comes from the documentation: Custom authentication classes can also

How to protect custom endpoints using BasicAuth?

梦想的初衷 提交于 2019-12-12 15:55:20
问题 Say I have enabled authentication to the resources using BasicAuth: class MyBasicAuth(BasicAuth): def check_auth(self,username,password,allowed_roles,resource,method): return username == 'secretusername' and password == 'secretpass' I also have custom routes which are used to manage documents from a HTML view. How do I use the same MyBasicAuth to protect the all the custom routes? I also need to implement logic which authenticates using the above MyBasicAuth. Please help me with this. It's

Python Eve get AUTH_FIELD value inside an Event Hook

霸气de小男生 提交于 2019-12-12 05:34:58
问题 I am using User Restricted Resource Access to isolate documents between users. Is it possible to retrieve the AUTH_FIELD value set during request authentication? I need to filter out only the documents for the current user when doing Pymongo queries in an Event Hook, the same way Eve does. 回答1: I can't tell if this is the best way, but I found the value inside the flask app under current_app.auth.get_request_auth_value() . 来源: https://stackoverflow.com/questions/35203030/python-eve-get-auth

How do I update a list data_relation in Python Eve

て烟熏妆下的殇ゞ 提交于 2019-12-12 04:54:14
问题 I have a model 'users' and a schema for it, which includes a one-to-many relation back to users: 'followers': { 'type': 'list', 'schema': { 'type': 'objectid', 'data_relation': { 'resource': 'users' } } }, I am trying to update the list of followers. I tried sending PATCH request to the /users/545c7dccb505970bbf0e5ad1 endpoint with a 'followers' key and a list of objectids but it doesn't work. Also tried sending a PUT request to /users/545c7dccb505970bbf0e5ad1/followers/ but no luck. So how

eve app deployment errors can anyone help me to fix it

强颜欢笑 提交于 2019-12-12 03:25:22
问题 [Sat Apr 09 18:27:29.953008 2016] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] mod_wsgi (pid=3230): Target WSGI script '/var/www/FlaskApps/FlaskApps.wsgi' cannot be loaded as Python module. [Sat Apr 09 18:27:29.953045 2016] [:error] [pid 3230:tid 140635784853248] [client 103.14.196.22:53950] mod_wsgi (pid=3230): Exception occurred processing WSGI script '/var/www/FlaskApps/FlaskApps.wsgi'. [Sat Apr 09 18:27:29.953065 2016] [:error] [pid 3230:tid 140635784853248]

GeoLocation API Calls against an EVE RESTful API

拟墨画扇 提交于 2019-12-11 20:37:04
问题 I easily can store geolocation Data into MongoDB with an Eve RESTful API Server running. So I store data like: loc : { lng: 13.01111, lat: 51.01111 } Validation etc. works nicely. But: I was unable to find a way to get geolocation data out of the REST API. There are sample queries over there working fine at the command-line, but there seems to be no way to query the API a appropriate way. Is there a way to throw MongoDB like Queries against the REST API or which is the prefered way to

REST API framework that works with my python program instead of Database

浪尽此生 提交于 2019-12-11 10:00:04
问题 I wanted to create a very simple REST API. I found EVE Framework very promising and I want to instead of using a Database. import my .py code and execute it and return the string. It should be something like: http://myipserver:5000/myprogram.py?string=xxx where 'xxx' is the string I'm looking to get and then evaluate it using my .py code. It'd be great if there's a way to make it work with EVE or any other Framework. I'm running Nginx. NB: my old question here, I understand that I should from

authentication token issue EVE

懵懂的女人 提交于 2019-12-11 09:09:09
问题 Hi I am using the eve token authentication (http://python-eve.org/tutorials/account_management.html#accounts-with-token-authentication) but am stuck with a 401 message. class RolesAuth(TokenAuth): def check_auth(self, token, allowed_roles, resource, method): users = app.data.driver.db['users'] lookup = {'token': token} if allowed_roles: lookup['roles'] = {'$in': allowed_roles} user = users.find_one(lookup) return user if __name__ == '__main__': app = Eve(auth=RolesAuth) app.run() I am using

Eve - Is it possible to unset a key from a document?

痞子三分冷 提交于 2019-12-11 05:01:34
问题 In a schema with optional values such as code in the example: 'code': { 'type': 'string', }, 'name': { 'type': 'string', 'required': True, }, 'email': { 'type': 'string', 'required': True } Let's say there's an inserted document with a value for code . Can I unset the code key like mongodb $unset does, using Eve somehow? 回答1: One way to achieve this is to setup a default projection for the endpoint. Limiting the Fieldset Exposed by the API Endpoint By default API responses to GET requests