Skip to content

Commit b027b5e

Browse files
committed
Upgraded the Approov token check server to use Laravel 9.5 in order to be able to run in PHP 8.
Signed-off-by: Exadra37 <exadra37@gmail.com>
1 parent 19d64b2 commit b027b5e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+4126
-2323
lines changed

src/approov-protected-server/token-check/hello/.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ trim_trailing_whitespace = false
1313

1414
[*.{yml,yaml}]
1515
indent_size = 2
16+
17+
[docker-compose.yml]
18+
indent_size = 4
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
APP_NAME=Laravel
22
APP_ENV=local
3-
APP_KEY=your-app-key-here
3+
APP_KEY=
44
APP_DEBUG=true
55
APP_URL=http://localhost
66

77
LOG_CHANNEL=stack
8+
LOG_DEPRECATIONS_CHANNEL=null
9+
LOG_LEVEL=debug
810

911
DB_CONNECTION=mysql
1012
DB_HOST=127.0.0.1
@@ -15,27 +17,31 @@ DB_PASSWORD=
1517

1618
BROADCAST_DRIVER=log
1719
CACHE_DRIVER=file
20+
FILESYSTEM_DISK=local
1821
QUEUE_CONNECTION=sync
1922
SESSION_DRIVER=file
2023
SESSION_LIFETIME=120
2124

25+
MEMCACHED_HOST=127.0.0.1
26+
2227
REDIS_HOST=127.0.0.1
2328
REDIS_PASSWORD=null
2429
REDIS_PORT=6379
2530

2631
MAIL_MAILER=smtp
27-
MAIL_HOST=smtp.mailtrap.io
28-
MAIL_PORT=2525
32+
MAIL_HOST=mailhog
33+
MAIL_PORT=1025
2934
MAIL_USERNAME=null
3035
MAIL_PASSWORD=null
3136
MAIL_ENCRYPTION=null
32-
MAIL_FROM_ADDRESS=null
37+
MAIL_FROM_ADDRESS="hello@example.com"
3338
MAIL_FROM_NAME="${APP_NAME}"
3439

3540
AWS_ACCESS_KEY_ID=
3641
AWS_SECRET_ACCESS_KEY=
3742
AWS_DEFAULT_REGION=us-east-1
3843
AWS_BUCKET=
44+
AWS_USE_PATH_STYLE_ENDPOINT=false
3945

4046
PUSHER_APP_ID=
4147
PUSHER_APP_KEY=
@@ -44,12 +50,3 @@ PUSHER_APP_CLUSTER=mt1
4450

4551
MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
4652
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
47-
48-
LOG_CHANNEL="stderr"
49-
50-
# For production usage the secret is always retrieved with the Approov CLI tool, that can be also used to generate valid
51-
# tokens for testing purposes. Check docs at https://approov.io/docs/v2.1/approov-cli-tool-reference/#token-commands.
52-
#
53-
# But if you don't have the Approov CLI tool, you can still test the backend with Postman or similar, by creating a
54-
# secret with `openssl rand -base64 64 | tr -d '\n'; echo`, and afterwards you can use jwt.io to create the JWT token.
55-
APPROOV_BASE64_SECRET=approov_base64_secret_here
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
* text=auto
2-
*.css linguist-vendored
3-
*.scss linguist-vendored
4-
*.js linguist-vendored
2+
3+
*.blade.php diff=html
4+
*.css diff=css
5+
*.html diff=html
6+
*.md diff=markdown
7+
*.php diff=php
8+
9+
/.github export-ignore
510
CHANGELOG.md export-ignore

src/approov-protected-server/token-check/hello/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ Homestead.json
1010
Homestead.yaml
1111
npm-debug.log
1212
yarn-error.log
13+
/.idea
14+
/.vscode

src/approov-protected-server/token-check/hello/.styleci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
php:
22
preset: laravel
3+
version: 8
34
disabled:
4-
- unused_use
5+
- no_unused_imports
56
finder:
67
not-name:
78
- index.php
8-
- server.php
99
js:
1010
finder:
1111
not-name:

src/approov-protected-server/token-check/hello/README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
<p align="center">
44
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a>
5-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a>
6-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a>
7-
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a>
5+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/dt/laravel/framework" alt="Total Downloads"></a>
6+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/v/laravel/framework" alt="Latest Stable Version"></a>
7+
<a href="https://packagist.org/packages/laravel/framework"><img src="https://img.shields.io/packagist/l/laravel/framework" alt="License"></a>
88
</p>
99

