You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix#98: scope Mercure subscriber JWT tokens to user-accessible resources
Adds a `mercure.secure_subscriptions` config option (default: false). When
enabled, MercureAuthorization evaluates each resource's security expression
at subscription-token-generation time. Resources with class-level security
expressions (e.g. role checks) are excluded from tokens when the current
user fails the check. Resources with item-level security (expressions
referencing `object`) are always included because access cannot be
determined without a concrete instance.
DummySecuredMercureResource test entity and three Behat scenarios verify
that admin-only topics are excluded for regular users and anonymous users,
and included for admins. Test config enables secure_subscriptions: true.
Copy file name to clipboardExpand all lines: src/DependencyInjection/Configuration.php
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,10 @@ private function addMercureNode(ArrayNodeDefinition $rootNode): void
51
51
->addDefaultsIfNotSet()
52
52
->children()
53
53
->scalarNode('hub_name')->defaultNull()->end()
54
+
->booleanNode('secure_subscriptions')
55
+
->defaultFalse()
56
+
->info('When true, subscriber JWT tokens only include topics for resources the current user can access. Requires class-level security expressions (i.e. no "object" variable) on API operations to be evaluated at subscription time.')
0 commit comments