簡體   English   中英

如何跳過'griddler-sendgrid'gem中的SPF驗證?

[英]How to skip SPF validation in 'griddler-sendgrid' gem?

我在我的ruby on rails應用程序中使用gem'griddler'與gem'griddler-sendgrid'來接收郵件。

在登台服務器上工作正常,但生產服務器出現問題。 我的配置沒有問題,我已經通過sendgrid support確認了這sendgrid support 他們告訴我僅使用DKIM validation並從驗證中刪除SPF check

我已經檢查了兩個寶石,但是沒有找到任何相關的東西。

這是我的gem配置詳細信息:

紅寶石'2.2.3'

gem'rails','4.1.2'

寶石'griddler','1.4.0'

寶石'griddler-sendgrid','1.0.0'

有人可以建議我如何跳過gem'griddler-sendgrid'中的SPF檢查驗證嗎?

提前致謝!

試圖從github獲取emails_controller.rb嗎?

https://github.com/thoughtbot/griddler

“在Rails API上用verify_authenticity_token修復ArgumentError”

protect_from_forgery with: :null_session添加了protect_from_forgery with: :null_session

我認為null_session應該在API控制器中使用,而不用於會話。 它在請求期間提供一個空會話。

https://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection/ClassMethods.html

在controllers文件夾中,griddler從Griddler github添加一個新文件,或嘗試下面的代碼。

/controllers/griddler/emails_controller.rb

class Griddler::EmailsController < ActionController::Base

  skip_before_action :verify_authenticity_token, raise: false
  protect_from_forgery with: :null_session

  def create
    normalized_params.each do |p|
      process_email email_class.new(p)
    end

    head :ok
  end

  private

  delegate :processor_class, :email_class, :processor_method, :email_service, to: :griddler_configuration

  private :processor_class, :email_class, :processor_method, :email_service

  def normalized_params
    Array.wrap(email_service.normalize_params(params))
  end

  def process_email(email)
    processor_class.new(email).public_send(processor_method)
  end

  def griddler_configuration
    Griddler.configuration
  end
end

不能完全確定整個解決方案,但希望它將有助於獲得更多指導。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM