Example #1
0
    def update_signatures(self):
        """
        Update the signatures on all Actions in the queryset.
        """
        # Convert to a list because order must be preserved
        actions = list(self)

        try:
            autographer = Autographer()
        except ImproperlyConfigured:
            for action in actions:
                action.signature = None
                action.save()
            return

        action_names = [a.name for a in actions]
        logger.info(
            f'Requesting signatures for actions named [{action_names}] from Autograph',
            extra={
                'code': INFO_REQUESTING_ACTION_SIGNATURES,
                'action_names': action_names
            })

        canonical_jsons = [a.canonical_json() for a in actions]
        signatures_data = autographer.sign_data(canonical_jsons)

        for action, sig_data in zip(actions, signatures_data):
            signature = Signature(**sig_data)
            signature.save()
            action.signature = signature
            action.save()
Example #2
0
    def update_signatures(self):
        """
        Update the signatures on all Recipes in the queryset.
        """
        # Convert to a list because order must be preserved
        recipes = list(self)

        try:
            autographer = Autographer()
        except ImproperlyConfigured:
            for recipe in recipes:
                recipe.signature = None
                recipe.save()
            return

        recipe_ids = [r.id for r in recipes]
        logger.info(
            f'Requesting signatures for recipes with ids [{recipe_ids}] from Autograph',
            extra={
                'code': INFO_REQUESTING_RECIPE_SIGNATURES,
                'recipe_ids': recipe_ids
            })

        canonical_jsons = [r.canonical_json() for r in recipes]
        signatures_data = autographer.sign_data(canonical_jsons)

        for recipe, sig_data in zip(recipes, signatures_data):
            signature = Signature(**sig_data)
            signature.save()
            recipe.signature = signature
            recipe.save()
Example #3
0
    def update_signature(self):
        try:
            autographer = Autographer()
        except ImproperlyConfigured:
            self.signature = None
            return

        logger.info(
            f"Requesting signature for action named {self.name} from Autograph",
            extra={"code": INFO_REQUESTING_ACTION_SIGNATURES, "action_names": [self.name]},
        )

        signature_data = autographer.sign_data([self.canonical_json()])[0]
        signature = Signature(**signature_data)
        signature.save()
        self.signature = signature
Example #4
0
    def update_signature(self):
        try:
            autographer = Autographer()
        except ImproperlyConfigured:
            self.signature = None
            return

        logger.info(
            f'Requesting signatures for recipes with ids [{self.id}] from Autograph',
            extra={
                'code': INFO_REQUESTING_RECIPE_SIGNATURES,
                'recipe_ids': [self.id]
            })

        signature_data = autographer.sign_data([self.canonical_json()])[0]
        signature = Signature(**signature_data)
        signature.save()
        self.signature = signature
Example #5
0
    def update_signature(self):
        try:
            autographer = Autographer()
        except ImproperlyConfigured:
            self.signature = None
            return

        logger.info(
            f'Requesting signature for action named {self.name} from Autograph',
            extra={
                'code': INFO_REQUESTING_ACTION_SIGNATURES,
                'action_names': [self.name]
            })

        signature_data = autographer.sign_data([self.canonical_json()])[0]
        signature = Signature(**signature_data)
        signature.save()
        self.signature = signature
Example #6
0
    def update_signature(self):
        try:
            autographer = Autographer()
        except ImproperlyConfigured:
            self.signature = None
            return

        # Don't sign recipe that aren't enabled
        if not self.enabled:
            return

        logger.info(
            f"Requesting signature for recipe with id {self.id} from Autograph",
            extra={"code": INFO_REQUESTING_RECIPE_SIGNATURES, "recipe_ids": [self.id]},
        )

        signature_data = autographer.sign_data([self.canonical_json()])[0]
        signature = Signature(**signature_data)
        signature.save()
        self.signature = signature
Example #7
0
    def update_signature(self):
        try:
            autographer = Autographer()
        except ImproperlyConfigured:
            self.signature = None
            return

        # Don't sign recipe that aren't enabled
        if not (self.approved_revision and self.approved_revision.enabled):
            return

        logger.info(
            f"Requesting signature for recipe with id {self.id} from Autograph",
            extra={
                "code": INFO_REQUESTING_RECIPE_SIGNATURES,
                "recipe_ids": [self.id]
            },
        )

        signature_data = autographer.sign_data([self.canonical_json()])[0]
        signature = Signature(**signature_data)
        signature.save()
        self.signature = signature