Guest User

Untitled

a guest
Feb 25th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. $user = wp_get_current_user();
  2. $secret = 'My Secret Key given to me from zendesk when enabling SSO with JWT HERE!';
  3. $jwt_header = array(
  4. 'type' => 'JWT',
  5. 'alg' => 'HS256'
  6. );
  7.  
  8. $user_name = $user->user_firstname . ' ' . $user->user_lastname;
  9.  
  10. $jwt_payload = array(
  11. 'iat' => (int) $_GET['timestamp'],
  12. 'jti' => (float) $user->ID . microtime(true),
  13. 'name' => trim($user_name),
  14. 'email' => $user->user_email
  15. );
  16.  
  17. if (!empty($_GET['locale_id']))
  18. $jwt_payload['locale_id'] = $_GET['locale_id'];
  19.  
  20. $header_string = base64_encode(json_encode($jwt_header));
  21. $payload_string = base64_encode(json_encode($jwt_payload));
  22. $signature = hash_hmac('sha256', $header_string . '.' . $payload_string, $secret);
  23.  
  24. $redirect = 'https://heavyocity.zendesk.com/access/jwt?return_to=' . urlencode($_GET['return_to']) . '&jwt=' . $header_string . '.' . $payload_string . '.' . base64_encode($signature);
Add Comment
Please, Sign In to add comment