def get(self): SetCORS(self.response, self.request) roles = [] username = '' action = '' id = None node = self.request.path_info.split('/')[3:] if node[-1] == '': node.pop(-1) action = node[0] if len(node) > 1: id = node[1] auth = self.request.headers.get('Authorization','').split(' '); if auth[0] == 'Fake': username = auth[2] if username != '' and action == 'UserInfo': user = User.query(User.email == username).get(); if user: userid = user.key.id() roles = user.roles obj = { 'userid': userid, 'userName': username, 'roles': roles, } self.response.write(json.dumps(obj)) else: self.abort(403)
def post(self): SetCORS(self.response, self.request) request = unicode(self.request.body, 'utf-8') data = urlparse.parse_qs(request) username = data['username'][0] if username: user = User.query(User.email == username).get(); if user: obj = { 'token_type': 'Fake', 'access_token': username , } self.response.write(json.dumps(obj)) else: self.abort(401)