Merge branch 'master' of github.com:beyondcode/laravel-websockets
This commit is contained in:
commit
687d584e56
|
|
@ -50,7 +50,7 @@ return [
|
|||
* Leave this empty if you want to accepts requests from all hosts.
|
||||
*/
|
||||
'allowedOrigins' => [
|
||||
|
||||
//
|
||||
],
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\SendMessage;
|
|||
use BeyondCode\LaravelWebSockets\Dashboard\Http\Controllers\ShowDashboard;
|
||||
|
||||
Route::get('/', ShowDashboard::class);
|
||||
Route::post('/auth', AuthenticateDashboard::class);
|
||||
Route::post('/event', SendMessage::class);
|
||||
Route::post('auth', AuthenticateDashboard::class);
|
||||
Route::post('event', SendMessage::class);
|
||||
|
|
@ -60,21 +60,23 @@ abstract class EchoController implements HttpServerInterface
|
|||
|
||||
function onError(ConnectionInterface $connection, Exception $exception)
|
||||
{
|
||||
if ($exception instanceof HttpException) {
|
||||
$response = new Response($exception->getStatusCode(), [
|
||||
'Content-Type' => 'application/json'
|
||||
], json_encode([
|
||||
'error' => $exception->getMessage()
|
||||
]));
|
||||
|
||||
$connection->send(Psr\str($response));
|
||||
$connection->close();
|
||||
if (! $exception instanceof HttpException) {
|
||||
return;
|
||||
}
|
||||
|
||||
$response = new Response($exception->getStatusCode(), [
|
||||
'Content-Type' => 'application/json'
|
||||
], json_encode([
|
||||
'error' => $exception->getMessage()
|
||||
]));
|
||||
|
||||
$connection->send(Psr\str($response));
|
||||
$connection->close();
|
||||
}
|
||||
|
||||
public function ensureValidAppId(string $appId)
|
||||
{
|
||||
if (! $client = Client::findByAppId($appId)) {
|
||||
if (!$client = Client::findByAppId($appId)) {
|
||||
throw new HttpException(401, "Unknown app id `{$appId}` provided.");
|
||||
}
|
||||
|
||||
|
|
@ -86,10 +88,10 @@ abstract class EchoController implements HttpServerInterface
|
|||
$bodyMd5 = md5($request->getContent());
|
||||
|
||||
$signature =
|
||||
"{$request->getMethod()}\n/{$request->path()}\n".
|
||||
"auth_key={$request->get('auth_key')}".
|
||||
"&auth_timestamp={$request->get('auth_timestamp')}".
|
||||
"&auth_version={$request->get('auth_version')}".
|
||||
"{$request->getMethod()}\n/{$request->path()}\n" .
|
||||
"auth_key={$request->get('auth_key')}" .
|
||||
"&auth_timestamp={$request->get('auth_timestamp')}" .
|
||||
"&auth_version={$request->get('auth_version')}" .
|
||||
"&body_md5={$bodyMd5}";
|
||||
|
||||
$authSignature = hash_hmac('sha256', $signature, Client::findByAppId($request->get('appId'))->appSecret);
|
||||
|
|
|
|||
Loading…
Reference in New Issue