Sha256: b10cfe8247afd691fdfa7a252419d97af6c343a79e57639c4a9d5919852d2871

Contents?: true

Size: 428 Bytes

Versions: 18

Compression:

Stored size: 428 Bytes

Contents

module ValidateSignature
  extend ActiveSupport::Concern

  included do
    before_action do
      render file: "#{Rails.root}/public/404.html", layout: false, status: :not_found unless has_valid_signature?
    end
  end

  private

  def has_valid_signature?
    request.original_url.split('?')[0] == ActiveSupport::MessageVerifier.new(ENV.fetch('RAILS_MASTER_KEY', '')).verify(params[:signature])
  rescue
    false
  end
end

Version data entries

18 entries across 9 versions & 1 rubygems

Version Path
kaze-0.18.0 stubs/hotwire/app/controllers/concerns/validate_signature.rb
kaze-0.18.0 stubs/inertia-common/app/controllers/concerns/validate_signature.rb
kaze-0.17.0 stubs/hotwire/app/controllers/concerns/validate_signature.rb
kaze-0.17.0 stubs/inertia-common/app/controllers/concerns/validate_signature.rb
kaze-0.16.0 stubs/inertia-common/app/controllers/concerns/validate_signature.rb
kaze-0.16.0 stubs/hotwire/app/controllers/concerns/validate_signature.rb
kaze-0.15.0 stubs/hotwire/app/controllers/concerns/validate_signature.rb
kaze-0.15.0 stubs/inertia-common/app/controllers/concerns/validate_signature.rb
kaze-0.14.0 stubs/inertia-common/app/controllers/concerns/validate_signature.rb
kaze-0.14.0 stubs/hotwire/app/controllers/concerns/validate_signature.rb
kaze-0.13.0 stubs/inertia-common/app/controllers/concerns/validate_signature.rb
kaze-0.13.0 stubs/hotwire/app/controllers/concerns/validate_signature.rb
kaze-0.12.0 stubs/inertia-common/app/controllers/concerns/validate_signature.rb
kaze-0.12.0 stubs/hotwire/app/controllers/concerns/validate_signature.rb
kaze-0.11.0 stubs/hotwire/app/controllers/concerns/validate_signature.rb
kaze-0.11.0 stubs/inertia-common/app/controllers/concerns/validate_signature.rb
kaze-0.10.0 stubs/inertia-common/app/controllers/concerns/validate_signature.rb
kaze-0.10.0 stubs/hotwire/app/controllers/concerns/validate_signature.rb