diff --git a/apps/locales/en_US/LC_MESSAGES/django.po b/apps/locales/en_US/LC_MESSAGES/django.po index 98262c54269..2bb6c26f686 100644 --- a/apps/locales/en_US/LC_MESSAGES/django.po +++ b/apps/locales/en_US/LC_MESSAGES/django.po @@ -9249,4 +9249,7 @@ msgid "The label field is required for the {index}th item in model_params_form" msgstr "" msgid "Publish" +msgstr "" + +msgid "token is required for EVENT triggers" msgstr "" \ No newline at end of file diff --git a/apps/locales/zh_CN/LC_MESSAGES/django.po b/apps/locales/zh_CN/LC_MESSAGES/django.po index cd48cb71ec2..0670f7d7dce 100644 --- a/apps/locales/zh_CN/LC_MESSAGES/django.po +++ b/apps/locales/zh_CN/LC_MESSAGES/django.po @@ -9372,4 +9372,7 @@ msgid "The label field is required for the {index}th item in model_params_form" msgstr "model_params_form 中的第 {index} 项的 label 字段是必填项" msgid "Publish" -msgstr "发布" \ No newline at end of file +msgstr "发布" + +msgid "token is required for EVENT triggers" +msgstr "事件触发器必须设置 token" \ No newline at end of file diff --git a/apps/locales/zh_Hant/LC_MESSAGES/django.po b/apps/locales/zh_Hant/LC_MESSAGES/django.po index 48890b882b6..3460c24c4d2 100644 --- a/apps/locales/zh_Hant/LC_MESSAGES/django.po +++ b/apps/locales/zh_Hant/LC_MESSAGES/django.po @@ -9369,4 +9369,7 @@ msgid "The label field is required for the {index}th item in model_params_form" msgstr "model_params_form 中的第 {index} 项的 label 字段是必填项" msgid "Publish" -msgstr "發布" \ No newline at end of file +msgstr "發布" + +msgid "token is required for EVENT triggers" +msgstr "事件觸發器必須設定 token" \ No newline at end of file diff --git a/apps/trigger/handler/impl/trigger/event_trigger.py b/apps/trigger/handler/impl/trigger/event_trigger.py index 8162ec074cc..6cc55702909 100644 --- a/apps/trigger/handler/impl/trigger/event_trigger.py +++ b/apps/trigger/handler/impl/trigger/event_trigger.py @@ -117,10 +117,12 @@ class EventTrigger(BaseTrigger): @staticmethod def execute(trigger, request=None, **kwargs): trigger_setting = trigger.get('trigger_setting') - if trigger_setting.get('token'): - token = request.META.get('HTTP_AUTHORIZATION') - if not token or trigger_setting.get('token') != token.replace('Bearer ', ''): - raise AppAuthenticationFailed(1002, _('Authentication information is incorrect')) + token = trigger_setting.get('token') + if not token: + raise AppAuthenticationFailed(1002, _('Authentication information is incorrect')) + request_token = request.META.get('HTTP_AUTHORIZATION') + if not request_token or token != request_token.replace('Bearer ', ''): + raise AppAuthenticationFailed(1002, _('Authentication information is incorrect')) is_active = trigger.get('is_active') if not is_active: return Result(code=404, message="404", response_status=404) diff --git a/apps/trigger/serializers/trigger.py b/apps/trigger/serializers/trigger.py index 30257a4e4b6..94673ad3154 100644 --- a/apps/trigger/serializers/trigger.py +++ b/apps/trigger/serializers/trigger.py @@ -243,6 +243,10 @@ def _validate_event_setting(setting): raise serializers.ValidationError({ 'trigger_setting': _('body must be an array') }) + if not setting.get('token'): + raise serializers.ValidationError({ + 'trigger_setting': _('token is required for EVENT triggers') + }) class TriggerTaskCreateRequest(serializers.Serializer):