Skip to content

Instantly share code, notes, and snippets.

@sumskyi
Created December 17, 2012 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sumskyi/4319095 to your computer and use it in GitHub Desktop.
Save sumskyi/4319095 to your computer and use it in GitHub Desktop.
class ApplicationController < ActionController::Base
before_filter :require_authentication
private
def require_authentication
unless current_certificate.verify(public_key)
head :forbidden
end
end
def public_key
@public_key ||= OpenSSL::PKey::RSA.new(ENV['AUTH_PUBLIC_KEY'])
end
def current_certificate
@current_certificate ||= OpenSSL::X509::Certificate.new(request.headers['X-SSL-Auth'])
end
def current_client
current_certificate.issuer.to_a.assoc('OU')[1]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment