Skip to content

Instantly share code, notes, and snippets.

@istan
Last active December 11, 2015 07:39
Show Gist options
  • Save istan/4568032 to your computer and use it in GitHub Desktop.
Save istan/4568032 to your computer and use it in GitHub Desktop.
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