Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/locales/en_US/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
5 changes: 4 additions & 1 deletion apps/locales/zh_CN/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 "发布"
msgstr "发布"

msgid "token is required for EVENT triggers"
msgstr "事件触发器必须设置 token"
5 changes: 4 additions & 1 deletion apps/locales/zh_Hant/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 "發布"
msgstr "發布"

msgid "token is required for EVENT triggers"
msgstr "事件觸發器必須設定 token"
10 changes: 6 additions & 4 deletions apps/trigger/handler/impl/trigger/event_trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions apps/trigger/serializers/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
Loading