Skip to content

Commit d0db9cb

Browse files
committed
Revert "GitBook: [master] 24 pages modified"
This reverts commit bcd5bba.
1 parent bcd5bba commit d0db9cb

24 files changed

+133
-181
lines changed

SUMMARY.md

-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
* [JWE creation](symfony-bundle/encrypted-tokens/jwe-creation.md)
3232
* [JWE decryption](symfony-bundle/encrypted-tokens/jwe-decryption.md)
3333
* [Configuration Helper](symfony-bundle/configuration-helper.md)
34-
* [Events](symfony-bundle/events.md)
35-
* [Profiling/Debugging](symfony-bundle/profiling-debugging.md)
3634
* [Console](console/README.md)
3735
* [Standalone Application](console/standalone.md)
3836
* [Symfony Console](console/symfony-console.md)
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
# Encrypted tokens and
22

3-
4-

advanced-topics/nested-tokens.md

-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ The `NestedTokenLoader` and `NestedTokenBuilder` classes will help you to create
77
* `web-token/jwt-checker`
88
* `web-token/jwt-signature`
99

10-
**New in version 2.0**: a new package is available: `web-token/jwt-nested-token`. This package contains all the classes and dependencies will be directly managed by composer. You can install it if needed.
11-
1210
## Nested Token Loading
1311

1412
To instantiate the `NestedTokenLoader`, you need a `JWSLoader` and a `JWELoader`.

advanced-topics/serialization.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,15 @@ The serializer manager can be helpful when your application deals more than one
9898

9999
require_once 'vendor/autoload.php';
100100

101+
use Jose\Component\Core\Converter\StandardConverter;
101102
use Jose\Component\Signature\Serializer;
102103

104+
$jsonConverter = new StandardConverter();
105+
103106
$manager = Serializer\JWSSerializerManager::create([
104-
new Serializer\CompactSerializer(),
105-
new Serializer\JSONFlattenedSerializer(),
106-
new Serializer\JSONGeneralSerializer(),
107+
new Serializer\CompactSerializer($jsonConverter),
108+
new Serializer\JSONFlattenedSerializer($jsonConverter),
109+
new Serializer\JSONGeneralSerializer($jsonConverter),
107110
]);
108111

109112
// Serializes the second signature (index = 1) of the variable $jws (JWS object) into JSON Flattened serialization mode.
@@ -191,12 +194,15 @@ The serializer manager can be helpful when your application deals more than one
191194

192195
require_once 'vendor/autoload.php';
193196

197+
use Jose\Component\Core\Converter\StandardConverter;
194198
use Jose\Component\Encryption\Serializer;
195199

200+
$jsonConverter = new StandardConverter();
201+
196202
$manager = Serializer\JWESerializerManager::create([
197-
new Serializer\CompactSerializer(),
198-
new Serializer\JSONFlattenedSerializer(),
199-
new Serializer\JSONGeneralSerializer(),
203+
new Serializer\CompactSerializer($jsonConverter),
204+
new Serializer\JSONFlattenedSerializer($jsonConverter),
205+
new Serializer\JSONGeneralSerializer($jsonConverter),
200206
]);
201207

202208
// Serializes the second recipient (index = 1) of the variable $jwe (JWE object) into JSON Flattened serialization mode.
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
# Signed tokens and
22

3-
4-

advanced-topics/signed-tokens-and/detached-payload.md

+19-8
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,33 @@ There is not much difference between the creation of a JWS with or without detac
1010
<?php
1111

1212
use Jose\Component\Core\AlgorithmManager;
13+
use Jose\Component\Core\Converter\StandardConverter;
1314
use Jose\Component\Core\JWK;
1415
use Jose\Component\Signature\Algorithm\HS256;
1516
use Jose\Component\Signature\JWSBuilder;
1617

