File: C:/laragon/www/beplocal/refreshJwt.php
<?php
require "vendor/autoload.php";
include_once 'DBClassOkta.php';
use \Firebase\JWT\JWT;
$oldJwt = $_POST['jwt'];
$secret_key = "OKTA2022@2202ATKO";
try {
$decoded = JWT::decode($oldJwt, $secret_key, array('HS256'));
$user = $decoded->data->Login;
$nome = $decoded->data->Nome;
$cognome = $decoded->data->Cognome;
$issuer_claim = "THE_ISSUER";
$audience_claim = "THE_AUDIENCE";
$issuedat_claim = time();
$notbefore_claim = $issuedat_claim ;
$expire_claim = $issuedat_claim + 1800;
$token = array(
"iss" => $issuer_claim,
"aud" => $audience_claim,
"iat" => $issuedat_claim,
"nbf" => $notbefore_claim,
"exp" => $expire_claim,
"data" => array(
"Cognome" => $cognome,
"Nome" => $nome,
"Login" => $user
));
$jwt = JWT::encode($token, $secret_key);
echo json_encode(
array(
"message" => "Token aggiornato con successo ",
"jwt" => $jwt
));
die();
}
catch (Exception $e) {
echo json_encode(array(
"message" => "SESSIONE SCADUTA",
"jwt" => $oldJwt
));
}
?>