conference-opportunities/conference-opportunities

View on GitHub
app/controllers/lets_encrypt_verifications_controller.rb

Summary

Maintainability
A
0 mins
Test Coverage
class LetsEncryptVerificationsController < ApplicationController
  class LetsEncryptCheck < Struct.new(:challenge, :response)
    def self.create
      new(ENV['LETS_ENCRYPT_CHALLENGE'], ENV['LETS_ENCRYPT_RESPONSE'])
    end

    def valid?(request)
      request == challenge
    end
  end

  def show
    skip_authorization
    check = LetsEncryptCheck.create
    if check.valid?(params[:id])
      render plain: check.response
    else
      render status: :forbidden, plain: ''
    end
  end
end