mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 14:42:32 -05:00
validate webhook header
This commit is contained in:
1 parent
9941122d90
commit
85fbae1813
1 file changed
+9
-1
@@ -3,11 +3,19 @@
|
|||||||
class WebhookSecretController < ApplicationController
|
class WebhookSecretController < ApplicationController
|
||||||
load_and_authorize_resource :webhook_url, parent: false
|
load_and_authorize_resource :webhook_url, parent: false
|
||||||
|
|
||||||
|
HEADER_NAME_REGEXP = /\A[\w-]+\z/
|
||||||
|
|
||||||
def show; end
|
def show; end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
|
key = webhook_secret_params[:key]
|
||||||
|
|
||||||
|
if key.present? && !HEADER_NAME_REGEXP.match?(key)
|
||||||
|
return redirect_back(fallback_location: settings_webhook_path(@webhook_url), alert: I18n.t('unable_to_save'))
|
||||||
|
end
|
||||||
|
|
||||||
@webhook_url.update!(secret: {
|
@webhook_url.update!(secret: {
|
||||||
webhook_secret_params[:key] => webhook_secret_params[:value]
|
key => webhook_secret_params[:value]
|
||||||
}.compact_blank)
|
}.compact_blank)
|
||||||
|
|
||||||
redirect_back(fallback_location: settings_webhook_path(@webhook_url),
|
redirect_back(fallback_location: settings_webhook_path(@webhook_url),
|
||||||
|
|||||||
Reference in new issue
Block a user