【发布时间】:2017-10-27 07:57:55
【问题描述】:
我正在尝试使用 tele_notify gem: Tele Notify
这个 Gem 使用 Webhook,所以我用 Telegram 设置它:
https://api.telegram.org/bot<TOKEN>/setWebHook?url=https://<EXAMPLE.COM>/<TOKEN>
{"ok":true,"result":true,"description":"Webhook was set"}
然后在应用程序控制器中:
#app/controllers/application_controller.rb
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
#IMPORTANT! THESE TWO LINES MUST COME AFTER protect_from_forgery!
skip_before_filter :verify_authenticity_token, :only => :webhook
include TeleNotify::Controller
#other code...
end
最后是路线:
#config/routes.rb
Rails.application.routes.draw do
post '/<your token>' => 'application#webhook'
end
这段代码安全吗?有人用过这个宝石吗?
跳过真实性令牌有问题吗?
skip_before_filter :verify_authenticity_token, :only => :webhook
非常感谢!
【问题讨论】:
标签: ruby-on-rails ruby model-view-controller rubygems telegram