Skip to content

Commit 4a49056

Browse files
authored
[WIP] Easy Toolset (#184)
* New Easy Toolset New builder to ease the use of this project. Offers a simple and fluent way to create, load, verify and decrypt tokens Example: ```php $jws = Build::jws() ->exp(time() + 3600) ->iat(time()) ->nbf(time()) ->jti('0123456789', true) ->alg('RS512') ->sign($this->rsaKey()) ``` * Decrypter added * Auto-load algorithms * New Easy package * Critical header support + tests added * Minor correction * Zip method test * Bugs fixed * New Load class * Composer branches fixed * Composer branches fixed * Errors fixed or ignored * Errors fixed or ignored * Micro-optimization * @throws statements * @throws statements * @throws statements + autodispatcher alias * @throws statements * Error fixed * Error fixed * Error fixed
1 parent e424fe4 commit 4a49056

File tree

159 files changed

+2607
-93
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+2607
-93
lines changed

.gitsplit.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ splits:
5151
target: "https://${GH_TOKEN}@github.com/web-token/encryption-pack.git"
5252
- prefix: "packs/signature"
5353
target: "https://${GH_TOKEN}@github.com/web-token/signature-pack.git"
54+
- prefix: "src/Easy"
55+
target: "https://${GH_TOKEN}@github.com/web-token/jwt-easy.git"
5456

5557
origins:
5658
- ^master$

phpstan.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ parameters:
1111
- %currentWorkingDirectory%/src/EncryptionAlgorithm/KeyEncryption/*/Tests/*
1212
- %currentWorkingDirectory%/src/SignatureAlgorithm/*/Tests/*
1313
ignoreErrors:
14+
- '#Strict comparison using === between false and .* will always evaluate to false\.*#'
15+
- '#Instanceof between Jose\\Component\\Core\\Algorithm and Jose\\Component\\Core\\Algorithm will always evaluate to true\.*#'
16+
- '#Parameter .* of function call_user_func_array expects .* array given\.*#'
17+
- '#Call to function is_int\(\) with int will always evaluate to true\.*#'
18+
- '#Call to an undefined method Jose\\Easy\\.*#'
1419
- '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)#'
1520
- '#Parameter \#1 \$value of class FG\\ASN1\\Universal\\Integer constructor expects int\, string given\.#'
1621
- '#Method Jose\\Component\\Core\\Util\\Ecc\\Math::rightShift\(\) should return GMP but returns resource\.#'

phpunit.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<directory>./src/EncryptionAlgorithm/ContentEncryption/*/Tests/</directory>
2020
<directory>./src/EncryptionAlgorithm/KeyEncryption/*/Tests/</directory>
2121
<directory>./src/EncryptionAlgorithm/Experimental/Tests/</directory>
22+
<directory>./src/Easy/Tests/</directory>
2223
</testsuite>
2324
</testsuites>
2425
<php>

src/Bundle/JoseFramework/DependencyInjection/Compiler/AlgorithmCompilerPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ final class AlgorithmCompilerPass implements CompilerPassInterface
2323
{
2424
/**
2525
* {@inheritdoc}
26+
*
27+
* @throws InvalidArgumentException if the algorithm has no alias
2628
*/
2729
public function process(ContainerBuilder $container): void
2830
{

src/Bundle/JoseFramework/DependencyInjection/Compiler/ClaimCheckerCompilerPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ final class ClaimCheckerCompilerPass implements CompilerPassInterface
2323
{
2424
/**
2525
* {@inheritdoc}
26+
*
27+
* @throws InvalidArgumentException if the claim checker has no alias
2628
*/
2729
public function process(ContainerBuilder $container): void
2830
{

src/Bundle/JoseFramework/DependencyInjection/Compiler/CompressionMethodCompilerPass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ final class CompressionMethodCompilerPass implements CompilerPassInterface
2323
{
2424
/**
2525
* {@inheritdoc}
26+
*
27+
* @throws InvalidArgumentException if the compression method has no alias
2628
*/
2729
public function process(ContainerBuilder $container): void
2830
{
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* The MIT License (MIT)
7+
*
8+
* Copyright (c) 2014-2019 Spomky-Labs
9+
*
10+
* This software may be modified and distributed under the terms
11+
* of the MIT license. See the LICENSE file for details.
12+
*/
13+
14+
namespace Jose\Bundle\JoseFramework\DependencyInjection\Compiler;
15+
16+
use Psr\EventDispatcher\EventDispatcherInterface;
17+
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
18+
use Symfony\Component\DependencyInjection\ContainerBuilder;
19+
20+
final class EventDispatcherAliasCompilerPass implements CompilerPassInterface
21+
{
22+
/**
23+
* {@inheritdoc}
24+
*/
25+
public function process(ContainerBuilder $container): void
26+
{
27+
if (!$container->hasDefinition('event_dispatcher') || $container->hasAlias(EventDispatcherInterface::class)) {
28+
return;
29+
}
30+
31+
$container->setAlias(EventDispatcherInterface::class, 'event_dispatcher');
32+
}
33+
}

src/Bundle/JoseFramework/DependencyInjection/Compiler/HeaderCheckerCompilerPass.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ public function process(ContainerBuilder $container): void
3636
$this->addTokenType($definition, $container);
3737
}
3838

39+
/**
40+
* @throws InvalidArgumentException if a header checker is wnongly configured
41+
*/
3942
private function addHeaderCheckers(Definition $definition, ContainerBuilder $container): void
4043
{
4144
$taggedHeaderCheckerServices = $container->findTaggedServiceIds('jose.checker.header');

src/Bundle/JoseFramework/DependencyInjection/Compiler/KeySetControllerCompilerPass.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ final class KeySetControllerCompilerPass implements CompilerPassInterface
2222
{
2323
/**
2424
* {@inheritdoc}
25+
*
26+
* @throws InvalidArgumentException if a controller has no "path" attribute
2527
*/
2628
public function process(ContainerBuilder $container): void
2729
{
@@ -35,7 +37,7 @@ public function process(ContainerBuilder $container): void
3537
foreach ($taggedAlgorithmServices as $id => $tags) {
3638
foreach ($tags as $attributes) {
3739
if (!isset($attributes['path'])) {
38-
throw new InvalidArgumentException(sprintf('The algorithm "%s" does not have any "path" attribute.', $id));
40+
throw new InvalidArgumentException(sprintf('The controller "%s" does not have any "path" attribute.', $id));
3941
}
4042
$definition->addMethodCall('add', [$attributes['path'], $id]);
4143
}

src/Bundle/JoseFramework/DependencyInjection/Source/KeyManagement/JWKSetSource.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace Jose\Bundle\JoseFramework\DependencyInjection\Source\KeyManagement;
1515

16+
use InvalidArgumentException;
1617
use Jose\Bundle\JoseFramework\DependencyInjection\Source\KeyManagement\JWKSetSource\JWKSetSource as JWKSetSourceInterface;
1718
use Jose\Bundle\JoseFramework\DependencyInjection\Source\Source;
1819
use LogicException;
@@ -33,6 +34,9 @@ public function name(): string
3334
return 'key_sets';
3435
}
3536

37+
/**
38+
* @throws LogicException if the definition is not configured
39+
*/
3640
public function load(array $configs, ContainerBuilder $container): void
3741
{
3842
$sources = $this->getJWKSetSources();
@@ -77,6 +81,8 @@ public function prepend(ContainerBuilder $container, array $config): array
7781
}
7882

7983
/**
84+
* @throws InvalidArgumentException if the source object is not valid
85+
*
8086
* @return JWKSetSourceInterface[]
8187
*/
8288
private function getJWKSetSources(): array
@@ -97,7 +103,7 @@ private function getJWKSetSources(): array
97103
foreach (array_keys($services) as $id) {
98104
$factory = $tempContainer->get($id);
99105
if (!$factory instanceof JWKSetSourceInterface) {
100-
throw new \InvalidArgumentException('Invalid object');
106+
throw new InvalidArgumentException('Invalid object');
101107
}
102108
$jwkset_sources[str_replace('-', '_', $factory->getKeySet())] = $factory;
103109
}

0 commit comments

Comments
 (0)