Skip to content

[FrameworkBundle] Make uri_signer lazy and improve error when kernel.secret is empty #59086

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 1 commit into from
Dec 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,17 @@ public function load(array $configs, ContainerBuilder $container): void
}
}

$emptySecretHint = '"framework.secret" option';
if (isset($config['secret'])) {
$container->setParameter('kernel.secret', $config['secret']);
$usedEnvs = [];
$container->resolveEnvPlaceholders($config['secret'], null, $usedEnvs);

if ($usedEnvs) {
$emptySecretHint = \sprintf('"%s" env var%s', implode('", "', $usedEnvs), 1 === \count($usedEnvs) ? '' : 's');
}
}
$container->parameterCannotBeEmpty('kernel.secret', 'A non-empty value for the parameter "kernel.secret" is required. Did you forget to configure the "framework.secret" option?');
$container->parameterCannotBeEmpty('kernel.secret', 'A non-empty value for the parameter "kernel.secret" is required. Did you forget to configure the '.$emptySecretHint.'?');

$container->setParameter('kernel.http_method_override', $config['http_method_override']);
$container->setParameter('kernel.trust_x_sendfile_type_header', $config['trust_x_sendfile_type_header']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class_exists(WorkflowEvents::class) ? WorkflowEvents::ALIASES : []
->args([
new Parameter('kernel.secret'),
])
->lazy()
->alias(UriSigner::class, 'uri_signer')

->set('config_cache_factory', ResourceCheckerConfigCacheFactory::class)
Expand Down