![](/img/trans.png)
[英]How should I approach adding a react front-end to a web app built with rails?
[英]How can I add security to my Shopify App? (webhooks & front-end)
我正在开发带导轨的Shopify应用程序, 我想避免它在安全性方面的未来问题 。 我不知道该怎么办,所以希望您能以此为指导...
Webhooks控制器:
module ShopifyApp
class WebhooksController < ActionController::Base
include ShopifyApp::WebhookVerification
class ShopifyApp::MissingWebhookJobError < StandardError; end
def receive
params.try(:permit!)
job_args = {shop_domain: shop_domain, webhook: webhook_params.to_h}
webhook_job_klass.perform_later(job_args)
head :no_content
end
private
def webhook_params
params.except(:controller, :action, :type)
end
def webhook_job_klass
"#{webhook_type.classify}Job".safe_constantize or raise ShopifyApp::MissingWebhookJobError
end
def webhook_type
params[:type]
end
end
end
我已经阅读过有关检查Webhook的HMAC的信息,但是我不知道我是否必须自己实现它,或者上述代码是否确实在执行该操作。
关于前端 ...我应该对视图或控制器进行一些安全防护吗?
感谢您的关注和知识。
我已经读过有关它,并且不必编写Webhooks的安全性。
该行包括ShopifyApp :: WebhookVerification完成所有过程。 WebhookVerification包含在gem'shopify_api'中,因此我们只需要包含gem并复制上面的代码即可管理webhooks。
如果我们想通过Shopify管理员测试Webhook: Settings> Notifications> Webhook, 那么我们应该实现此代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.