1718
// The algorithm manager with the HS256 algorithm.
18-
$algorithmManager = new AlgorithmManager([
19+
$algorithmManager = AlgorithmManager::create([
1920
new HS256(),
2021
]);
2122

2223
// Our key.
23-
$jwk = new JWK([
24+
$jwk = JWK::create([
2425
'kty' => 'oct',
2526
'k' => 'dzI6nbW4OcNF-AtfxGAmuyz7IpHRudBI0WgGjZWgaRJt6prBn3DARXgUR8NVwKhfL43QBIU2Un3AvCGCHRgY4TbEqhOi8-i98xxmCggNjde4oaW6wkJ2NgM3Ss9SOX9zS3lcVzdCMdum-RwVJ301kbin4UtGztuzJBeg5oVN00MGxjC2xWwyI0tgXVs-zJs5WlafCuGfX1HrVkIf5bvpE0MQCSjdJpSeVao6-RSTYDajZf7T88a2eVjeW31mMAg-jzAWfUrii61T_bYPJFOXW8kkRWoa1InLRdG6bKB9wQs9-VdXZP60Q4Yuj_WZ-lO7qV9AEFrUkkjpaDgZT86w2g',
2627
]);
2728

29+
// The JSON Converter.
30+
$jsonConverter = new StandardConverter();
31+
2832
// We instantiate our JWS Builder.
2933
$jwsBuilder = new JWSBuilder(
34+
$jsonConverter,
3035
$algorithmManager
3136
);
3237

3338
// The payload we want to sign
34-
$payload = json_encode([
39+
$payload = $jsonConverter->encode([
3540
'iat' => time(),
3641
'nbf' => time(),
3742
'exp' => time() + 3600,
@@ -56,30 +61,36 @@ The loading of a signed token with a detached payload is as easy as when the pay
5661
<?php
5762

5863
use Jose\Component\Core\AlgorithmManager;
64+
use Jose\Component\Core\Converter\StandardConverter;
5965
use Jose\Component\Core\JWK;
6066
use Jose\Component\Signature\Algorithm\HS256;
6167
use Jose\Component\Signature\JWSVerifier;
6268
use Jose\Component\Signature\Serializer\JWSSerializerManager;
6369
use Jose\Component\Signature\Serializer\CompactSerializer;
6470

6571
// The algorithm manager with the HS256 algorithm.
66-
$algorithmManager = new AlgorithmManager([
72+
$algorithmManager = AlgorithmManager::create([
6773
new HS256(),
6874
]);
6975

7076
// Our key.
71-
$jwk = new JWK([
77+
$jwk = JWK::create([
7278
'kty' => 'oct',
7379
'k' => 'dzI6nbW4OcNF-AtfxGAmuyz7IpHRudBI0WgGjZWgaRJt6prBn3DARXgUR8NVwKhfL43QBIU2Un3AvCGCHRgY4TbEqhOi8-i98xxmCggNjde4oaW6wkJ2NgM3Ss9SOX9zS3lcVzdCMdum-RwVJ301kbin4UtGztuzJBeg5oVN00MGxjC2xWwyI0tgXVs-zJs5WlafCuGfX1HrVkIf5bvpE0MQCSjdJpSeVao6-RSTYDajZf7T88a2eVjeW31mMAg-jzAWfUrii61T_bYPJFOXW8kkRWoa1InLRdG6bKB9wQs9-VdXZP60Q4Yuj_WZ-lO7qV9AEFrUkkjpaDgZT86w2g',
7480
]);
7581

82+
// The JSON Converter.
83+
$jsonConverter = new StandardConverter();
84+
7685
// The serializer manager. We only use the JWS Compact Serialization Mode.
77-
$serializerManager = new JWSSerializerManager([
78-
new CompactSerializer(),
86+
$serializerManager = JWSSerializerManager::create([
87+
new CompactSerializer($jsonConverter),
7988
]);
8089

8190
// We instantiate our JWS Verifier.
82-
$jwsVerifier = new JWSVerifier($algorithmManager);
91+
$jwsVerifier = new JWSVerifier(
92+
$algorithmManager
93+
);
8394

8495
// The detached payload
8596
$payload = '{"iat":1507896992,"nbf":1507896992,"exp":1507900592,"iss":"My service","aud":"Your application"}';

advanced-topics/signed-tokens-and/multiple-signatures.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ $jws = $jwsBuilder
1717
The variable `$jws` will be a valid JWS object with all computed signatures. Next step is the serialization of these signatures.
1818

1919
```php
20+
use Jose\Component\Core\Converter\StandardConverter;
2021
use Jose\Component\Signature\Serializer;
2122

23+
// The JSON Converter.
24+
$jsonConverter = new StandardConverter();
25+
2226
$manager = Serializer\JWSSerializerManager::create([
23-
new Serializer\CompactSerializer(),
24-
new Serializer\JsonFlattenedSerializer(),
25-
new Serializer\JsonGeneralSerializer(),
27+
new Serializer\CompactSerializer($jsonConverter),
28+
new Serializer\JsonFlattenedSerializer($jsonConverter),
29+
new Serializer\JsonGeneralSerializer($jsonConverter),
2630
]);
2731

2832
$tokenWithAllSignatures = $manager->serialize('jws_json_general', $jws);

components/algorithm-management-jwa.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use Jose\Component\Core\AlgorithmManager;
2121
use Jose\Component\Signature\Algorithm\PS256;
2222
use Jose\Component\Signature\Algorithm\ES512;
2323

24-
$algorithm_manager = new AlgorithmManager([
24+
$algorithm_manager = AlgorithmManager::create([
2525
new PS256(),
2626
new ES512(),
2727
]);

components/claim-checker.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ In the following example, we will create a manager able to check the `aud` \(Aud
1818
use Jose\Component\Checker\ClaimCheckerManager;
1919
use Jose\Component\Checker;
2020

21-
$claimCheckerManager = new ClaimCheckerManager(
21+
$claimCheckerManager = ClaimCheckerManager::create(
2222
[
2323
new Checker\IssuedAtChecker(),
2424
new Checker\NotBeforeChecker(),
@@ -28,10 +28,14 @@ $claimCheckerManager = new ClaimCheckerManager(
2828
);
2929
```
3030

31-
When instantiated, call the method `check` to check the claims of a JWT object. This method only accept an associative array. You have to retrieve this array by converting the JWT payload.
31+
When instantiated, call the method `check` to check the claims of a JWT object. This method only accept an array. You have to retrieve this array by converting the JWT payload.
3232

3333
```php
34-
$claims = json_decode($jwt->getPayload(), true);
34+
use Jose\Component\Core\Converter\StandardConverter;
35+
36+
$jsonConverter = new StandardConverter();
37+
38+
$claims = $jsonConverter->decode($jwt->getPayload());
3539
$claimCheckerManager->check($claims);
3640
```
3741

components/encrypted-tokens-jwe/encryption-algorithms.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ use Jose\Component\Encryption\Algorithm\KeyEncryption\A128KW;
7474
use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS256A128KW;
7575
use Jose\Component\Encryption\Algorithm\ContentEncryption\A128CBCHS256;
7676

77-
$algorithmManager = new AlgorithmManager([
77+
$algorithmManager = AlgorithmManager::create([
7878
new A128KW(),
7979
new PBES2HS256A128KW(),
8080
new A128CBCHS256(),
@@ -96,7 +96,7 @@ Example with 16 bytes \(128 bits\) salt and 1024 counts:
9696
use Jose\Component\Core\AlgorithmManager;
9797
use Jose\Component\Encryption\Algorithm\KeyEncryption\PBES2HS256A128KW;
9898

99-
$algorithmManager = new AlgorithmManager([
99+
$algorithmManager = AlgorithmManager::create([
100100
new PBES2HS256A128KW(16, 1024),
101101
]);
102102
```

components/encrypted-tokens-jwe/jwe-creation.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,41 @@ The computation of a JWE is done by the `JWEBuilder` object. This object require
44

55
* an algorithm manager with key encryption algorithms
66
* an algorithm manager with content encryption algorithms
7-
* a compression method manager. No compression method is needed if you do not intent to compress the payload.
7+
* a compression method manager. No compression method is needed if you do not intent to compress the payload
8+
* and a JSON converter.
89

910
```php
1011
<?php
1112

1213
use Jose\Component\Core\AlgorithmManager;
14+
use Jose\Component\Core\Converter\StandardConverter;
1315
use Jose\Component\Encryption\Algorithm\KeyEncryption\A256KW;
1416
use Jose\Component\Encryption\Algorithm\ContentEncryption\A256CBCHS512;
1517
use Jose\Component\Encryption\Compression\CompressionMethodManager;
1618
use Jose\Component\Encryption\Compression\Deflate;
1719
use Jose\Component\Encryption\JWEBuilder;
1820

1921
// The key encryption algorithm manager with the A256KW algorithm.
20-
$keyEncryptionAlgorithmManager = new AlgorithmManager([
22+
$keyEncryptionAlgorithmManager = AlgorithmManager::create([
2123
new A256KW(),
2224
]);
2325

2426
// The content encryption algorithm manager with the A256CBC-HS256 algorithm.
25-
$contentEncryptionAlgorithmManager = new AlgorithmManager([
27+
$contentEncryptionAlgorithmManager = AlgorithmManager::create([
2628
new A256CBCHS512(),
2729
]);
2830

2931
// The compression method manager with the DEF (Deflate) method.
30-
$compressionMethodManager = new CompressionMethodManager([
32+
$compressionMethodManager = CompressionMethodManager::create([
3133
new Deflate(),
3234
]);
3335

36+
// The JSON Converter.
37+
$jsonConverter = new StandardConverter();
38+
3439
// We instantiate our JWE Builder.
3540
$jweBuilder = new JWEBuilder(
41+
$jsonConverter,
3642
$keyEncryptionAlgorithmManager,
3743
$contentEncryptionAlgorithmManager,
3844
$compressionMethodManager
@@ -45,13 +51,13 @@ Now let's create our first JWE object.
4551
use Jose\Component\Core\JWK;
4652

4753
// Our key.
48-
$jwk = new JWK([
54+
$jwk = JWK::create([
4955
'kty' => 'oct',
5056
'k' => 'dzI6nbW4OcNF-AtfxGAmuyz7IpHRudBI0WgGjZWgaRJt6prBn3DARXgUR8NVwKhfL43QBIU2Un3AvCGCHRgY4TbEqhOi8-i98xxmCggNjde4oaW6wkJ2NgM3Ss9SOX9zS3lcVzdCMdum-RwVJ301kbin4UtGztuzJBeg5oVN00MGxjC2xWwyI0tgXVs-zJs5WlafCuGfX1HrVkIf5bvpE0MQCSjdJpSeVao6-RSTYDajZf7T88a2eVjeW31mMAg-jzAWfUrii61T_bYPJFOXW8kkRWoa1InLRdG6bKB9wQs9-VdXZP60Q4Yuj_WZ-lO7qV9AEFrUkkjpaDgZT86w2g',
5157
]);
5258

53-
// The payload we want to encrypt. It MUST be a string.
54-
$payload = json_encode([
59+
// The payload we want to encrypt. The payload MUST be a string hence we use our JSON Converter.
60+
$payload = $jsonConverter->encode([
5561
'iat' => time(),
5662
'nbf' => time(),
5763
'exp' => time() + 3600,
@@ -78,7 +84,7 @@ We will use the compact serialization mode. This is the most common mode as it i
7884
```php
7985
use Jose\Component\Encryption\Serializer\CompactSerializer;
8086

81-
$serializer = new CompactSerializer(); // The serializer
87+
$serializer = new CompactSerializer($jsonConverter); // The serializer
8288

8389
$token = $serializer->serialize($jwe, 0); // We serialize the recipient at index 0 (we only have one recipient).
8490
```

components/encrypted-tokens-jwe/jwe-loading.md

+9-5
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ use Jose\Component\Encryption\Compression\Deflate;
1919
use Jose\Component\Encryption\JWEDecrypter;
2020

2121
// The key encryption algorithm manager with the A256KW algorithm.
22-
$keyEncryptionAlgorithmManager = new AlgorithmManager([
22+
$keyEncryptionAlgorithmManager = AlgorithmManager::create([
2323
new A256KW(),
2424
]);
2525

2626
// The content encryption algorithm manager with the A256CBC-HS256 algorithm.
27-
$contentEncryptionAlgorithmManager = new AlgorithmManager([
27+
$contentEncryptionAlgorithmManager = AlgorithmManager::create([
2828
new A256CBCHS512(),
2929
]);
3030

3131
// The compression method manager with the DEF (Deflate) method.
32-
$compressionMethodManager = new CompressionMethodManager([
32+
$compressionMethodManager = CompressionMethodManager::create([
3333
new Deflate(),
3434
]);
3535

@@ -48,6 +48,7 @@ Now we can try to deserialize and decrypt the input we receive. We will continue
4848
```php
4949
<?php
5050

51+
use Jose\Component\Core\Converter\StandardConverter;
5152
use Jose\Component\Core\JWK;
5253
use Jose\Component\Encryption\Serializer\JWESerializerManager;
5354
use Jose\Component\Encryption\Serializer\CompactSerializer;
@@ -58,9 +59,12 @@ $jwk = JWK::create([
5859
'k' => 'dzI6nbW4OcNF-AtfxGAmuyz7IpHRudBI0WgGjZWgaRJt6prBn3DARXgUR8NVwKhfL43QBIU2Un3AvCGCHRgY4TbEqhOi8-i98xxmCggNjde4oaW6wkJ2NgM3Ss9SOX9zS3lcVzdCMdum-RwVJ301kbin4UtGztuzJBeg5oVN00MGxjC2xWwyI0tgXVs-zJs5WlafCuGfX1HrVkIf5bvpE0MQCSjdJpSeVao6-RSTYDajZf7T88a2eVjeW31mMAg-jzAWfUrii61T_bYPJFOXW8kkRWoa1InLRdG6bKB9wQs9-VdXZP60Q4Yuj_WZ-lO7qV9AEFrUkkjpaDgZT86w2g',
5960
]);
6061

62+
// The JSON Converter.
63+
$jsonConverter = new StandardConverter();
64+
6165
// The serializer manager. We only use the JWE Compact Serialization Mode.
62-
$serializerManager = new JWESerializerManager([
63-
new CompactSerializer(),
66+
$serializerManager = JWESerializerManager::create([
67+
new CompactSerializer($jsonConverter),
6468
]);
6569

6670
// The input we want to decrypt

components/header-checker.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use Jose\Component\Checker\HeaderCheckerManager;
2828
use Jose\Component\Checker\AlgorithmChecker;
2929
use Jose\Component\Signature\JWSTokenSupport;
3030

31-
$headerCheckerManager = new HeaderCheckerManager(
31+
$headerCheckerManager = HeaderCheckerManager::create(
3232
[
3333
new AlgorithmChecker(['HS256']), // We check the header "alg" (algorithm)
3434
],
@@ -87,8 +87,6 @@ The following header checkers are provided:
8787

8888
If you need, you can create you own header checker. It must implement the interface `Jose\Component\Checker\HeaderChecker`. In the following example, we will check that the protected header parameter `custom` is an array with value `foo` or `bar`.
8989

90-
{% code-tabs %}
91-
{% code-tabs-item title="Acme\\Checker\\CustomChecker.php" %}
9290
```php
9391
<?php
9492

@@ -97,6 +95,9 @@ namespace Acme\Checker;
9795
use Jose\Component\Checker\HeaderChecker;
9896
use Jose\Component\Checker\InvalidHeaderException;
9997

98+
/**
99+
* Class CustomChecker.
100+
*/
100101
final class CustomChecker implements HeaderChecker
101102
{
102103
public function checkHeader($value)
@@ -119,6 +120,4 @@ final class CustomChecker implements HeaderChecker
119120
}
120121
}
121122
```
122-
{% endcode-tabs-item %}
123-
{% endcode-tabs %}
124123

0 commit comments

Comments
 (0)