Last active
March 14, 2019 13:05
Revisions
-
pbertera revised this gist
Sep 22, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -19,4 +19,4 @@ def get_sso_url(email, name, base_url, key, redirect_url=None, phone=None, compa url = "%s&company=%s" % (url, urllib.quote(company)) return url print get_sso_url('test@myportal.com', 'Ciccio Pasticcio', 'https://support.example.com', '89128932983928912dw23', redirect_url='https://support.example.com/support/tickets') -
pbertera revised this gist
Sep 22, 2015 . 1 changed file with 13 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,9 +3,20 @@ import hmac import urllib def get_sso_url(email, name, base_url, key, redirect_url=None, phone=None, company=None): """This function returns the Freshdesk SSO URL. For more info look at https://goo.gl/NISgpr """ utctime = int(time.time()) plaintext = "%s%s%s" % (name, email, utctime) hash = hmac.new(key.encode(), plaintext.encode(), hashlib.md5).hexdigest() url = '%s/login/sso?name=%s&email=%s×tamp=%s&hash=%s' % (base_url, urllib.quote(name), urllib.quote(email), utctime, hash) if redirect_url: url = "%s&redirect_to=%s" % (url, urllib.quote(redirect_url)) if phone: url = "%s&phone=%s" % (url, urllib.quote(phone)) if company: url = "%s&company=%s" % (url, urllib.quote(company)) return url print get_sso_url('test@myportal.com', 'User Name', 'https://support.example.com', '89128932983928912dw23', redirect_url='https://support.example.com/support/tickets') -
pbertera created this gist
Sep 22, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,11 @@ import time import hashlib import hmac import urllib def get_sso_url(email, name, base_url, key): utctime = int(time.time()) plaintext = "%s%s%s" % (name, email, utctime) hash = hmac.new(key.encode(), plaintext.encode(), hashlib.md5).hexdigest() url = '%s/login/sso?name=%s&email=%s×tamp=%s&hash=%s' % (base_url, urllib.quote(name), urllib.quote(email), utctime, hash) return url