def user_service(name): if request.method == 'GET': return Users().lookup(name) elif request.method == 'PUT': return Users().edit(name, jdata()) elif request.method == 'DELETE': return Users().delete(name)
def check_auth(username, password): u = Users() all = u.list(internal=True) if len(all) == 0 and (username == DEFAULT_USER and password == DEFAULT_PASS): u.add(dict(name=DEFAULT_USER, _password=DEFAULT_PASS)) return True return u.login(username, password)
def hello_world(): return dict( rest_resources=dict( users=dict(href='/api/users/', fields=Users().FIELDS), hosts=dict(href='/api/hosts/', fields=Hosts().FIELDS), groups=dict(href='/api/groups/', fields=Groups().FIELDS), ), version=VERSION, )
def check_auth(username, password): u = Users() all = u.list(internal=True) if len(all) == 0 and (username == DEFAULT_USER and password == DEFAULT_PASS): u.add(dict(name=DEFAULT_USER, _password=DEFAULT_PASS)) return True if not u.login(username, password): log("login failed: %s" % (username)) return False else: log("login successful: %s" % (username)) return True
def users_service(): if request.method == 'GET': return Users().list() elif request.method == 'POST': return Users().add(jdata())