示例#1
0
 def add_account(self, github_app: InstallationEvent) -> bool:
     """
     Add account to whitelist, if automatic verification of user
     (check if user is packager in fedora) fails, account is still inserted in whitelist
      with status : `waiting`.
      Then a scripts in files/scripts have to be executed for manual approval
     :param github_app: github app installation info
     :return: was the account auto-whitelisted?
     """
     account = self.get_account(github_app.account_login)
     if account:
         # the account is already in DB
         return True
     # we want to verify if user who installed the application is packager
     if Whitelist._is_packager(github_app.sender_login):
         github_app.status = WhitelistStatus.approved_automatically
         self.db[github_app.account_login] = github_app.get_dict()
         logger.info(f"Account {github_app.account_login} whitelisted!")
         return True
     else:
         logger.error(
             "Failed to verify that user is Fedora packager. "
             "This could be caused by different github username than FAS username "
             "or that user is not a packager.")
         github_app.status = WhitelistStatus.waiting
         self.db[github_app.account_login] = github_app.get_dict()
         logger.info(f"Account {github_app.account_login} inserted "
                     f"to whitelist with status: waiting for approval")
         return False
    def add_account(self, github_app: InstallationEvent) -> bool:
        """
        Add account to whitelist.
        Status is set to 'waiting' or to 'approved_automatically'
        if the account is a packager in Fedora.

        :param github_app: github app installation info
        :return: was the account (auto/already)-whitelisted?
        """
        if github_app.account_login in self.db:
            # TODO: if the sender added (not created) our App to more repos,
            #  then we should update the DB here
            return True

        # Do the DB insertion as a first thing to avoid issue#42
        github_app.status = WhitelistStatus.waiting
        self.db[github_app.account_login] = github_app.get_dict()

        # we want to verify if user who installed the application (sender_login) signed FPCA
        # https://fedoraproject.org/wiki/Legal:Fedora_Project_Contributor_Agreement
        if self._signed_fpca(github_app.sender_login):
            github_app.status = WhitelistStatus.approved_automatically
            self.db[github_app.account_login] = github_app.get_dict()
            return True
        else:
            return False
示例#3
0
    def add_account(self, github_app: InstallationEvent) -> bool:
        """
        Add account to whitelist, if automatic verification of user
        (check if user is packager in fedora) fails, account is still inserted in whitelist
         with status : `waiting`.
         Then a scripts in files/scripts have to be executed for manual approval
        :param github_app: github app installation info
        :return: was the account (auto/already)-whitelisted?
        """
        if github_app.account_login in self.db:
            # TODO: if the sender added (not created) our App to more repos,
            #  then we should update the DB here
            return True

        # Do the DB insertion as a first thing to avoid issue#42
        github_app.status = WhitelistStatus.waiting
        self.db[github_app.account_login] = github_app.get_dict()

        # we want to verify if user who installed the application (sender_login) is packager
        if self._is_packager(github_app.sender_login):
            github_app.status = WhitelistStatus.approved_automatically
            self.db[github_app.account_login] = github_app.get_dict()
            logger.info(
                f"{github_app.account_type} {github_app.account_login} whitelisted!"
            )
            return True
        else:
            logger.info(
                "Failed to verify that user is Fedora packager. "
                "This could be caused by different github username than FAS username "
                "or that user is not a packager."
                f"{github_app.account_type} {github_app.account_login} inserted "
                "to whitelist with status: waiting for approval")
            return False