From 74cb1477bb921a2378ea22a552b71a48c11e0931 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 20 Jul 2018 16:34:32 +0200 Subject: Better API (integrated oauth completely) --- infrastructure/Http/ApiRequest.php | 21 ++++++++++ infrastructure/Http/Controller.php | 10 +++++ infrastructure/Http/Kernel.php | 47 +++++++++++++++++++++++ infrastructure/Http/Middleware/EncryptCookies.php | 17 ++++++++ infrastructure/Http/RouteServiceProvider.php | 23 +++++++++++ 5 files changed, 118 insertions(+) create mode 100644 infrastructure/Http/ApiRequest.php create mode 100644 infrastructure/Http/Controller.php create mode 100644 infrastructure/Http/Kernel.php create mode 100644 infrastructure/Http/Middleware/EncryptCookies.php create mode 100644 infrastructure/Http/RouteServiceProvider.php (limited to 'infrastructure/Http') diff --git a/infrastructure/Http/ApiRequest.php b/infrastructure/Http/ApiRequest.php new file mode 100644 index 0000000..0183bb4 --- /dev/null +++ b/infrastructure/Http/ApiRequest.php @@ -0,0 +1,21 @@ +errors()->toJson()); + } + + protected function failedAuthorization() + { + throw new HttpException(403); + } +} diff --git a/infrastructure/Http/Controller.php b/infrastructure/Http/Controller.php new file mode 100644 index 0000000..aa567b9 --- /dev/null +++ b/infrastructure/Http/Controller.php @@ -0,0 +1,10 @@ + \Infrastructure\Auth\Middleware\AccessTokenChecker::class, + 'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class, + 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class, + 'can' => \Illuminate\Auth\Middleware\Authorize::class, + 'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class, + 'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class, + ]; +} diff --git a/infrastructure/Http/Middleware/EncryptCookies.php b/infrastructure/Http/Middleware/EncryptCookies.php new file mode 100644 index 0000000..80b8da3 --- /dev/null +++ b/infrastructure/Http/Middleware/EncryptCookies.php @@ -0,0 +1,17 @@ +app->make(Router::class); + + $router->pattern('id', '[0-9]+'); + + parent::boot($router); + } +} -- cgit v1.2.3