Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Estou precisando de autenticar o login enviando um jwt para o Zendesk. Estou seguindo a documentação, mas ainda não consegui fazer funcionar o envio do json web token.
Depois de tentar logar recebo a mensagem de class JWT not found.
Alguém já implementou algo parecido?
O código que estou usando:
$key = "{key}";
$subdomain = "{subdomain}";
$now = time();
$token = array(
"jti" => md5($now . rand()),
"iat" => $now,
"name" => $user->name,
"email" => $user->email
);
$jwt = JWT::encode($token, $key);
$location = "https://" . $subdomain . ".zendesk.com/access/jwt?jwt=" . $jwt;
if(isset($_GET["return_to"])) {
$location .= "&return_to=" . urlencode($_GET["return_to"]);
}
Consegui resolver.
verifica_login.php
include_once "JWT.php";
// Verifica se a senha do usuário está correta
if ( crypt( $dados_usuario['senha'], $fetch_usuario['user_password'] ) === $fetch_usuario['user_password'] ) {
// O usuário está logado
$token = array(
JWT.php
<?php
/**
* JSON Web Token implementation, based on this spec:
* http://tools.ietf.org/html/draft-ietf-oauth-json-web-token-06
*
* PHP version 5
*
* @category Authentication
* @package Authentication_JWT
* @author Neuman Vong <neuman@twilio.com>
* @author Anant Narayanan <anant@php.net>
* @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
* @link https://github.com/firebase/php-jwt
*/
class JWT
{
/**
* Decodes a JWT string into a PHP object.
*
* @param string $jwt The JWT
* @param string|null $key The secret key
* @param bool $verify Don't skip verification process
*