shish 6 лет назад
Родитель
Сommit
fd4ed596df
1 измененных файлов с 24 добавлено и 24 удалено
  1. 24 24
      common/components/token.php

+ 24 - 24
common/components/token.php

@@ -18,34 +18,34 @@ class token
 
 	public static function create($uid)
 	{
-		$host = Yii::$app->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;
+//		$host = Yii::$app->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);
+//		$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);
 	}
 
 }