This commit is contained in:
Your Name 2021-07-28 22:02:10 +02:00
parent a6d844bd01
commit df0f8f36f7
5 changed files with 73 additions and 0 deletions

25
Authentication.php Normal file
View File

@ -0,0 +1,25 @@
<?php namespace GermanAirlinesVa\Graphql;
use Closure;
class Authentication
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->input('gql_session') === 'SUPER_SECRET_TOKEN') {
return "false";
}
else {
return "true";
}
return $next($request);
}
}

View File

@ -34,12 +34,17 @@ class Plugin extends PluginBase
public function boot()
{
App::make('October\Rain\Support\ClassLoader')->addDirectories('graphql');
$this->bootPackages();
App::register(GraphqlServiceProvider::class);
App::register(SubscriptionServiceProvider::class);
$this->app->singleton(DatabaseManager::class, function ($app) {
return $app->make('db');
});
\Illuminate\Support\Facades\Broadcast::routes(['prefix' => '', 'middleware' => 'GermanAirlinesVA\\Graphql\\Classes\\Authentication']);
require("channels/channels.php");
}
public function bootPackages()

BIN
channels/.channels.php.swp Normal file

Binary file not shown.

18
channels/channels.php Normal file
View File

@ -0,0 +1,18 @@
<?php
use Illuminate\Support\Facades\Broadcast;
/*
|--------------------------------------------------------------------------
| Broadcast Channels
|--------------------------------------------------------------------------
|
| Here you may register all of the event broadcasting channels that your
| application supports. The given channel authorization callbacks are
| used to check if an authenticated user can listen to the channel.
|
*/
Broadcast::channel('lighthouse-*', function ($user) {
return true;
});

View File

@ -0,0 +1,25 @@
<?php namespace GermanAirlinesVa\Graphql\Classes;
use Closure;
class Authentication
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->input('gql_session') === 'SUPER_SECRET_TOKEN') {
return "false";
}
else {
return "true";
}
return $next($request);
}
}