Skip to content

Commit 7347442

Browse files
authored
Refactor encryption algorithms configuration (#544)
* Refactor encryption algorithms configuration Deprecated 'key_encryption_algorithms' and 'content_encryption_algorithms' have been replaced with a unified 'encryption_algorithms' across multiple classes and configurations. Warning messages have been added to any deprecated usages to ensure smooth transition in future versions. Update test assertions accordingly to reflect these changes. * Update code to avoid use of deprecated encryption algorithms Replaced 'key_encryption_algorithms' and 'content_encryption_algorithms' with 'encryption_algorithms'. Deprecated warning messages have now been included in code to guide future updates. Test cases have been adjusted to validate these changes.
1 parent 0ad5388 commit 7347442

12 files changed

+447
-32
lines changed

phpstan-baseline.neon

+250-10
Original file line numberDiff line numberDiff line change
@@ -1006,11 +1006,6 @@ parameters:
10061006
count: 1
10071007
path: src/Bundle/Serializer/JWESerializer.php
10081008

1009-
-
1010-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWESerializer\\:\\:getSupportedTypes\\(\\) return type has no value type specified in iterable type array\\.$#"
1011-
count: 1
1012-
path: src/Bundle/Serializer/JWESerializer.php
1013-
10141009
-
10151010
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWESerializer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
10161011
count: 1
@@ -1046,11 +1041,6 @@ parameters:
10461041
count: 1
10471042
path: src/Bundle/Serializer/JWSSerializer.php
10481043

1049-
-
1050-
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSSerializer\\:\\:getSupportedTypes\\(\\) return type has no value type specified in iterable type array\\.$#"
1051-
count: 1
1052-
path: src/Bundle/Serializer/JWSSerializer.php
1053-
10541044
-
10551045
message: "#^Method Jose\\\\Bundle\\\\JoseFramework\\\\Serializer\\\\JWSSerializer\\:\\:supportsDenormalization\\(\\) has parameter \\$context with no value type specified in iterable type array\\.$#"
10561046
count: 1
@@ -1288,16 +1278,86 @@ parameters:
12881278
count: 1
12891279
path: src/Library/Checker/IssuerChecker.php
12901280

1281+
-
1282+
message: "#^Property Jose\\\\Component\\\\Console\\\\AddKeyIntoKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1283+
count: 1
1284+
path: src/Library/Console/AddKeyIntoKeysetCommand.php
1285+
1286+
-
1287+
message: "#^Property Jose\\\\Component\\\\Console\\\\AddKeyIntoKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#"
1288+
count: 1
1289+
path: src/Library/Console/AddKeyIntoKeysetCommand.php
1290+
1291+
-
1292+
message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1293+
count: 1
1294+
path: src/Library/Console/EcKeyGeneratorCommand.php
1295+
1296+
-
1297+
message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1298+
count: 1
1299+
path: src/Library/Console/EcKeyGeneratorCommand.php
1300+
12911301
-
12921302
message: "#^Cannot cast mixed to int\\.$#"
12931303
count: 1
12941304
path: src/Library/Console/EcKeysetGeneratorCommand.php
12951305

1306+
-
1307+
message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1308+
count: 1
1309+
path: src/Library/Console/EcKeysetGeneratorCommand.php
1310+
1311+
-
1312+
message: "#^Property Jose\\\\Component\\\\Console\\\\EcKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1313+
count: 1
1314+
path: src/Library/Console/EcKeysetGeneratorCommand.php
1315+
12961316
-
12971317
message: "#^Method Jose\\\\Component\\\\Console\\\\GeneratorCommand\\:\\:getOptions\\(\\) return type has no value type specified in iterable type array\\.$#"
12981318
count: 1
12991319
path: src/Library/Console/GeneratorCommand.php
13001320

1321+
-
1322+
message: "#^Property Jose\\\\Component\\\\Console\\\\GetThumbprintCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1323+
count: 1
1324+
path: src/Library/Console/GetThumbprintCommand.php
1325+
1326+
-
1327+
message: "#^Property Jose\\\\Component\\\\Console\\\\GetThumbprintCommand\\:\\:\\$defaultName has no type specified\\.$#"
1328+
count: 1
1329+
path: src/Library/Console/GetThumbprintCommand.php
1330+
1331+
-
1332+
message: "#^Property Jose\\\\Component\\\\Console\\\\JKULoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1333+
count: 1
1334+
path: src/Library/Console/JKULoaderCommand.php
1335+
1336+
-
1337+
message: "#^Property Jose\\\\Component\\\\Console\\\\JKULoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
1338+
count: 1
1339+
path: src/Library/Console/JKULoaderCommand.php
1340+
1341+
-
1342+
message: "#^Property Jose\\\\Component\\\\Console\\\\KeyAnalyzerCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1343+
count: 1
1344+
path: src/Library/Console/KeyAnalyzerCommand.php
1345+
1346+
-
1347+
message: "#^Property Jose\\\\Component\\\\Console\\\\KeyAnalyzerCommand\\:\\:\\$defaultName has no type specified\\.$#"
1348+
count: 1
1349+
path: src/Library/Console/KeyAnalyzerCommand.php
1350+
1351+
-
1352+
message: "#^Property Jose\\\\Component\\\\Console\\\\KeyFileLoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1353+
count: 1
1354+
path: src/Library/Console/KeyFileLoaderCommand.php
1355+
1356+
-
1357+
message: "#^Property Jose\\\\Component\\\\Console\\\\KeyFileLoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
1358+
count: 1
1359+
path: src/Library/Console/KeyFileLoaderCommand.php
1360+
13011361
-
13021362
message: "#^Parameter \\#1 \\$jwk of method Jose\\\\Component\\\\KeyManagement\\\\Analyzer\\\\KeyAnalyzerManager\\:\\:analyze\\(\\) expects Jose\\\\Component\\\\Core\\\\JWK, mixed given\\.$#"
13031363
count: 1
@@ -1308,31 +1368,211 @@ parameters:
13081368
count: 1
13091369
path: src/Library/Console/KeysetAnalyzerCommand.php
13101370

1371+
-
1372+
message: "#^Property Jose\\\\Component\\\\Console\\\\KeysetAnalyzerCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1373+
count: 1
1374+
path: src/Library/Console/KeysetAnalyzerCommand.php
1375+
1376+
-
1377+
message: "#^Property Jose\\\\Component\\\\Console\\\\KeysetAnalyzerCommand\\:\\:\\$defaultName has no type specified\\.$#"
1378+
count: 1
1379+
path: src/Library/Console/KeysetAnalyzerCommand.php
1380+
1381+
-
1382+
message: "#^Property Jose\\\\Component\\\\Console\\\\MergeKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1383+
count: 1
1384+
path: src/Library/Console/MergeKeysetCommand.php
1385+
1386+
-
1387+
message: "#^Property Jose\\\\Component\\\\Console\\\\MergeKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#"
1388+
count: 1
1389+
path: src/Library/Console/MergeKeysetCommand.php
1390+
1391+
-
1392+
message: "#^Property Jose\\\\Component\\\\Console\\\\NoneKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1393+
count: 1
1394+
path: src/Library/Console/NoneKeyGeneratorCommand.php
1395+
1396+
-
1397+
message: "#^Property Jose\\\\Component\\\\Console\\\\NoneKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1398+
count: 1
1399+
path: src/Library/Console/NoneKeyGeneratorCommand.php
1400+
13111401
-
13121402
message: "#^Cannot cast mixed to int\\.$#"
13131403
count: 1
13141404
path: src/Library/Console/OctKeyGeneratorCommand.php
13151405

1406+
-
1407+
message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1408+
count: 1
1409+
path: src/Library/Console/OctKeyGeneratorCommand.php
1410+
1411+
-
1412+
message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1413+
count: 1
1414+
path: src/Library/Console/OctKeyGeneratorCommand.php
1415+
13161416
-
13171417
message: "#^Cannot cast mixed to int\\.$#"
13181418
count: 2
13191419
path: src/Library/Console/OctKeysetGeneratorCommand.php
13201420

1421+
-
1422+
message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1423+
count: 1
1424+
path: src/Library/Console/OctKeysetGeneratorCommand.php
1425+
1426+
-
1427+
message: "#^Property Jose\\\\Component\\\\Console\\\\OctKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1428+
count: 1
1429+
path: src/Library/Console/OctKeysetGeneratorCommand.php
1430+
1431+
-
1432+
message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1433+
count: 1
1434+
path: src/Library/Console/OkpKeyGeneratorCommand.php
1435+
1436+
-
1437+
message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1438+
count: 1
1439+
path: src/Library/Console/OkpKeyGeneratorCommand.php
1440+
13211441
-
13221442
message: "#^Cannot cast mixed to int\\.$#"
13231443
count: 1
13241444
path: src/Library/Console/OkpKeysetGeneratorCommand.php
13251445

1446+
-
1447+
message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1448+
count: 1
1449+
path: src/Library/Console/OkpKeysetGeneratorCommand.php
1450+
1451+
-
1452+
message: "#^Property Jose\\\\Component\\\\Console\\\\OkpKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1453+
count: 1
1454+
path: src/Library/Console/OkpKeysetGeneratorCommand.php
1455+
1456+
-
1457+
message: "#^Property Jose\\\\Component\\\\Console\\\\OptimizeRsaKeyCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1458+
count: 1
1459+
path: src/Library/Console/OptimizeRsaKeyCommand.php
1460+
1461+
-
1462+
message: "#^Property Jose\\\\Component\\\\Console\\\\OptimizeRsaKeyCommand\\:\\:\\$defaultName has no type specified\\.$#"
1463+
count: 1
1464+
path: src/Library/Console/OptimizeRsaKeyCommand.php
1465+
1466+
-
1467+
message: "#^Property Jose\\\\Component\\\\Console\\\\P12CertificateLoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1468+
count: 1
1469+
path: src/Library/Console/P12CertificateLoaderCommand.php
1470+
1471+
-
1472+
message: "#^Property Jose\\\\Component\\\\Console\\\\P12CertificateLoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
1473+
count: 1
1474+
path: src/Library/Console/P12CertificateLoaderCommand.php
1475+
1476+
-
1477+
message: "#^Property Jose\\\\Component\\\\Console\\\\PemConverterCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1478+
count: 1
1479+
path: src/Library/Console/PemConverterCommand.php
1480+
1481+
-
1482+
message: "#^Property Jose\\\\Component\\\\Console\\\\PemConverterCommand\\:\\:\\$defaultName has no type specified\\.$#"
1483+
count: 1
1484+
path: src/Library/Console/PemConverterCommand.php
1485+
1486+
-
1487+
message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeyCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1488+
count: 1
1489+
path: src/Library/Console/PublicKeyCommand.php
1490+
1491+
-
1492+
message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeyCommand\\:\\:\\$defaultName has no type specified\\.$#"
1493+
count: 1
1494+
path: src/Library/Console/PublicKeyCommand.php
1495+
1496+
-
1497+
message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1498+
count: 1
1499+
path: src/Library/Console/PublicKeysetCommand.php
1500+
1501+
-
1502+
message: "#^Property Jose\\\\Component\\\\Console\\\\PublicKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#"
1503+
count: 1
1504+
path: src/Library/Console/PublicKeysetCommand.php
1505+
1506+
-
1507+
message: "#^Property Jose\\\\Component\\\\Console\\\\RotateKeysetCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1508+
count: 1
1509+
path: src/Library/Console/RotateKeysetCommand.php
1510+
1511+
-
1512+
message: "#^Property Jose\\\\Component\\\\Console\\\\RotateKeysetCommand\\:\\:\\$defaultName has no type specified\\.$#"
1513+
count: 1
1514+
path: src/Library/Console/RotateKeysetCommand.php
1515+
13261516
-
13271517
message: "#^Cannot cast mixed to int\\.$#"
13281518
count: 1
13291519
path: src/Library/Console/RsaKeyGeneratorCommand.php
13301520

1521+
-
1522+
message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1523+
count: 1
1524+
path: src/Library/Console/RsaKeyGeneratorCommand.php
1525+
1526+
-
1527+
message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1528+
count: 1
1529+
path: src/Library/Console/RsaKeyGeneratorCommand.php
1530+
13311531
-
13321532
message: "#^Cannot cast mixed to int\\.$#"
13331533
count: 2
13341534
path: src/Library/Console/RsaKeysetGeneratorCommand.php
13351535

1536+
-
1537+
message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeysetGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1538+
count: 1
1539+
path: src/Library/Console/RsaKeysetGeneratorCommand.php
1540+
1541+
-
1542+
message: "#^Property Jose\\\\Component\\\\Console\\\\RsaKeysetGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1543+
count: 1
1544+
path: src/Library/Console/RsaKeysetGeneratorCommand.php
1545+
1546+
-
1547+
message: "#^Property Jose\\\\Component\\\\Console\\\\SecretKeyGeneratorCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1548+
count: 1
1549+
path: src/Library/Console/SecretKeyGeneratorCommand.php
1550+
1551+
-
1552+
message: "#^Property Jose\\\\Component\\\\Console\\\\SecretKeyGeneratorCommand\\:\\:\\$defaultName has no type specified\\.$#"
1553+
count: 1
1554+
path: src/Library/Console/SecretKeyGeneratorCommand.php
1555+
1556+
-
1557+
message: "#^Property Jose\\\\Component\\\\Console\\\\X509CertificateLoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1558+
count: 1
1559+
path: src/Library/Console/X509CertificateLoaderCommand.php
1560+
1561+
-
1562+
message: "#^Property Jose\\\\Component\\\\Console\\\\X509CertificateLoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
1563+
count: 1
1564+
path: src/Library/Console/X509CertificateLoaderCommand.php
1565+
1566+
-
1567+
message: "#^Property Jose\\\\Component\\\\Console\\\\X5ULoaderCommand\\:\\:\\$defaultDescription has no type specified\\.$#"
1568+
count: 1
1569+
path: src/Library/Console/X5ULoaderCommand.php
1570+
1571+
-
1572+
message: "#^Property Jose\\\\Component\\\\Console\\\\X5ULoaderCommand\\:\\:\\$defaultName has no type specified\\.$#"
1573+
count: 1
1574+
path: src/Library/Console/X5ULoaderCommand.php
1575+
13361576
-
13371577
message: "#^Call to function is_string\\(\\) with string will always evaluate to true\\.$#"
13381578
count: 1

src/Bundle/DependencyInjection/Source/Encryption/AbstractEncryptionSource.php

+45-2
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,60 @@ public function getNodeDefinition(NodeDefinition $node): void
1717
->arrayNode($this->name())
1818
->useAttributeAsKey('name')
1919
->arrayPrototype()
20+
->beforeNormalization()
21+
->ifTrue(
22+
static fn (array $v) => isset($v['key_encryption_algorithms']) || isset($v['content_encryption_algorithms'])
23+
)
24+
->then(static function (array $v) {
25+
$v['encryption_algorithms'] = array_merge(
26+
$v['encryption_algorithms'] ?? [],
27+
$v['key_encryption_algorithms'] ?? []
28+
);
29+
$v['encryption_algorithms'] = array_merge(
30+
$v['encryption_algorithms'],
31+
$v['content_encryption_algorithms'] ?? []
32+
);
33+
unset($v['key_encryption_algorithms'], $v['content_encryption_algorithms']);
34+
$v['encryption_algorithms'] = array_values(array_unique($v['encryption_algorithms']));
35+
36+
return $v;
37+
})
38+
->end()
2039
->children()
2140
->booleanNode('is_public')
2241
->info('If true, the service will be public, else private.')
2342
->defaultTrue()
2443
->end()
25-
->arrayNode('key_encryption_algorithms')
26-
->info('A list of supported key encryption algorithms.')
44+
->arrayNode('encryption_algorithms')
45+
->info('A list of key or content encryption algorithm aliases.')
2746
->useAttributeAsKey('name')
2847
->isRequired()
2948
->requiresAtLeastOneElement()
3049
->scalarPrototype()
3150
->end()
3251
->end()
52+
->arrayNode('key_encryption_algorithms')
53+
->info('A list of supported key encryption algorithms.')
54+
->setDeprecated(
55+
'web-token/jwt-bundle',
56+
'3.3.0',
57+
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
58+
)
59+
->useAttributeAsKey('name')
60+
->treatNullLike([])
61+
->treatFalseLike([])
62+
->defaultValue([])
63+
->scalarPrototype()
64+
->end()
65+
->end()
3366
->arrayNode('content_encryption_algorithms')
3467
->info('A list of supported content encryption algorithms.')
3568
->useAttributeAsKey('name')
69+
->setDeprecated(
70+
'web-token/jwt-bundle',
71+
'3.3.0',
72+
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
73+
)
3674
->treatNullLike([])
3775
->treatFalseLike([])
3876
->defaultValue([])
@@ -41,6 +79,11 @@ public function getNodeDefinition(NodeDefinition $node): void
4179
->end()
4280
->arrayNode('compression_methods')
4381
->info('A list of supported compression methods.')
82+
->setDeprecated(
83+
'web-token/jwt-bundle',
84+
'3.3.0',
85+
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0.'
86+
)
4487
->useAttributeAsKey('name')
4588
->treatNullLike([])
4689
->treatFalseLike([])

0 commit comments

Comments
 (0)