def get_users(self): if ConfigParameters.TABPY_PWD_FILE in self.settings: succeeded, credentials = parse_pwd_file( self.settings[ConfigParameters.TABPY_PWD_FILE]) if succeeded: return {"users": [user for user in credentials.keys()]} return {}
def _parse_pwd_file(self): succeeded, self.credentials = parse_pwd_file( self.settings[ConfigParameters.TABPY_PWD_FILE]) if succeeded and len(self.credentials) == 0: logger.error('No credentials found') succeeded = False return succeeded
def main(): logging.basicConfig(level=logging.DEBUG, format="%(message)s") args = docopt.docopt(__doc__) succeeded, credentials = parse_pwd_file(args["--pwdfile"]) if not succeeded and not args["add"]: return if args["--password"] is None: args["--password"] = generate_password() process_command(args, credentials) return
def main(): logging.basicConfig(level=logging.DEBUG, format="%(message)s") parser = build_cli_parser() args = parser.parse_args() if not check_args(args): parser.print_help() return succeeded, credentials = parse_pwd_file(args.pwdfile) if not succeeded and args.command != 'add': return if args.password is None: args.password = generate_password() process_command(args, credentials) return
def _process_user_request(self, option): """ Scans the password file and then invokes tabpy_user function to add or update user accordingly. """ body = json.loads(self.request.body) if "TABPY_PWD_FILE" in self.tabpy_state.settings: succeeded, credentials = parse_pwd_file( self.tabpy_state.settings["TABPY_PWD_FILE"]) if not succeeded: return False user_data = { f"{option}": True, "--username": body["username"], "--password": body["password"], } if tabpy_user.process_command(user_data, credentials): self.finish("User Added Successfully!") self.error_out(400, "No Password File in Settings.")