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

40 lines
1.1 KiB
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;
2020-08-23 16:12:22 +00:00
use BeyondCode\LaravelWebSockets\Contracts\PushesToPusher;
use Illuminate\Broadcasting\Broadcasters\PusherBroadcaster;
2020-03-04 09:58:39 +00:00
use Illuminate\Http\Request;
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
{
2020-08-23 16:12:22 +00:00
use PushesToPusher;
2020-08-18 17:21:22 +00:00
/**
* Find the app by using the header
* and then reconstruct the PusherBroadcaster
* using our own app selection.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function __invoke(Request $request)
2018-11-23 23:06:28 +00:00
{
$app = App::findById($request->header('x-app-id'));
2020-08-23 16:12:22 +00:00
$broadcaster = $this->getPusherBroadcaster([
'key' => $app->key,
'secret' => $app->secret,
'id' =>$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
}