Created
October 26, 2010 13:49
-
-
Save electronicbites/646923 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
consumer_secret = <<END_OF_STRING | |
-----BEGIN PUBLIC KEY----- | |
KEY HERE HERE | |
-----END PUBLIC KEY----- | |
END_OF_STRING | |
request_proxy = OAuth::RequestProxy::ActionControllerRequest.new(request) | |
signature_base_string = request_proxy.signature_base_string | |
public_key = OpenSSL::PKey::RSA.new(consumer_secret).public_key | |
logger.error "public_key returned: #{public_key} " | |
logger.error "params[:oauth_signature]: #{params[:oauth_signature]}" | |
decoded_sig = Base64.decode64(params[:oauth_signature]) rescue '' | |
logger.error "Decode returned: #{decoded_sig} " | |
is_verified = public_key.verify(OpenSSL::Digest::SHA1.new,decoded_sig,signature_base_string) | |
logger.error "Signature verification returned: #{is_verified} " | |
render :text => "OAuth access denied", :status => :unauthorized unless is_verified |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment