Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from eve import Eve
- from eve.auth import BasicAuth
- class Authenticate(BasicAuth):
- def check_auth(self, username, password, allowed_roles, resource,
- method):
- resource_user_req_GET = resource == "user" and method == "GET"
- resource_user_req_POST = resource == 'user' and method == 'POST'
- if resource_user_req_GET:
- user = app.data.driver.db["user"]
- user = user.find_one(
- {
- "username":username,
- "password": password
- })
- if user:
- return True
- else:
- return False
- elif resource_user_req_POST:
- return username == 'admin' and password == 'admin'
- else:
- return True
- if __name__ == '__main__':
- app = Eve(auth=Authenticate)
- app.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement