Skip to content

Instantly share code, notes, and snippets.

@mneil
Last active August 29, 2015 14:16
Show Gist options
  • Save mneil/11c9d355ea8c39e186ba to your computer and use it in GitHub Desktop.
Save mneil/11c9d355ea8c39e186ba to your computer and use it in GitHub Desktop.
Muut Ruby Federated Identites Example
@user = {
:user => {
:id => 'johndoe', # required
:displayname => 'John Doe', # required
:email => '[email protected]',
:avatar => '//gravatar.com/avatar/e5fb96fe7ec4ac3d4fa675422f8d1fb9',
:is_admin => true
}
}
require 'digest/sha1'
require 'base64'
require 'json'
# timestamp (in seconds). Improves security.
@timestamp = Time.now.to_i
# Message (base64 encoded string)
@message = Base64.strict_encode64 @user.to_json
# Signature (signed with private key)
@signature = Digest::SHA1.hexdigest "ocUxp5e20qOb7hP5Dm7j5emH #{@message} #{@timestamp}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment