mirror of
https://gitee.com/ctexthuang/hyperf_rbac_framework_server_ctexthuang.git
synced 2025-12-25 20:27:49 +08:00
feat : jwt
This commit is contained in:
@@ -88,24 +88,20 @@ abstract class AbstractJwt implements JwtInterface
|
||||
*/
|
||||
public function parserAccessToken(string $accessToken): UnencryptedToken
|
||||
{
|
||||
try {
|
||||
return $this->getJwtFacade()
|
||||
->parse(
|
||||
$accessToken,
|
||||
new SignedWith(
|
||||
$this->getSigner(),
|
||||
$this->getSigningKey()
|
||||
),
|
||||
new StrictValidAt(
|
||||
$this->clock,
|
||||
$this->clock->now()->diff($this->getExpireAt($this->clock->now()))
|
||||
),
|
||||
$this->getBlackListConstraint(),
|
||||
$this->refreshTokenConstraint
|
||||
);
|
||||
} catch (RequiredConstraintsViolated $e) {
|
||||
throw new ErrException('token过期',ResultCode::JWT_EXPIRED,['err_msg' => $e->getMessage()]);
|
||||
}
|
||||
return $this->getJwtFacade()
|
||||
->parse(
|
||||
$accessToken,
|
||||
new SignedWith(
|
||||
$this->getSigner(),
|
||||
$this->getSigningKey()
|
||||
),
|
||||
new StrictValidAt(
|
||||
$this->clock,
|
||||
$this->clock->now()->diff($this->getExpireAt($this->clock->now()))
|
||||
),
|
||||
$this->getBlackListConstraint(),
|
||||
$this->refreshTokenConstraint
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,24 +110,20 @@ abstract class AbstractJwt implements JwtInterface
|
||||
*/
|
||||
public function parserRefreshToken(string $refreshToken): UnencryptedToken
|
||||
{
|
||||
try {
|
||||
return $this->getJwtFacade()
|
||||
->parse(
|
||||
$refreshToken,
|
||||
new SignedWith(
|
||||
$this->getSigner(),
|
||||
$this->getSigningKey()
|
||||
),
|
||||
new StrictValidAt(
|
||||
$this->clock,
|
||||
$this->clock->now()->diff($this->getRefreshExpireAt($this->clock->now()))
|
||||
),
|
||||
$this->getBlackListConstraint(),
|
||||
$this->accessTokenConstraint
|
||||
);
|
||||
}catch (RequiredConstraintsViolated $e) {
|
||||
throw new ErrException('refresh_token过期',ResultCode::JWT_EXPIRED,['err_msg' => $e->getMessage()]);
|
||||
}
|
||||
return $this->getJwtFacade()
|
||||
->parse(
|
||||
$refreshToken,
|
||||
new SignedWith(
|
||||
$this->getSigner(),
|
||||
$this->getSigningKey()
|
||||
),
|
||||
new StrictValidAt(
|
||||
$this->clock,
|
||||
$this->clock->now()->diff($this->getRefreshExpireAt($this->clock->now()))
|
||||
),
|
||||
$this->getBlackListConstraint(),
|
||||
$this->accessTokenConstraint
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user