Created
January 30, 2014 19:35
-
-
Save DeskWOW/8717015 to your computer and use it in GitHub Desktop.
Ruby code example of multipass endpoint
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
post '/login' do | |
user = params[:user] | |
password = params[:password] | |
if user == "ty" && password == "password" | |
SITE_KEY = "zzz-ty-multipass" | |
API_KEY = "4a5b3be36eac5363893a43035e02d048" # Example dummy key | |
multipass_string = MultiPass.encode( | |
SITE_KEY, | |
API_KEY, | |
:customer_name => "Ty", | |
:customer_email => "[email protected]", | |
:uid => "123", | |
:customer_custom_number => 25, | |
:customer_custom_truefalse => "1", | |
:expires => (Time.now + 120), # Expire two minutes from now | |
:url_safe => true | |
) | |
signature = CGI.escape(Base64.encode64(OpenSSL::HMAC.digest('sha1', API_KEY, multipass_string))) | |
redirect 'http://brand2.desk.moonkin.com/customer/authentication/multipass/callback?multipass='+multipass_string+'&signature='+signature | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment