Skip to content

Commit 4bec9db

Browse files
committed
lcobucci/jwt updated
1 parent 7507036 commit 4bec9db

File tree

2 files changed

+36
-7
lines changed

2 files changed

+36
-7
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ext-json": "*",
1717
"google/protobuf": "~3.15.8",
1818
"grpc/grpc": "^1.35",
19-
"lcobucci/jwt": "^3.4.6",
19+
"lcobucci/jwt": "^4.1.5",
2020
"phpseclib/phpseclib": "^2.0|^3.0",
2121
"psr/log": "~1.0"
2222
},

src/Jwt/Signer/Sha256.php

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,51 @@
33
namespace YandexCloud\Ydb\Jwt\Signer;
44

55
use Lcobucci\JWT\Signer\Key as SignerKey;
6-
use Lcobucci\JWT\Signer\Rsa as SignerRsa;
6+
use Lcobucci\JWT\Signer\OpenSSL;
77

88
use phpseclib\Crypt\RSA as LegacyRSA;
99
use phpseclib3\Crypt\RSA;
1010
use phpseclib3\Crypt\PublicKeyLoader;
1111

12-
class Sha256 extends SignerRsa
12+
class Sha256 extends OpenSSL
1313
{
1414
/**
1515
* @param string $payload
1616
* @param SignerKey $key
1717
* @return string
1818
*/
19-
public function createHash($payload, SignerKey $key)
19+
final public function sign(string $payload, SignerKey $key): string
2020
{
21-
$keyContent = $key->getContent();
21+
return $this->createHash($payload, $key);
22+
}
23+
24+
/**
25+
* @param string $expected
26+
* @param string $payload
27+
* @param SignerKey $key
28+
* @return bool
29+
*/
30+
final public function verify(string $expected, string $payload, SignerKey $key): bool
31+
{
32+
return $this->verifySignature($expected, $payload, $key->contents());
33+
}
34+
35+
/**
36+
* @return int
37+
*/
38+
final public function keyType(): int
39+
{
40+
return OPENSSL_KEYTYPE_RSA;
41+
}
42+
43+
/**
44+
* @param string $payload
45+
* @param SignerKey $key
46+
* @return string
47+
*/
48+
public function createHash($payload, SignerKey $key): string
49+
{
50+
$keyContent = $key->contents();
2251

2352
if (class_exists(LegacyRSA::class))
2453
{
@@ -42,15 +71,15 @@ public function createHash($payload, SignerKey $key)
4271
/**
4372
* @return string
4473
*/
45-
public function getAlgorithmId()
74+
public function algorithmId(): string
4675
{
4776
return 'PS256';
4877
}
4978

5079
/**
5180
* @return int
5281
*/
53-
public function getAlgorithm()
82+
public function algorithm(): int
5483
{
5584
return OPENSSL_ALGO_SHA256;
5685
}

0 commit comments

Comments
 (0)