Created
December 17, 2012 15:24
-
-
Save sumskyi/4319095 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
http://collectiveidea.com/blog/archives/2012/12/17/inter-service-authentication-with-ssl