Last active
December 11, 2015 07:39
-
-
Save istan/4568032 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
def get_disqus_sso | |
data = { | |
:id => self.id, | |
:username => self.email, | |
:email => self.email | |
} | |
message = Base64.strict_encode64 data.to_json | |
timestamp = Time.now.to_i | |
pub_key = DISQUS_PUBLIC_KEY | |
secret = DISQUS_SECRET_KEY | |
digest = OpenSSL::Digest::Digest.new('sha1') | |
sig = OpenSSL::HMAC.hexdigest(digest, "#{message} #{timestamp}", secret).to_s | |
js = "<script type='text/javascript'> | |
var disqus_config = function() { | |
this.page.remote_auth_s3 = '#{message} #{sig} #{timestamp}'; | |
this.page.api_key = '#{pub_key}'; | |
} | |
</script>" | |
return js | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment