Updated readme, subscription authorization logic

This commit is contained in:
Chris 2024-03-10 23:12:34 +01:00
parent 87d47f8ce8
commit d05d2e13e3
3 changed files with 12 additions and 13 deletions

View File

@ -39,8 +39,10 @@ $ ./mercureact.phar -c mercureact.conf
* [x] Check JWTs on connect * [x] Check JWTs on connect
* [ ] Check claims on subscribe and publish * [ ] Check claims on subscribe and publish
* [ ] WebSocket authentication * [ ] WebSocket authentication
* [ ] Subscription/Topic manager * [ ] Extract JWT claims to request attributes, instead of JWTToken
* [ ] Unify distribution * [x] Subscription/Topic manager
* [x] Unify distribution
* [ ] Enumerate subscriptions and topics
* [ ] Publish events * [ ] Publish events
* [ ] Server-Side Events distributor * [ ] Server-Side Events distributor
* [x] Distribute events over SSE * [x] Distribute events over SSE
@ -48,6 +50,5 @@ $ ./mercureact.phar -c mercureact.conf
* [ ] Setup subscriptions * [ ] Setup subscriptions
* [ ] Dynamic subscriptions * [ ] Dynamic subscriptions
* [x] Distribute events over WS * [x] Distribute events over WS
* [ ] HTTP * [x] Break out HTTP middleware into classes
* [ ] Break out HTTP middleware into classes
* [ ] HTTP middleware unittests * [ ] HTTP middleware unittests

View File

@ -31,13 +31,8 @@ class Topic
// TODO check if message id has already been published // TODO check if message id has already been published
foreach ($this->subscribers as $subscriber) { foreach ($this->subscribers as $subscriber) {
if ($message->private === true) { // Deliver to all subscribers
// TODO check subscriber access
$subscriber->deliver($message); $subscriber->deliver($message);
} else {
// TODO deliver to subscriber
$subscriber->deliver($message);
}
} }
} }

View File

@ -34,8 +34,10 @@ class TopicManager
public function subscribe(SubscriberInterface $subscriber, array $topics): void public function subscribe(SubscriberInterface $subscriber, array $topics): void
{ {
foreach ($topics as $topic) { foreach ($topics as $topic) {
if ($subscriber->isAuthorized($topic))
$this->getTopic($topic)->addSubscriber($subscriber); $this->getTopic($topic)->addSubscriber($subscriber);
} }
$this->subscribers->attach($subscriber);
} }
public function unsubscribe(SubscriberInterface $subscriber, ?array $topics=null): void public function unsubscribe(SubscriberInterface $subscriber, ?array $topics=null): void
@ -49,6 +51,7 @@ class TopicManager
foreach ($topics as $topic) { foreach ($topics as $topic) {
$this->getTopic($topic)->removeSubscriber($subscriber); $this->getTopic($topic)->removeSubscriber($subscriber);
} }
$this->subscribers->detach($subscriber);
} }
public function getTopicCount(): int public function getTopicCount(): int