def authorize_action(self): # The user might be OK. if utils.check_auth(self.model.user, self.hutch): return True # If the user isn't OK, give him or her a chance to authenticate. if self.model.user == self.myuid: self.doAuthenticate() if utils.check_auth(self.model.user, self.hutch): return True QtGui.QMessageBox.critical( None, "Error", "Action not authorized for user %s" % self.model.user, QtGui.QMessageBox.Ok, QtGui.QMessageBox.Ok) return False
def upload(): if 'client' in config and 'user' in config["client"] and 'pass' in config["client"]: auth_control = check_auth(config) if auth_control: return auth_control _file = request.files.get("file") if not _file: return "a file named as 'file' required", 400 if not allowed_file(_file.filename, config): return "invalid file type", 400 filename = secure_filename(_file.filename) full_filename = os.path.join(app.config['UPLOAD_FOLDER'], filename) try: full_filename = get_available_filename(full_filename) except ValueError as error: return error.message, 400 _file.save(full_filename) return os.path.split(full_filename)[1], 201
def web_update_ticket_contents(request): result = {'success': False} #if True: try: user, token = check_auth(request) ticket_id = request.POST['ticket_id'] contents = request.POST['contents'] update_ticket_contents( user_id = user.id, ticket_id = ticket_id, contents = contents, ) result['ticket_id'] = ticket_id result['success'] = True except: pass return make_response(result)
def decorated(*args, **kwargs): auth = request.authorization if not auth: return authenticate() elif not check_auth(auth.username, auth.password): return authenticate() return f(*args, **kwargs)
def web_complete_task(request): """ Complete a task """ result = {'user': None} result['success'] = False #if True: try: user, token = check_auth(request) task_id = request.POST['task_id'] task = complete_task(user, task_id); result['task_id'] = task.id result['success'] = True except: pass return make_response(result)
def web_create_project(request): """ Create a new project """ result = {'user': None} #if True: try: user, token = check_auth(request) name = request.POST['name'] description = request.POST['description'] project = create_new_project( user= user, name = name, description = description, ) result['project_id'] = project.id result['success'] = True except: pass return make_response(result)
def web_create_task(request): """ Get all of the organizations that the user has access to """ result = {'user': None} result['success'] = False #if True: try: user, token = check_auth(request) project_id = request.POST['project_id'] title = request.POST['title'] contents = request.POST['contents'] assigned_id = request.POST['assigned_id'] due = request.POST['due'] task = create_new_task( user = user, project_id = project_id, title = title, contents = contents, assigned_id = assigned_id, due = due, ) result['task_id'] = task.id; result['success'] = True except: pass return make_response(result)
def upload(): if 'client' in config and 'user' in config[ "client"] and 'pass' in config["client"]: auth_control = check_auth(config) if auth_control: return auth_control _file = request.files.get("file") if not _file: return "a file named as 'file' required", 400 if not allowed_file(_file.filename, config): return "invalid file type", 400 filename = secure_filename(_file.filename) full_filename = os.path.join(app.config['UPLOAD_FOLDER'], filename) try: full_filename = get_available_filename(full_filename) except ValueError as error: return error.message, 400 _file.save(full_filename) return os.path.split(full_filename)[1], 201
def web_assign_user_to_project(request): """ Assign a user to a project """ result = {} #if True: try: user, token = check_auth(request) project_id = int(request.POST['project_id']) email = request.POST['email'] target_user, assignment = assign_user_to_project( user = user, project_id = project_id, email = email, ) if assignment != None: result['assignment_id'] = assignment.id else: result['assignment_id'] = -1; result['project_id'] = project_id result['user_id'] = target_user.id result['success'] = True except: pass return make_response(result)
def add_user(self, user_id): if not check_auth(ROOT_ID, user_id): print("非root账户无权新建账户") return password_file_inode_id = self._get_password_file_inode_id() password_inode = self.get_inode(password_file_inode_id) password_list = password_inode.get_target_obj(self.fp) flag = 3 username = '******' + str(self.user_counts) password = '******' while flag > 0: username = input("输入用户名:") for item in password_list: if username == item.name: print("用户名重复") flag -= 1 continue password1 = getpass.getpass("输入密码:") password2 = getpass.getpass("确认密码:") if password1 != password2: print("密码不一致") flag -= 1 continue else: password = password1 break password_list.append(User(username, password, self.user_counts)) self.user_counts += 1 self.write_back(password_inode, pickle.dumps(password_list)) return username, self.user_counts - 1
def web_assign_user_to_ticket(request): result = {'success': False} #if True: try: user, token = check_auth(request) ticket_id = request.POST['ticket_id'] email = request.POST['email'] unassign = False try: unassign = str2bool(request.POST['unassign']) except: pass assign_user_to_ticket( user = user, ticket_id = ticket_id, email = email, unassign = unassign, ) result['ticket_id'] = ticket_id result['success'] = True except: pass return make_response(result)
def web_update_ticket_title(request): result = {'success': False} #if True: try: user, token = check_auth(request) ticket_id = request.POST['ticket_id'] title = request.POST['title'] update_ticket_title( user = user, ticket_id = ticket_id, title = title, ) result['ticket_id'] = ticket_id result['success'] = True except: pass return make_response(result)
def web_manage_project(request): result = {'user': None} #if True: try: user, token = check_auth(request) project_id = request.GET['project_id'] result['user'] = user result['project'] = get_project(user.id, project_id) result['tasks'] = get_tasks(project_id, completed=False) result['tickets'] = get_tickets(project_id) result['lists'] = [] #get_lists(project_id) #result['projects'] = get_projects(user); except: pass return result
def web_add_user(request): result = {'success': False} #if True: try: user, token = check_auth(request) organization_id = request.POST['organization_id'] user_type_id = request.POST['user_type_id'] first = request.POST['first'] last = request.POST['last'] email = request.POST['email'] password = request.POST['password'] new_user = add_user( user = user, organization_id = organization_id, user_type_id = user_type_id, first = first, last = last, email = email, password = password, ) result['new_user_id'] = new_user.id result['success'] = True except: pass return make_response(result)
def web_close_ticket(request): """ Create a new ticket """ result = {'user': None} result['success'] = False #if True: try: user, token = check_auth(request) ticket_id = request.POST['ticket_id'] ticket = close_ticket(user, ticket_id); result['ticket_id'] = ticket.id result['success'] = True except: pass return make_response(result)
def web_projectsettings(request): result = {'user': None} #if True: try: user, token = check_auth(request) result['user'] = user project_id = request.GET['project_id'] result['project'] = get_project(user.id, project_id) result['organization_users'] = get_organization_users(user.organization_id); result['assigned_users'] = get_users_assigned_to_project(user.id, project_id) result['tasks'] = get_tasks(project_id) result['tickets'] = get_tickets(project_id) except: pass return result
def web_tasks(request): result = {'user': None} #if True: try: user, token = check_auth(request) result['user'] = user project_id = int(request.GET['project_id']) completed = False try: completed = int(request.GET['completed']); except: pass result['completed'] = completed result['tasks'] = get_tasks(project_id, completed) result['project'] = get_project(user.id, project_id) except: pass return result
def web_task(request): result = {'user': None} #if True: try: user, token = check_auth(request) result['user'] = user task_id = request.GET['task_id'] #project_id = request.GET['project_id'] task = get_task(task_id) result['task'] = task result['comments'] = get_task_comments(task['id']) result['tasks'] = get_tasks(task['project_id'], completed=False) result['project'] = get_project(user.id, task['project_id']) except: pass return result
def web_owner_tickets(request): result = {'user': None} #if True: try: user, token = check_auth(request) result['user'] = user project_id = int(request.GET['project_id']) result['tickets'] = get_tickets( project_id = project_id, closed = False, unassigned = False, user_id = user.id, opened = True, ) result['project'] = get_project(user.id, project_id) except: pass return result
def web_ticket(request): result = {'user': None} #if True: try: user, token = check_auth(request) result['user'] = user ticket_id = request.GET['ticket_id'] #project_id = request.GET['project_id'] ticket = get_ticket( user_id = user.id, ticket_id = ticket_id, ) result['ticket'] = ticket result['comments'] = get_ticket_comments(user.id, ticket['id']) result['tickets'] = get_tickets(ticket['project_id']) result['assigned_users'] = get_users_assigned_to_project(user.id, ticket['project_id']) result['project'] = get_project(user.id, ticket['project_id']) except: pass return result
def web_projects(request): result = {'user': None} #if True: try: user, token = check_auth(request) result['user'] = user result['projects'] = get_user_projects(user) #build_index_projects(user, limit=25) #project_id = request.GET['project_id'] #result['project'] = get_project(user.id, project_id) #result['tasks'] = get_tasks(project_id, completed=False) #result['tickets'] = get_tickets(project_id) #result['lists'] = [] #get_lists(project_id) except: pass return result
def web_index(request): result = {'user': None} #if True: try: user, token = check_auth(request) result['user'] = user result['projects'] = build_index_projects(user, limit=25) #result['projects'] = get_user_projects(user) #result['ticket_assignments'] = get_ticket_assignments(user, limit=25) #result['task_assignments'] = get_task_assignments(user, limit=25) actions = get_actions(user, limit=25) result['actions'] = actions except: pass return result
def get(self, request, project, pk): auth_status, message = check_auth(request.user, project, 'reader') if not auth_status: return Response(message, status=status.HTTP_401_UNAUTHORIZED) component_obj = get_object(Component, project, pk) serializer = FeatureComponentSerializer(component_obj) return Response(serializer.data, status=status.HTTP_200_OK)
def get(self, request, project): auth_status, message = check_auth(request.user, project, 'reader') if not auth_status: return Response(message, status=status.HTTP_401_UNAUTHORIZED) fea_list = Feature.objects.filter(project__name=project) serializer = FeatureSerializer(fea_list, many=True) return Response(serializer.data, status=status.HTTP_200_OK)
def interface_show_view(request): data = {} data["auth"] = utils.check_auth(request) data["urlHost"] = data_utils.get_url_host_list() data["api"] = data_utils.get_api(request.GET.get("id")) data["structure"] = data_utils.get_data_structure() data["mob_version"] = data_utils.get_mob_version_list() return render(request, 'interface_show.html', {"data": data})
def index(): name = check_auth(request) votes = dict(ladder_user(name)) if name else {} return render_template( 'index.html', name=name, votes=votes, )
def get_group_view(request): data = {} data["auth"] = utils.check_auth(request) param = {} param["id"] = request.GET.get("id") param["work_id"] = request.GET.get("work_id", "") data["work_id"] = param["work_id"] data["group"] = data_utils.get_api_group_list(param) return render(request, 'api_group.html', {"data": data})
def load_files_block(self, inode: INode): """ 获取对应inode文件的内容 :return:反序列化的内容 """ if check_auth(inode.user_id, self.current_user_id): return True, inode.get_target_obj(self.fp) else: return False, None
def delete(self, request, project, pk): auth_status, message = check_auth(request.user, project, 'writer') if not auth_status: return Response(message, status=status.HTTP_401_UNAUTHORIZED) component_obj = get_object(Component, project, pk) component_obj.feature_set.clear() component_obj.delete() return Response(status=status.HTTP_204_NO_CONTENT)
def get_write_user_info_view(request): data = {} work_id = request.GET.get("work_id", "") data["work_id"] = work_id data["q"] = request.GET.get("q", "") data["flag"] = public.WRITE_FLAG data["page_current"] = request.GET.get("page_current") data["user"] = utils.get_user_info(data) data["auth"] = utils.check_auth(request) return render(request, 'set_write.html', {"data": data})
def get_user_view(request): data = {} work_id = int(request.GET.get("work_id")) if request.GET.get("work_id") else 0 data["work_id"] = work_id data["q"] = request.GET.get("q", "") data["flag"] = request.GET.get("flag", "") data["page_current"] = request.GET.get("page_current", 1) ret = data ret["user"] = utils.get_user_info(data) ret["auth"] = utils.check_auth(public.get_user_mail(request), work_id) return render(request, 'user_info.html', {'data': ret})
def get_user_view(request): data = {} work_id = int( request.GET.get("work_id")) if request.GET.get("work_id") else 0 data["work_id"] = work_id data["q"] = request.GET.get("q", "") data["flag"] = request.GET.get("flag", "") data["page_current"] = request.GET.get("page_current", 1) ret = data ret["user"] = utils.get_user_info(data) ret["auth"] = utils.check_auth(public.get_user_mail(request), work_id) return render(request, 'user_info.html', {'data': ret})
def add_work_view(request): if request.method == "POST": data = data_utils.save_api_work(request) return public.success_result_http(data) else: data = {} data["auth"] = utils.check_auth(request) id = request.GET.get("id") if id: data["work"] = data_utils.get_api_work_dict(id) else: data["work"] = {} return render(request, 'add_work.html', {"data": data})
def home(request): data = {} if request.GET.get("code"): host = request.META.get("HTTP_HOST") if host: url = "http://" + host else: url = public.WEB_URL return redirect(url) if request.method == "GET": data["auth"] = utils.check_auth(request) data["work"] = data_utils.get_api_work() return render(request, 'frame.html', {"data": data})
def web_usersettings(request): result = {'user': None} #if True: try: user, token = check_auth(request) result['user'] = user except: pass return result
def register(): login = request.args.get('login') if not login: return '/register?login=YOUR_LOGIN' auth_table = get_table('tech', 'auth') existed = check_auth(login=login) if not existed: existed = {'login': login, 'password': ''.join(random.choice(string.ascii_letters) for _ in range(10))} create_schema(login) auth_table.insert(existed) else: existed = existed[0] return jsonify(existed)
def add_interface_view(request): if request.method == "POST": ret = data_utils.save_api(request) return public.success_result_http(ret) else: data = {} data["auth"] = utils.check_auth(request) data["work_id"] = request.GET.get("work_id", "") data["group_id"] = request.GET.get("group_id", "") data["group"] = data_utils.get_api_group_list({"work_id": data["work_id"]}) data["work"] = data_utils.get_api_work() data["urlHost"] = data_utils.get_url_host_list() data["structure"] = data_utils.get_data_structure() data["api_tag"] = data_utils.get_api_tag_list() data["api"] = data_utils.get_api(request.GET.get("id")) return render(request, 'add_interface.html', {"data": data})
def main_view(request): data = {} data["auth"] = utils.check_auth(request) data["work"] = data_utils.get_api_work() data["user"] = utils.static_user_info() data["api_tag"] = data_utils.get_api_tag_count() rank = data_utils.user_top_ranking() data["user_ranking"] = {} user = models.UserInfo.objects.all() index = 0 for r in rank: r["name"] = user.get(mail=r.get("user")).name data["user_ranking"][index] = r index += 1 return render(request, 'main.html', {"data": data})
def web_database_dump(request): result = {'success': False} #if True: try: user, token = check_auth(request) result['database'] = export_database(user.id) result['success'] = True except: pass return make_response(result)
def web_new_project(request): result = {'user': None} #if True: try: user, token = check_auth(request) result['user'] = user result['projects'] = get_projects(user); except: pass return result
def add_interface_view(request): if request.method == "POST": ret = data_utils.save_api(request) return public.success_result_http(ret) else: data = {} data["auth"] = utils.check_auth(request) data["work_id"] = request.GET.get("work_id", "") data["group_id"] = request.GET.get("group_id", "") data["group"] = data_utils.get_api_group_list( {"work_id": data["work_id"]}) data["work"] = data_utils.get_api_work() data["urlHost"] = data_utils.get_url_host_list() data["structure"] = data_utils.get_data_structure() data["api_tag"] = data_utils.get_api_tag_list() data["api"] = data_utils.get_api(request.GET.get("id")) return render(request, 'add_interface.html', {"data": data})
def set_state(hutch, ioc, enable): if not utils.check_auth(pwd.getpwuid(os.getuid())[0], hutch): print "Not authorized!" sys.exit(1) (ft, cl, hl, vs) = utils.readConfig(hutch) try: utils.COMMITHOST = vs["COMMITHOST"] except: pass for c in cl: if c['id'] == ioc: c['newdisable'] = not enable do_commit(hutch, cl, hl, vs) utils.applyConfig(hutch, None, ioc) sys.exit(0) print "IOC %s not found in hutch %s!" % (ioc, hutch) sys.exit(1)
def free_up_inode(self, inode_id: int): """ 释放文件对应的inode,同时级联释放inode指向的空间 如果指向的是inode指向的是目录则递归删除 :return: """ inode = self.get_inode(inode_id) if not check_auth(inode.user_id, self.current_user_id): return False if inode.target_type == DIR_TYPE: inode_target = inode.get_target_obj(self.fp) for son_inode_id in inode_target.get_all_son_inode(): self.free_up_inode(son_inode_id) for i in range(inode.i_sectors_state): self.sp.free_up_data_block(self.fp, inode.get_sector(i)) self.sp.free_up_inode_block(self.fp, inode_id) return True
def vim(fs: FileSystem, name: str): """ 向文件中输入内容,或者是修改文件 :param fs: :param name: :return: """ if name == '-h': print(""" 编辑文件中的内容 vim file_name 不可跨层级调用 命令使用后会打开一个线程单独运行文本编辑器 """) return pwd_cat = fs.load_pwd_obj() # 当前目录 flag = pwd_cat.is_exist_son_files(name) if flag == -1: touch(fs, name) vim(fs, name) return if flag == DIR_TYPE: print("{} 是文件夹".format(name)) if flag == FILE_TYPE: inode_io = pwd_cat.get_file(name) inode = fs.get_inode(inode_id=inode_io) if check_auth(inode.user_id, fs.current_user_id): def func(): flag_x, s = fs.load_files_block(inode) if not s: s = '' te = TextEdit(s) te.run() s = te.s if len(pickle.dumps(s)) <= (13 * BLOCK_SIZE - 100): fs.write_back(inode, pickle.dumps(s)) inode.write_back(fs.fp) else: print("out of size") vim_thread = Thread(target=func) vim_thread.start() else: print("cannot edit file .: Permission denied")
def get_interface_view(request): data = {} data["in_q"] = request.GET.get("in_q", "") data["work_id"] = request.GET.get("work_id", "") data["group_id"] = request.GET.get("group_id", "") if data["work_id"]: data["work_id"] = int(data["work_id"]) data["work_name"] = data_utils.get_api_work_dict( data["work_id"]).get("name") if data["group_id"]: data["group_id"] = int(data["group_id"]) data["group_name"] = data_utils.get_api_group_dict( data["group_id"]).get("name") data["days"] = request.GET.get("days") data["o"] = request.GET.get("o") data["page_current"] = request.GET.get("page_current") data["api"] = data_utils.get_api_list(request) data["auth"] = utils.check_auth(request) return render(request, 'interface.html', {"data": data})
def upgrade(hutch, ioc, version): if not utils.check_auth(pwd.getpwuid(os.getuid())[0], hutch): print "Not authorized!" sys.exit(1) if not utils.validateDir(version, ioc): print "%s does not have an st.cmd for %s!" % (version, ioc) sys.exit(1) (ft, cl, hl, vs) = utils.readConfig(hutch) try: utils.COMMITHOST = vs["COMMITHOST"] except: pass for c in cl: if c['id'] == ioc: c['newdir'] = version do_commit(hutch, cl, hl, vs) utils.applyConfig(hutch, None, ioc) sys.exit(0) print "IOC %s not found in hutch %s!" % (ioc, hutch) sys.exit(1)
def put(self, request, project, pk): auth_status, message = check_auth(request.user, project, 'writer') if not auth_status: return Response(message, status=status.HTTP_401_UNAUTHORIZED) serializer = FeatureComponentSerializer(data=request.data) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) component_name = serializer.data['name'] if not check_name_by_id(Component, component_name, project, pk): return Response({'detail': unicode("Found same name component, " "please check your component name.")}, status=status.HTTP_409_CONFLICT) component_obj = get_object(Component, project, pk) component_obj.name = component_name component_obj.save() new_serializer = FeatureComponentSerializer(component_obj) return Response(new_serializer.data, status=status.HTTP_202_ACCEPTED)
def post(self, request, project): auth_status, message = check_auth(request.user, project, 'writer') if not auth_status: return Response(message, status=status.HTTP_401_UNAUTHORIZED) serializer = FeatureSerializer(data=request.data) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) try: fea_name = serializer.data['name'] fea_owner = serializer.data['owner'] fea_component = serializer.data['component'] fea_requirement = serializer.data['requirement'] fea_description = serializer.data['description'] except KeyError: return Response({'detail': unicode("The lack of required parameters.")}, status=status.HTTP_400_BAD_REQUEST) if not check_name(Feature, fea_name, project): return Response({'detail': unicode("Found same name feature, " "please check your feature name.")}, status=status.HTTP_409_CONFLICT) if not check_owner_runner(request.user, fea_owner): return Response({'detail': unicode("The owner should be current user - {0}".format(request.user))}, status=status.HTTP_400_BAD_REQUEST) new_fea = Feature.objects.create( name=fea_name, owner=fea_owner, component_id=fea_component, requirement_id=fea_requirement, description=fea_description, project=get_project_object(project) ) new_serializer = FeatureSerializer(new_fea) return Response(new_serializer.data, status=status.HTTP_201_CREATED)
def post(self, request, project): auth_status, message = check_auth(request.user, project, 'writer') if not auth_status: return Response(message, status=status.HTTP_401_UNAUTHORIZED) serializer = FeatureComponentSerializer(data=request.data) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) component_name = serializer.data['name'] if not check_name(Component, component_name, project): return Response({'detail': unicode("Found same name componet, " "please check your componet name.")}, status=status.HTTP_409_CONFLICT) new_component = Component.objects.create( name=component_name, project=get_project_object(project) ) new_serializer = FeatureComponentSerializer(new_component) return Response(new_serializer.data, status=status.HTTP_201_CREATED)
def put(self, request, project, pk): auth_status, message = check_auth(request.user, project, 'writer') if not auth_status: return Response(message, status=status.HTTP_401_UNAUTHORIZED) serializer = FeatureSerializer(data=request.data) if not serializer.is_valid(): return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) try: fea_name = serializer.data['name'] fea_owner = serializer.data['owner'] fea_component = serializer.data['component'] fea_requirement = serializer.data['requirement'] fea_description = serializer.data['description'] except KeyError: return Response({'detail': unicode("The lack of required parameters.")}, status=status.HTTP_400_BAD_REQUEST) if not check_name_by_id(Feature, fea_name, project, pk): return Response({'detail': unicode("Found same name feature, " "please check your feature name.")}, status=status.HTTP_409_CONFLICT) fea_obj = get_object(Feature, project, pk) if not check_owner_runner(fea_obj.owner, fea_owner): return Response({'detail': unicode("The owner can not be changed.")}, status=status.HTTP_400_BAD_REQUEST) fea_obj.name = fea_name fea_obj.owner = fea_owner fea_obj.component_id = fea_component fea_obj.requirement_id = fea_requirement fea_obj.description = fea_description fea_obj.save() new_serializer = FeatureSerializer(fea_obj) return Response(new_serializer.data, status=status.HTTP_202_ACCEPTED)
def ch_sig_dir(self, name, info=True): """ 单级目录切换 :param name: :return: """ pwd_cat = self.load_pwd_obj() if name == "..": target_id = pwd_cat.parent_inode_id if target_id == -1: return False elif name == "~": target_id = self.get_base_dir_inode_id() else: target_id = pwd_cat.get_dir(name) if target_id: inode = self.get_inode(target_id) if not check_auth(inode.user_id, self.current_user_id): if self.current_user_id != ROOT_ID: if name not in [*INIT_DIRS[1:], "~"]: if name == '..' and self.path[-2] in [*INIT_DIRS[1:], BASE_NAME]: pass else: if info: print("cannot open directory .: Permission denied") return False self.write_back_pwd_inode() self.pwd_inode = inode if name == "..": self.path_pop() elif name == "~": self.path_clear() else: self.path_add(self.get_pwd_cat_name()) return True return False
def move(hutch, ioc, hostport): if not utils.check_auth(pwd.getpwuid(os.getuid())[0], hutch): print "Not authorized!" sys.exit(1) (ft, cl, hl, vs) = utils.readConfig(hutch) try: utils.COMMITHOST = vs["COMMITHOST"] except: pass for c in cl: if c['id'] == ioc: hp = hostport.split(":") c['newhost'] = hp[0] if len(hp) > 1: c['newport'] = int(hp[1]) if not utils.validateConfig(cl): print "Port conflict when moving %s to %s, not moved!" % (ioc, hostport) sys.exit(1) do_commit(hutch, cl, hl, vs) utils.applyConfig(hutch, None, ioc) sys.exit(0) print "IOC %s not found in hutch %s!" % (ioc, hutch) sys.exit(1)
async def check_auth_middleware(request: Request): if settings.ENVIRONMENT in ('production', 'test'): body = await request.body() if not check_auth(body, request.headers.get('X-Hub-Signature', '')): raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED)
def wrapper(*args, **kwargs): auth = request.authorization if not auth or not check_auth(auth.username, auth.password): return please_authenticate() return func(*args, **kwargs)