Auth
This commit is contained in:
parent
a6d844bd01
commit
df0f8f36f7
25
Authentication.php
Normal file
25
Authentication.php
Normal 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);
|
||||
}
|
||||
}
|
||||
@ -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
BIN
channels/.channels.php.swp
Normal file
Binary file not shown.
18
channels/channels.php
Normal file
18
channels/channels.php
Normal 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;
|
||||
});
|
||||
25
classes/Authentication.php
Normal file
25
classes/Authentication.php
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user