1010
## About Laravel
@@ -25,7 +25,7 @@ Laravel is accessible, powerful, and provides tools required for large, robust a
2525

2626
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework.
2727

28-
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
28+
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 2000 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library.
2929

3030
## Laravel Sponsors
3131

@@ -42,7 +42,10 @@ We would like to extend our thanks to the following sponsors for funding Laravel
4242
- **[Many](https://www.many.co.uk)**
4343
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)**
4444
- **[DevSquad](https://devsquad.com)**
45+
- **[Curotec](https://www.curotec.com/services/technologies/laravel/)**
4546
- **[OP.GG](https://op.gg)**
47+
- **[WebReinvent](https://webreinvent.com/?utm_source=laravel&utm_medium=github&utm_campaign=patreon-sponsors)**
48+
- **[Lendio](https://lendio.com)**
4649

4750
## Contributing
4851

src/approov-protected-server/token-check/hello/app/Console/Kernel.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77

88
class Kernel extends ConsoleKernel
99
{
10-
/**
11-
* The Artisan commands provided by your application.
12-
*
13-
* @var array
14-
*/
15-
protected $commands = [
16-
//
17-
];
18-
1910
/**
2011
* Define the application's command schedule.
2112
*

src/approov-protected-server/token-check/hello/app/Exceptions/Handler.php

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Handler extends ExceptionHandler
1010
/**
1111
* A list of the exception types that are not reported.
1212
*
13-
* @var array
13+
* @var array<int, class-string<Throwable>>
1414
*/
1515
protected $dontReport = [
1616
//
@@ -19,37 +19,23 @@ class Handler extends ExceptionHandler
1919
/**
2020
* A list of the inputs that are never flashed for validation exceptions.
2121
*
22-
* @var array
22+
* @var array<int, string>
2323
*/
2424
protected $dontFlash = [
25+
'current_password',
2526
'password',
2627
'password_confirmation',
2728
];
2829

2930
/**
30-
* Report or log an exception.
31+
* Register the exception handling callbacks for the application.
3132
*
32-
* @param \Throwable $exception
3333
* @return void
34-
*
35-
* @throws \Throwable
36-
*/
37-
public function report(Throwable $exception)
38-
{
39-
parent::report($exception);
40-
}
41-
42-
/**
43-
* Render an exception into an HTTP response.
44-
*
45-
* @param \Illuminate\Http\Request $request
46-
* @param \Throwable $exception
47-
* @return \Symfony\Component\HttpFoundation\Response
48-
*
49-
* @throws \Throwable
5034
*/
51-
public function render($request, Throwable $exception)
35+
public function register()
5236
{
53-
return parent::render($request, $exception);
37+
$this->reportable(function (Throwable $e) {
38+
//
39+
});
5440
}
5541
}

src/approov-protected-server/token-check/hello/app/Http/Kernel.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ class Kernel extends HttpKernel
1111
*
1212
* These middleware are run during every request to your application.
1313
*
14-
* @var array
14+
* @var array<int, class-string|string>
1515
*/
1616
protected $middleware = [
1717
// \App\Http\Middleware\TrustHosts::class,
1818
\App\Http\Middleware\TrustProxies::class,
19-
\Fruitcake\Cors\HandleCors::class,
20-
\App\Http\Middleware\CheckForMaintenanceMode::class,
19+
\Illuminate\Http\Middleware\HandleCors::class,
20+
\App\Http\Middleware\PreventRequestsDuringMaintenance::class,
2121
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
2222
\App\Http\Middleware\TrimStrings::class,
2323
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
@@ -26,7 +26,7 @@ class Kernel extends HttpKernel
2626
/**
2727
* The application's route middleware groups.
2828
*
29-
* @var array
29+
* @var array<string, array<int, class-string|string>>
3030
*/
3131
protected $middlewareGroups = [
3232
'web' => [
@@ -40,8 +40,9 @@ class Kernel extends HttpKernel
4040
],
4141

4242
'api' => [
43+
// \Laravel\Sanctum\Http\Middleware\EnsureFrontendRequestsAreStateful::class,
4344
'approov',
44-
'throttle:60,1',
45+
'throttle:api',
4546
\Illuminate\Routing\Middleware\SubstituteBindings::class,
4647
],
4748
];
@@ -51,13 +52,12 @@ class Kernel extends HttpKernel
5152
*
5253
* These middleware may be assigned to groups or used individually.
5354
*
54-
* @var array
55+
* @var array<string, class-string|string>
5556
*/
5657
protected $routeMiddleware = [
5758
'approov' => \App\Http\Middleware\Approov::class,
5859
'auth' => \App\Http\Middleware\Authenticate::class,
5960
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
60-
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
6161
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
6262
'can' => \Illuminate\Auth\Middleware\Authorize::class,
6363
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,

src/approov-protected-server/token-check/hello/app/Http/Middleware/EncryptCookies.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class EncryptCookies extends Middleware
99
/**
1010
* The names of the cookies that should not be encrypted.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
1515
//

src/approov-protected-server/token-check/hello/app/Http/Middleware/CheckForMaintenanceMode.php renamed to src/approov-protected-server/token-check/hello/app/Http/Middleware/PreventRequestsDuringMaintenance.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace App\Http\Middleware;
44

5-
use Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode as Middleware;
5+
use Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance as Middleware;
66

7-
class CheckForMaintenanceMode extends Middleware
7+
class PreventRequestsDuringMaintenance extends Middleware
88
{
99
/**
1010
* The URIs that should be reachable while maintenance mode is enabled.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
1515
//

src/approov-protected-server/token-check/hello/app/Http/Middleware/RedirectIfAuthenticated.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Providers\RouteServiceProvider;
66
use Closure;
7+
use Illuminate\Http\Request;
78
use Illuminate\Support\Facades\Auth;
89

910
class RedirectIfAuthenticated
@@ -12,14 +13,18 @@ class RedirectIfAuthenticated
1213
* Handle an incoming request.
1314
*
1415
* @param \Illuminate\Http\Request $request
15-
* @param \Closure $next
16-
* @param string|null $guard
17-
* @return mixed
16+
* @param \Closure(\Illuminate\Http\Request): (\Illuminate\Http\Response|\Illuminate\Http\RedirectResponse) $next
17+
* @param string|null ...$guards
18+
* @return \Illuminate\Http\Response|\Illuminate\Http\RedirectResponse
1819
*/
19-
public function handle($request, Closure $next, $guard = null)
20+
public function handle(Request $request, Closure $next, ...$guards)
2021
{
21-
if (Auth::guard($guard)->check()) {
22-
return redirect(RouteServiceProvider::HOME);
22+
$guards = empty($guards) ? [null] : $guards;
23+
24+
foreach ($guards as $guard) {
25+
if (Auth::guard($guard)->check()) {
26+
return redirect(RouteServiceProvider::HOME);
27+
}
2328
}
2429

2530
return $next($request);

src/approov-protected-server/token-check/hello/app/Http/Middleware/TrimStrings.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ class TrimStrings extends Middleware
99
/**
1010
* The names of the attributes that should not be trimmed.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
15+
'current_password',
1516
'password',
1617
'password_confirmation',
1718
];

src/approov-protected-server/token-check/hello/app/Http/Middleware/TrustHosts.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class TrustHosts extends Middleware
99
/**
1010
* Get the host patterns that should be trusted.
1111
*
12-
* @return array
12+
* @return array<int, string|null>
1313
*/
1414
public function hosts()
1515
{

src/approov-protected-server/token-check/hello/app/Http/Middleware/TrustProxies.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace App\Http\Middleware;
44

5-
use Fideloper\Proxy\TrustProxies as Middleware;
5+
use Illuminate\Http\Middleware\TrustProxies as Middleware;
66
use Illuminate\Http\Request;
77

88
class TrustProxies extends Middleware
99
{
1010
/**
1111
* The trusted proxies for this application.
1212
*
13-
* @var array|string|null
13+
* @var array<int, string>|string|null
1414
*/
1515
protected $proxies;
1616

@@ -19,5 +19,10 @@ class TrustProxies extends Middleware
1919
*
2020
* @var int
2121
*/
22-
protected $headers = Request::HEADER_X_FORWARDED_ALL;
22+
protected $headers =
23+
Request::HEADER_X_FORWARDED_FOR |
24+
Request::HEADER_X_FORWARDED_HOST |
25+
Request::HEADER_X_FORWARDED_PORT |
26+
Request::HEADER_X_FORWARDED_PROTO |
27+
Request::HEADER_X_FORWARDED_AWS_ELB;
2328
}

src/approov-protected-server/token-check/hello/app/Http/Middleware/VerifyCsrfToken.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class VerifyCsrfToken extends Middleware
99
/**
1010
* The URIs that should be excluded from CSRF verification.
1111
*
12-
* @var array
12+
* @var array<int, string>
1313
*/
1414
protected $except = [
1515
//

0 commit comments

Comments
 (0)