Skip to content

Instantly share code, notes, and snippets.

@plukevdh
Created April 10, 2014 19:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save plukevdh/10415368 to your computer and use it in GitHub Desktop.
Save plukevdh/10415368 to your computer and use it in GitHub Desktop.
halogen redirect
require 'sinatra'
require 'pry'
USERNAME = 'BFGIT'
SALT = "mytestsalt"
def generate_hash(str)
Digest::SHA256.new.digest str
end
def hash_session(session_id)
hash = generate_hash([USERNAME, session_id, SALT].join(""))
hex = hash.unpack("H*").first
puts hex.length
hex
end
get "/" do
hash = hash_session(params[:sessionID])
redirect "https://ondemand.halogensoftware.com/bfgcom/signonServlet?username=#{USERNAME}&dkey=#{hash}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment