request->getHostInfo(); // $time = time(); // $token = (new Builder())->issuedBy($host) // Configures the issuer (iss claim) // ->permittedFor($host) // Configures the audience (aud claim) // ->identifiedBy('5f1g23a12awP1', true) // Configures the id (jti claim), replicating as a header item // ->issuedAt($time) // Configures the time that the token was issue (iat claim) // ->canOnlyBeUsedAfter($time + 60) // Configures the time that the token can be used (nbf claim) // ->expiresAt($time + 3600) // Configures the expiration time of the token (exp claim) // ->withClaim('uid', $uid) // Configures a new claim, called "uid" // ->getToken(); // Retrieves the generated token // return $token; } public static function validate($token) { // $token = (new Parser())->parse((string)$token); // $signer = Sha256(); // //签名不正确 // if (!$token->verify($signer, '2019.1964')) { // return false; // } // $host = Yii::$app->request->getHostInfo(); // $validationData = new ValidationData(); // $validationData->setIssuer($host); // $validationData->setAudience($host); // $validationData->setId('sxs-4f1g23a12aa');//自字义标识 // // return $token->validate($validationData); } }