Skip to content

Instantly share code, notes, and snippets.

@AlLoud
Forked from thanashyam/sso_login_freshdesk.php
Last active September 5, 2018 10:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlLoud/cfdea1aac2d158f288deaa71ed186037 to your computer and use it in GitHub Desktop.
Save AlLoud/cfdea1aac2d158f288deaa71ed186037 to your computer and use it in GitHub Desktop.
SSO Login for Freshdesk support portal - PHP Sample Code (Updated)
<?php
define('FRESHDESK_SHARED_SECRET','____Place your Single Sign On Shared Secret here_____');
define('FRESHDESK_LOGIN_URL','http://{{your-account}}.freshdesk.com/login/sso/');
function getSSOUrl($strName, $strEmail) {
$timestamp = time();
$str_to_be_hashed = $strName . FRESHDESK_SHARED_SECRET . $strEmail . $timestamp;
return FRESHDESK_LOGIN_URL . '?' .
http_build_query([ // parameters urlencoded by default - www.faqs.org/rfcs/rfc1738.html
'name' => $strName,
'hash' => hash_hmac('md5', $str_to_be_hashed, FRESHDESK_SHARED_SECRET)),
'email' => $strEmail,
'timestamp' => $timestamp,
], '' , '&amp;');
}
header("Location: " . getSSOUrl("User's Name","username@thecompany.com"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment