Skip to content

Merge release 3.3.5 into 4.0.x #549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"psr/http-client": "^1.0",
"psr/http-factory": "^1.0",
"spomky-labs/aes-key-wrap": "^7.0",
"spomky-labs/pki-framework": "^1.0",
"spomky-labs/pki-framework": "^1.2.1",
"symfony/config": "^5.4|^6.0|^7.0",
"symfony/console": "^5.4|^6.0|^7.0",
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,60 @@ public function getNodeDefinition(NodeDefinition $node): void
->arrayNode($this->name())
->useAttributeAsKey('name')
->arrayPrototype()
->beforeNormalization()
->ifTrue(
static fn (array $v) => isset($v['key_encryption_algorithms']) || isset($v['content_encryption_algorithms'])
)
->then(static function (array $v) {
$v['encryption_algorithms'] = array_merge(
$v['encryption_algorithms'] ?? [],
$v['key_encryption_algorithms'] ?? []
);
$v['encryption_algorithms'] = array_merge(
$v['encryption_algorithms'],
$v['content_encryption_algorithms'] ?? []
);
unset($v['key_encryption_algorithms'], $v['content_encryption_algorithms']);
$v['encryption_algorithms'] = array_values(array_unique($v['encryption_algorithms']));

return $v;
})
->end()
->children()
->booleanNode('is_public')
->info('If true, the service will be public, else private.')
->defaultTrue()
->end()
->arrayNode('key_encryption_algorithms')
->info('A list of supported key encryption algorithms.')
->arrayNode('encryption_algorithms')
->info('A list of key or content encryption algorithm aliases.')
->useAttributeAsKey('name')
->isRequired()
->requiresAtLeastOneElement()
->scalarPrototype()
->end()
->end()
->arrayNode('key_encryption_algorithms')
->info('A list of supported key encryption algorithms.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
)
->useAttributeAsKey('name')
->treatNullLike([])
->treatFalseLike([])
->defaultValue([])
->scalarPrototype()
->end()
->end()
->arrayNode('content_encryption_algorithms')
->info('A list of supported content encryption algorithms.')
->useAttributeAsKey('name')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
)
->treatNullLike([])
->treatFalseLike([])
->defaultValue([])
Expand All @@ -41,6 +79,11 @@ public function getNodeDefinition(NodeDefinition $node): void
->end()
->arrayNode('compression_methods')
->info('A list of supported compression methods.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0.'
)
->useAttributeAsKey('name')
->treatNullLike([])
->treatFalseLike([])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function load(array $configs, ContainerBuilder $container): void
$definition
->setFactory([new Reference(JWEBuilderFactory::class), 'create'])
->setArguments([
$itemConfig['key_encryption_algorithms'],
$itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'],
$itemConfig['encryption_algorithms'],
null,
$itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'],
])
->addTag('jose.jwe_builder')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public function load(array $configs, ContainerBuilder $container): void
$definition
->setFactory([new Reference(JWEDecrypterFactory::class), 'create'])
->setArguments([
$itemConfig['key_encryption_algorithms'],
$itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'],
$itemConfig['encryption_algorithms'],
null,
$itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'],
])
->addTag('jose.jwe_decrypter')
Expand Down
50 changes: 47 additions & 3 deletions src/Bundle/DependencyInjection/Source/Encryption/JWELoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function load(array $configs, ContainerBuilder $container): void
->setFactory([new Reference(JWELoaderFactory::class), 'create'])
->setArguments([
$itemConfig['serializers'],
$itemConfig['key_encryption_algorithms'],
$itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'],
$itemConfig['encryption_algorithms'],
null,
$itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'],
$itemConfig['header_checkers'],
])
Expand All @@ -52,20 +52,59 @@ public function getNodeDefinition(NodeDefinition $node): void
->requiresAtLeastOneElement()
->useAttributeAsKey('name')
->arrayPrototype()
->beforeNormalization()
->ifTrue(
static fn (array $v) => isset($v['key_encryption_algorithms']) || isset($v['content_encryption_algorithms'])
)
->then(static function (array $v) {
$v['encryption_algorithms'] = array_merge(
$v['encryption_algorithms'] ?? [],
$v['key_encryption_algorithms'] ?? []
);
$v['encryption_algorithms'] = array_merge(
$v['encryption_algorithms'],
$v['content_encryption_algorithms'] ?? []
);
unset($v['key_encryption_algorithms'], $v['content_encryption_algorithms']);
$v['encryption_algorithms'] = array_values(array_unique($v['encryption_algorithms']));

return $v;
})
->end()
->children()
->booleanNode('is_public')
->info('If true, the service will be public, else private.')
->defaultTrue()
->end()
->arrayNode('encryption_algorithms')
->info('A list of key or content encryption algorithm aliases.')
->useAttributeAsKey('name')
->isRequired()
->requiresAtLeastOneElement()
->scalarPrototype()
->end()
->end()
->arrayNode('key_encryption_algorithms')
->info('A list of key encryption algorithm aliases.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
)
->useAttributeAsKey('name')
->isRequired()
->treatNullLike([])
->treatFalseLike([])
->defaultValue([])
->scalarPrototype()
->end()
->end()
->arrayNode('content_encryption_algorithms')
->info('A list of key encryption algorithm aliases.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
)
->useAttributeAsKey('name')
->treatNullLike([])
->treatFalseLike([])
Expand All @@ -75,6 +114,11 @@ public function getNodeDefinition(NodeDefinition $node): void
->end()
->arrayNode('compression_methods')
->info('A list of compression method aliases.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0.'
)
->useAttributeAsKey('name')
->treatNullLike([])
->treatFalseLike([])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function load(array $configs, ContainerBuilder $container): void
->setFactory([new Reference(NestedTokenBuilderFactory::class), 'create'])
->setArguments([
$itemConfig['jwe_serializers'],
$itemConfig['key_encryption_algorithms'],
$itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'],
$itemConfig['encryption_algorithms'],
null,
$itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'],
$itemConfig['jws_serializers'],
$itemConfig['signature_algorithms'],
Expand All @@ -52,6 +52,25 @@ public function getNodeDefinition(NodeDefinition $node): void
->treatFalseLike([])
->useAttributeAsKey('name')
->arrayPrototype()
->beforeNormalization()
->ifTrue(
static fn (array $v) => isset($v['key_encryption_algorithms']) || isset($v['content_encryption_algorithms'])
)
->then(static function (array $v) {
$v['encryption_algorithms'] = array_merge(
$v['encryption_algorithms'] ?? [],
$v['key_encryption_algorithms'] ?? []
);
$v['encryption_algorithms'] = array_merge(
$v['encryption_algorithms'],
$v['content_encryption_algorithms'] ?? []
);
unset($v['key_encryption_algorithms'], $v['content_encryption_algorithms']);
$v['encryption_algorithms'] = array_unique(array_values($v['encryption_algorithms']));

return $v;
})
->end()
->children()
->booleanNode('is_public')
->info('If true, the service will be public, else private.')
Expand All @@ -64,15 +83,35 @@ public function getNodeDefinition(NodeDefinition $node): void
->scalarPrototype()
->end()
->end()
->arrayNode('encryption_algorithms')
->info('A list of key or content encryption algorithm aliases.')
->useAttributeAsKey('name')
->isRequired()
->requiresAtLeastOneElement()
->scalarPrototype()
->end()
->end()
->arrayNode('key_encryption_algorithms')
->info('A list of key encryption algorithm aliases.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
)
->useAttributeAsKey('name')
->isRequired()
->treatNullLike([])
->treatFalseLike([])
->defaultValue([])
->scalarPrototype()
->end()
->end()
->arrayNode('content_encryption_algorithms')
->info('A list of key encryption algorithm aliases.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
)
->useAttributeAsKey('name')
->treatNullLike([])
->treatFalseLike([])
Expand All @@ -82,6 +121,11 @@ public function getNodeDefinition(NodeDefinition $node): void
->end()
->arrayNode('compression_methods')
->info('A list of compression method aliases.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0.'
)
->useAttributeAsKey('name')
->treatNullLike([])
->treatFalseLike([])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ public function load(array $configs, ContainerBuilder $container): void
->setFactory([new Reference(NestedTokenLoaderFactory::class), 'create'])
->setArguments([
$itemConfig['jwe_serializers'],
$itemConfig['key_encryption_algorithms'],
$itemConfig['content_encryption_algorithms'] === [] ? null : $itemConfig['content_encryption_algorithms'],
$itemConfig['encryption_algorithms'],
null,
$itemConfig['compression_methods'] === [] ? null : $itemConfig['compression_methods'],
$itemConfig['jwe_header_checkers'],
$itemConfig['jws_serializers'],
Expand All @@ -54,6 +54,25 @@ public function getNodeDefinition(NodeDefinition $node): void
->treatFalseLike([])
->useAttributeAsKey('name')
->arrayPrototype()
->beforeNormalization()
->ifTrue(
static fn (array $v) => isset($v['key_encryption_algorithms']) || isset($v['content_encryption_algorithms'])
)
->then(static function (array $v) {
$v['encryption_algorithms'] = array_merge(
$v['encryption_algorithms'] ?? [],
$v['key_encryption_algorithms'] ?? []
);
$v['encryption_algorithms'] = array_merge(
$v['encryption_algorithms'],
$v['content_encryption_algorithms'] ?? []
);
unset($v['key_encryption_algorithms'], $v['content_encryption_algorithms']);
$v['encryption_algorithms'] = array_values(array_unique($v['encryption_algorithms']));

return $v;
})
->end()
->children()
->booleanNode('is_public')
->info('If true, the service will be public, else private.')
Expand All @@ -66,15 +85,35 @@ public function getNodeDefinition(NodeDefinition $node): void
->scalarPrototype()
->end()
->end()
->arrayNode('encryption_algorithms')
->info('A list of key or content encryption algorithm aliases.')
->useAttributeAsKey('name')
->isRequired()
->requiresAtLeastOneElement()
->scalarPrototype()
->end()
->end()
->arrayNode('key_encryption_algorithms')
->info('A list of key encryption algorithm aliases.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
)
->useAttributeAsKey('name')
->isRequired()
->treatNullLike([])
->treatFalseLike([])
->defaultValue([])
->scalarPrototype()
->end()
->end()
->arrayNode('content_encryption_algorithms')
->info('A list of key encryption algorithm aliases.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0. Please use "encryption_algorithms" instead.'
)
->useAttributeAsKey('name')
->treatNullLike([])
->treatFalseLike([])
Expand All @@ -84,6 +123,11 @@ public function getNodeDefinition(NodeDefinition $node): void
->end()
->arrayNode('compression_methods')
->info('A list of compression method aliases.')
->setDeprecated(
'web-token/jwt-bundle',
'3.3.0',
'The child node "%node%" at path "%path%" is deprecated and will be removed in 4.0.0.'
)
->useAttributeAsKey('name')
->treatNullLike([])
->treatFalseLike([])
Expand Down
2 changes: 1 addition & 1 deletion src/Deprecated/Core/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"ext-mbstring": "*",
"brick/math": "^0.9|^0.10|^0.11|^0.12",
"paragonie/constant_time_encoding": "^2.6",
"spomky-labs/pki-framework": "^1.0",
"spomky-labs/pki-framework": "^1.2.1",
"web-token/jwt-library": "^3.3"
}
}
Loading