Я пытаюсь аутентифицировать подписки с помощью Lighthouse ( документы )
const pusher = new Pusher('blabla', {
cluster: 'eu',
forceTLS: true,
authEndpoint: 'https://app.test/graphql/subscriptions/auth',
auth: {
headers: {
Authorization: `Bearer blabla`
}
}
})
Но когда я запускаю запрос на подписку, я получаю это
Unable to retrieve auth string from auth endpoint.
Received status 403 from https://app.test/graphql/subscriptions/auth.
Clients must be authenticated to join private or presence channels.
See: https://pusher.com/docs/authenticating_users
Поэтому я решил проследить за потоком.
И вот где он терпит неудачу:
//
// Nuwave\Lighthouse\Subscriptions > class Authorizer
//
public function authorize(Request $request): bool
$subscriber = $this->storage->subscriberByRequest(
$request->input(),
$request->headers->all()
);
// ? "$subscriber" is empty here. ==> return false
if (! $subscriber) {
return false;
}
...
}
Войдя внутрь $this->storage->subscriberByRequest()
, я получаю
//
// Nuwave\Lighthouse\Subscriptions > class StorageManager
//
public function subscriberByRequest(array $input, array $headers): ?Subscriber
{
$channel = Arr::get($input, 'channel_name');
return $channel
? $this->subscriberByChannel($channel)
: null;
}
public function subscriberByChannel(string $channel): ?Subscriber
{
$key = self::SUBSCRIBER_KEY.".{$channel}";
// At this point, "$key" equals "graphql.subscriber.private-lighthouse-blablabla"
return $this->cache->get($key); // ? This returns NULL
}
Может кто-нибудь помогите?
Я что-то пропустил?
Моя конфигурация:
# composer.json
"php": "^7.4",
"laravel/framework": "^7.0",
"nuwave/lighthouse": "^4.11",
"pusher/pusher-php-server": "^4.1"
# .env
BROADCAST_DRIVER=pusher
CACHE_DRIVER=file
LIGHTHOUSE_SUBSCRIPTION_STORAGE=file
LIGHTHOUSE_BROADCASTER=pusher
# config/lighthouse.php
'subscriptions' => [
'storage' => env('LIGHTHOUSE_SUBSCRIPTION_STORAGE', 'file'),
'broadcaster' => env('LIGHTHOUSE_BROADCASTER', 'pusher')
],