laravel-websockets/src/Dashboard/Http/Controllers/AuthenticateDashboard.php

36 lines
958 B
PHP
Raw Normal View History

2018-11-23 23:06:28 +00:00
<?php
2018-11-26 08:55:06 +00:00
namespace BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers;
2018-11-23 23:06:28 +00:00
use BeyondCode\LaravelWebSockets\Apps\App;
use Illuminate\Broadcasting\Broadcasters\PusherBroadcaster;
2020-03-04 09:58:39 +00:00
use Illuminate\Http\Request;
use Pusher\Pusher;
2018-11-23 23:06:28 +00:00
2018-11-26 00:01:18 +00:00
class AuthenticateDashboard
2018-11-23 23:06:28 +00:00
{
public function __invoke(Request $request)
2018-11-23 23:06:28 +00:00
{
/**
* Find the app by using the header
* and then reconstruct the PusherBroadcaster
* using our own app selection.
*/
$app = App::findById($request->header('x-app-id'));
$broadcaster = new PusherBroadcaster(new Pusher(
$app->key,
$app->secret,
$app->id,
[]
));
2018-11-25 21:35:34 +00:00
/*
* Since the dashboard itself is already secured by the
* Authorize middleware, we can trust all channel
* authentication requests in here.
*/
2018-11-23 23:06:28 +00:00
return $broadcaster->validAuthenticationResponse($request, []);
}
2018-12-04 21:22:33 +00:00
}