Skip to content

Commit 026a6d9

Browse files
committed
Updates for some whitespace and other minor issues.
1 parent b582985 commit 026a6d9

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

Authentication/JWT.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@ public static function decode($jwt, $key = null, $verify = true)
6565
if (empty($header->alg)) {
6666
throw new DomainException('Empty algorithm');
6767
}
68-
if (is_array($key) && !isset($header->kid)) {
69-
throw new DomainException('"kid" empty, unable to lookup correct key');
70-
} elseif(is_array($key) && isset($header->kid)) {
71-
$key = $key[$header->kid];
68+
if (is_array($key)) {
69+
if(isset($header->kid)) {
70+
$key = $key[$header->kid];
71+
} else {
72+
throw new DomainException('"kid" empty, unable to lookup correct key');
73+
}
7274
}
7375
if (!JWT::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
7476
throw new UnexpectedValueException('Signature verification failed');
@@ -116,7 +118,7 @@ public static function encode($payload, $key, $algo = 'HS256', $keyId = null)
116118
* @param string $msg The message to sign
117119
* @param string|resource $key The secret key
118120
* @param string $method The signing algorithm. Supported
119-
* algorithms are 'HS256', 'HS384' and 'HS512'
121+
* algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
120122
*
121123
* @return string An encrypted message
122124
* @throws DomainException Unsupported algorithm was specified

tests/JWTTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ function testValidToken(){
4747
$this->assertEquals($decoded->message, 'abc');
4848
}
4949

50-
function testRSEncodeDecode() {
51-
$privKey = openssl_pkey_new(array('digest_alg' => 'sha256',
50+
function testRSEncodeDecode(){
51+
$privKey = openssl_pkey_new(array('digest_alg' => 'sha256',
5252
'private_key_bits' => 1024,
5353
'private_key_type' => OPENSSL_KEYTYPE_RSA));
5454
$msg = JWT::encode('abc',$privKey, 'RS256');
@@ -58,7 +58,7 @@ function testRSEncodeDecode() {
5858
$this->assertEquals($decoded, 'abc');
5959
}
6060

61-
function testKIDChooser() {
61+
function testKIDChooser(){
6262
$keys = array('1' => 'my_key', '2' => 'my_key2');
6363
$msg = JWT::encode('abc', $keys['1'], 'HS256', '1');
6464
$decoded = JWT::decode($msg, $keys, true);

0 commit comments

Comments
 (0)