v0.1.3: audit-driven non-breaking fixes
Three bugs surfaced by the post-v0.1.2 architecture audit: - bridge.qml_path is now actually configurable. BridgeBundle::configure defines the qml_path scalar node (default ../qml/); loadExtension exposes it as the bridge.qml_path container parameter; services.yaml binds it into BridgeResourceMaker + BridgeWindowMaker. Apps override with `config/packages/bridge.yaml`. The existing maker docstrings claimed this worked already — they lied; now they don't. - SessionAuthenticator implements AuthenticationEntryPointInterface and routes the no-token entry-point path through the same problem+json helper as onAuthenticationFailure, so QML's RestClient sees one error shape regardless of which firewall path was taken. Test added. - CorrelationKeyListener::onTerminate guards on isMainRequest() now, matching onRequest's existing guard. No user-visible impact in worker mode (no sub-requests emitted), but the asymmetry was a defensive bug that would corrupt optimistic-update reconciliation. PLAN.md §13 gains a v0.1.3 section + folds the audit's API-surface items (PublisherInterface / ModelPublisherInterface / BridgeOp enum / maker DRY / DTO-shaped scaffold) into v0.2.0. CHANGELOG.md mirrors. PHPStan + cs-fixer + PHPUnit (17/17) + maker snapshot tests all green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ use Symfony\Component\Security\Http\Authenticator\AbstractAuthenticator;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Badge\UserBadge;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
|
||||
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
|
||||
use Symfony\Component\Security\Http\EntryPoint\AuthenticationEntryPointInterface;
|
||||
|
||||
/**
|
||||
* Validates the per-session bearer token shared between the Qt host
|
||||
@@ -22,7 +23,7 @@ use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPasspor
|
||||
* Qt host generates it per session and passes it to FrankenPHP via env.
|
||||
* See PLAN.md §3 (*Run modes*, *Edge cases — Per-session secret rotation*).
|
||||
*/
|
||||
final class SessionAuthenticator extends AbstractAuthenticator
|
||||
final class SessionAuthenticator extends AbstractAuthenticator implements AuthenticationEntryPointInterface
|
||||
{
|
||||
public function __construct(
|
||||
#[\SensitiveParameter]
|
||||
@@ -57,13 +58,30 @@ final class SessionAuthenticator extends AbstractAuthenticator
|
||||
}
|
||||
|
||||
public function onAuthenticationFailure(Request $request, AuthenticationException $exception): Response
|
||||
{
|
||||
return $this->problemJson($exception->getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Entry point invoked when access is denied without a triggered authenticator
|
||||
* (e.g. an anonymous request to a protected route). Without this, Symfony
|
||||
* returns its default `WWW-Authenticate: Form` 302/401, which clients
|
||||
* speaking JSON would never expect — same shape as onAuthenticationFailure
|
||||
* keeps QML's RestClient error mapping consistent across both paths.
|
||||
*/
|
||||
public function start(Request $request, ?AuthenticationException $authException = null): Response
|
||||
{
|
||||
return $this->problemJson($authException?->getMessage() ?? 'Bearer token required.');
|
||||
}
|
||||
|
||||
private function problemJson(string $detail): JsonResponse
|
||||
{
|
||||
return new JsonResponse(
|
||||
[
|
||||
'type' => 'about:blank',
|
||||
'title' => 'Unauthorized',
|
||||
'status' => Response::HTTP_UNAUTHORIZED,
|
||||
'detail' => $exception->getMessage(),
|
||||
'detail' => $detail,
|
||||
],
|
||||
Response::HTTP_UNAUTHORIZED,
|
||||
['Content-Type' => 'application/problem+json'],
|
||||
|
||||
Reference in New Issue
Block a user