Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

Commit

Permalink
use=>sig added for all none keys created by the factory
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Morselli committed Sep 8, 2016
1 parent 1f9874d commit fa19b85
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions doc/object/jwk.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ This type of key does not require any other value.
$jwk = new JWK([
'kty' => 'none',
'alg' => 'none', //Not mandatory, but as the key is only used with that algorithm this key/value pair is recommended
'use' => 'sig', //Not mandatory, but as the key is only used to sign JWT, this key/value pair is recommended
]);
```

Expand Down
1 change: 1 addition & 0 deletions src/Factory/JWKFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ public static function createNoneKey(array $values)
[
'kty' => 'none',
'alg' => 'none',
'use' => 'sig',
]
);

Expand Down
5 changes: 4 additions & 1 deletion tests/Unit/Keys/NoneKeysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ public function testKeyThumbprint()
$key = new JWK([
'kty' => 'none',
'alg' => 'none',
'use' => 'sig',
'kid' => '2011-04-29',
]);

$this->assertEquals('{"kty":"none","alg":"none","kid":"2011-04-29"}', json_encode($key));
$this->assertEquals('{"kty":"none","alg":"none","use":"sig","kid":"2011-04-29"}', json_encode($key));
$this->assertEquals('BC69Ls25CLRh1KQrXvQAAB22oyuW3eQabDSMdv9xMNk', $key->thumbprint('sha256'));
$this->assertEquals('hCnBo6v87V-Gz5Bp7eoFTrdvkGA', $key->thumbprint('sha1'));
$this->assertEquals('JI3gujreJtPt2gzxlbGnLQ', $key->thumbprint('md5'));
Expand All @@ -42,6 +43,7 @@ public function testCreateNoneKey()

$this->assertEquals('none', $key->get('kty'));
$this->assertEquals('none', $key->get('alg'));
$this->assertEquals('sig', $key->get('use'));
$this->assertEquals('NONE_KEY', $key->get('kid'));

$this->assertEquals('BC69Ls25CLRh1KQrXvQAAB22oyuW3eQabDSMdv9xMNk', $key->thumbprint('sha256'));
Expand All @@ -55,6 +57,7 @@ public function testCreateNoneKey2()

$this->assertEquals('none', $key->get('kty'));
$this->assertEquals('none', $key->get('alg'));
$this->assertEquals('sig', $key->get('use'));
$this->assertEquals('NONE_KEY', $key->get('kid'));

$this->assertEquals('BC69Ls25CLRh1KQrXvQAAB22oyuW3eQabDSMdv9xMNk', $key->thumbprint('sha256'));
Expand Down

0 comments on commit fa19b85

Please sign in to comment.