Skip to content

Failed to subscribe to Private Updates #591

Closed
@tpharaoh

Description

I am trying to figure out where the issue is, I can't get private updates to my subscriber.

On login I send a jwt

$key = Key\InMemory::plainText('!ChangeMe!'); // don't forget to set this parameter! Test value: !ChangeMe!
        $configuration = Configuration::forSymmetricSigner(new Sha256(), $key);
            $path = [
              'http://localhost/api/raw_datas/*'
            ];


        $token = $configuration->builder()
            ->withClaim('mercure', ['subscribe' => $path

            ]) // can also be a URI template, or *
            ->getToken($configuration->signer(), $configuration->signingKey())
            ->toString();

        $data['mercureToken'] = $token;

I have an entity which sends the private updates when a new row is added, below is an example:

{"level":"info","ts":1637671722.7986138,"logger":"http.handlers.mercure","msg":"Update published","update":{"id":"urn:uuid:fcb8518c-5b11-4e7b-87d7-64430e25360f","type":"","retry":0,"topics":["http://localhost/api/raw_datas/93"],"private":true},"remote_addr":"11.75.178.192:61592"}
{"level":"info","ts":1637671722.798698,"logger":"http.log.access","msg":"handled request","request":{"remote_addr":"11.75.178.192:61592","proto":"HTTP/2.0","method":"POST","host":"mercure.domain.fi","uri":"/.well-known/mercure","headers":{"User-Agent":["Symfony HttpClient/Curl"],"Accept-Encoding":["gzip"],"Content-Length":["2103"],"Content-Type":["application/x-www-form-urlencoded"],"Accept":["*/*"],"Authorization":["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtZXJjdXJlIjp7InB1Ymxpc2giOlsiKiJdfX0.obDjwCgqtPuIvwBlTxUEmibbBf0zypKCNzNKP7Op2UM"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":"mercure.domain.fi"}},"common_log":"11.75.178.192 - - [23/Nov/2021:12:48:42 +0000] \"POST /.well-known/mercure HTTP/2.0\" 200 45","duration":0.00360974,"size":45,"status":200,"resp_headers":{"Server":["Caddy"],"X-Frame-Options":["DENY"],"X-Content-Type-Options":["nosniff"],"X-Xss-Protection":["1; mode=block"],"Content-Security-Policy":["default-src 'self' mercure.rocks cdn.jsdelivr.net"]}}

On the VueJS front end, I use Yaffle/EventSource to add the JWT token

  const url = new URL('https://mercure.domain.fi/.well-known/mercure');
    
    url.searchParams.append('topic', 'http://localhost/api/raw_datas/*');
    
    const EventSource = EventSourcePolyfill;
    const eventSource = new EventSource(url,{
          
          headers: {
              
              'Authorization': 'Bearer ' + store.mercureToken.value
          }
      });
    eventSource.onmessage = e => console.log(e.data); // do something with the payload

It subscribes. The token shows, only thing I see is the token is in handle.request, and not in new subscriber. Is that normal?

{"level":"info","ts":1637672544.7301142,"logger":"http.handlers.mercure","msg":"Subscriber disconnected","subscriber":{"id":"urn:uuid:67ea2cf4-50cf-4480-857d-76ef23a74acc","last_event_id":"","remote_addr":"85.75.178.192:54095","topic_selectors":["http://localhost/api/raw_datas/*"],"topics":["http://localhost/api/raw_datas/*","https://example.com/users/dunglas"]}}
{"level":"info","ts":1637672544.7301977,"logger":"http.log.access","msg":"handled request","request":{"remote_addr":"85.75.178.192:54095","proto":"HTTP/2.0","method":"GET","host":"mercure.domain.fi","uri":"/.well-known/mercure?topic=http%3A%2F%2Flocalhost%2Fapi%2Fraw_datas%2F*&topic=https%3A%2F%2Fexample.com%2Fusers%2Fdunglas","headers":{"Origin":["http://localhost:8080"],"Sec-Fetch-Dest":["empty"],"Accept-Encoding":["gzip, deflate, br"],"Sec-Gpc":["1"],"Authorization":["Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJodHRwOi8vbG9jYWxob3N0L2FwaS9yYXdfZGF0YXMvKiJdfX0.z6I3IApnTcJ1caaITEtaGv-gCPM4KUj-JLMSAjZlyVo"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36"],"Referer":["http://localhost:8080/"],"Accept-Language":["en-US,en;q=0.9"],"Accept":["text/event-stream"],"Sec-Fetch-Mode":["cors"],"Sec-Ch-Ua":["\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"96\", \"Google Chrome\";v=\"96\""],"Sec-Ch-Ua-Platform":["\"macOS\""],"Sec-Fetch-Site":["cross-site"],"Sec-Ch-Ua-Mobile":["?0"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":"mercure.domain.fi"}},"common_log":"85.75.178.192 - - [23/Nov/2021:13:02:24 +0000] \"GET /.well-known/mercure?topic=http%3A%2F%2Flocalhost%2Fapi%2Fraw_datas%2F*&topic=https%3A%2F%2Fexample.com%2Fusers%2Fdunglas HTTP/2.0\" 200 2","duration":47.335029145,"size":2,"status":200,"resp_headers":{"Access-Control-Allow-Credentials":["true"],"Expire":["0"],"X-Accel-Buffering":["no"],"X-Frame-Options":["DENY"],"X-Xss-Protection":["1; mode=block"],"Content-Security-Policy":["default-src 'self' mercure.rocks cdn.jsdelivr.net"],"Connection":["keep-alive"],"Content-Type":["text/event-stream"],"Cache-Control":["private, no-cache, no-store, must-revalidate, max-age=0"],"Pragma":["no-cache"],"Server":["Caddy"],"X-Content-Type-Options":["nosniff"],"Access-Control-Allow-Origin":["*"]}}
{"level":"info","ts":1637672546.2951877,"logger":"http.log.access","msg":"handled request","request":{"remote_addr":"85.75.178.192:54095","proto":"HTTP/2.0","method":"OPTIONS","host":"mercure.domain.fi","uri":"/.well-known/mercure?topic=http%3A%2F%2Flocalhost%2Fapi%2Fraw_datas%2F*&topic=https%3A%2F%2Fexample.com%2Fusers%2Fdunglas","headers":{"Accept-Encoding":["gzip, deflate, br"],"Accept":["*/*"],"Access-Control-Request-Method":["GET"],"Origin":["http://localhost:8080"],"Sec-Fetch-Mode":["cors"],"Sec-Fetch-Site":["cross-site"],"Sec-Fetch-Dest":["empty"],"Referer":["http://localhost:8080/"],"Access-Control-Request-Headers":["authorization"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36"],"Accept-Language":["en-US,en;q=0.9"],"Sec-Gpc":["1"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":"mercure.domain.fi"}},"common_log":"85.75.178.192 - - [23/Nov/2021:13:02:26 +0000] \"OPTIONS /.well-known/mercure?topic=http%3A%2F%2Flocalhost%2Fapi%2Fraw_datas%2F*&topic=https%3A%2F%2Fexample.com%2Fusers%2Fdunglas HTTP/2.0\" 200 0","duration":0.000135783,"size":0,"status":200,"resp_headers":{"Server":["Caddy"],"X-Frame-Options":["DENY"],"X-Content-Type-Options":["nosniff"],"X-Xss-Protection":["1; mode=block"],"Content-Security-Policy":["default-src 'self' mercure.rocks cdn.jsdelivr.net"],"Access-Control-Allow-Headers":["Authorization"],"Access-Control-Allow-Credentials":["true"],"Access-Control-Allow-Origin":["*"]}}
{"level":"info","ts":1637672546.374491,"logger":"http.handlers.mercure","msg":"New subscriber","subscriber":{"id":"urn:uuid:f9e8c08d-cd6f-4d10-853e-75bcf10e6ce8","last_event_id":"","remote_addr":"85.75.178.192:54095","topic_selectors":["http://localhost/api/raw_datas/*"],"topics":["http://localhost/api/raw_datas/*","https://example.com/users/dunglas"]}}
{"level":"info","ts":1637672547.329528,"logger":"http.handlers.mercure","msg":"Subscriber disconnected","subscriber":{"id":"urn:uuid:68fa3ad0-2699-4852-9131-054696af0d0c","last_event_id":"","remote_addr":"85.75.178.192:54095","topic_selectors":["http://localhost/api/raw_datas/*"],"topics":["http://localhost/api/raw_datas/*","https://example.com/users/dunglas"]}}
{"level":"info","ts":1637672547.3296108,"logger":"http.log.access","msg":"handled request","request":{"remote_addr":"85.75.178.192:54095","proto":"HTTP/2.0","method":"GET","host":"mercure.domain.fi","uri":"/.well-known/mercure?topic=http%3A%2F%2Flocalhost%2Fapi%2Fraw_datas%2F*&topic=https%3A%2F%2Fexample.com%2Fusers%2Fdunglas","headers":{"Sec-Ch-Ua-Mobile":["?0"],"Sec-Gpc":["1"],"Origin":["http://localhost:8080"],"Sec-Fetch-Site":["cross-site"],"Sec-Ch-Ua":["\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"96\", \"Google Chrome\";v=\"96\""],"Sec-Ch-Ua-Platform":["\"macOS\""],"Sec-Fetch-Mode":["cors"],"Sec-Fetch-Dest":["empty"],"Accept-Encoding":["gzip, deflate, br"],"Authorization":["Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtZXJjdXJlIjp7InN1YnNjcmliZSI6WyJodHRwOi8vbG9jYWxob3N0L2FwaS9yYXdfZGF0YXMvKiJdfX0.z6I3IApnTcJ1caaITEtaGv-gCPM4KUj-JLMSAjZlyVo"],"User-Agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.55 Safari/537.36"],"Accept-Language":["en-US,en;q=0.9"],"Accept":["text/event-stream"],"Referer":["http://localhost:8080/"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","proto_mutual":true,"server_name":"mercure.domain.fi"}},"common_log":"85.75.178.192 - - [23/Nov/2021:13:02:27 +0000] \"GET /.well-known/mercure?topic=http%3A%2F%2Flocalhost%2Fapi%2Fraw_datas%2F*&topic=https%3A%2F%2Fexample.com%2Fusers%2Fdunglas HTTP/2.0\" 200 2","duration":46.966630725,"size":2,"status":200,"resp_headers":{"Pragma":["no-cache"],"X-Content-Type-Options":["nosniff"],"X-Xss-Protection":["1; mode=block"],"Content-Security-Policy":["default-src 'self' mercure.rocks cdn.jsdelivr.net"],"X-Frame-Options":["DENY"],"Access-Control-Allow-Origin":["*"],"Expire":["0"],"X-Accel-Buffering":["no"],"Server":["Caddy"],"Access-Control-Allow-Credentials":["true"],"Connection":["keep-alive"],"Content-Type":["text/event-stream"],"Cache-Control":["private, no-cache, no-store, must-revalidate, max-age=0"]}}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions