Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $user = wp_get_current_user();
- $secret = 'My Secret Key given to me from zendesk when enabling SSO with JWT HERE!';
- $jwt_header = array(
- 'type' => 'JWT',
- 'alg' => 'HS256'
- );
- $user_name = $user->user_firstname . ' ' . $user->user_lastname;
- $jwt_payload = array(
- 'iat' => (int) $_GET['timestamp'],
- 'jti' => (float) $user->ID . microtime(true),
- 'name' => trim($user_name),
- 'email' => $user->user_email
- );
- if (!empty($_GET['locale_id']))
- $jwt_payload['locale_id'] = $_GET['locale_id'];
- $header_string = base64_encode(json_encode($jwt_header));
- $payload_string = base64_encode(json_encode($jwt_payload));
- $signature = hash_hmac('sha256', $header_string . '.' . $payload_string, $secret);
- $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