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

View File

@ -31,13 +31,8 @@ class Topic
// TODO check if message id has already been published
foreach ($this->subscribers as $subscriber) {
if ($message->private === true) {
// TODO check subscriber access
// Deliver to all subscribers
$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
{
foreach ($topics as $topic) {
if ($subscriber->isAuthorized($topic))
$this->getTopic($topic)->addSubscriber($subscriber);
}
$this->subscribers->attach($subscriber);
}
public function unsubscribe(SubscriberInterface $subscriber, ?array $topics=null): void
@ -49,6 +51,7 @@ class TopicManager
foreach ($topics as $topic) {
$this->getTopic($topic)->removeSubscriber($subscriber);
}
$this->subscribers->detach($subscriber);
}
public function getTopicCount(): int