diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 622e774b..a8c51585 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -29,12 +29,14 @@ class Kernel extends ConsoleKernel } /** - * Register the Closure based commands for the application. + * Register the commands for the application. * * @return void */ protected function commands() { + $this->load(__DIR__.'/Commands'); + require base_path('routes/console.php'); } } diff --git a/app/Exceptions/Handler.php b/app/Exceptions/Handler.php index a747e31b..7e2563a8 100644 --- a/app/Exceptions/Handler.php +++ b/app/Exceptions/Handler.php @@ -3,23 +3,27 @@ namespace App\Exceptions; use Exception; -use Illuminate\Auth\AuthenticationException; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler { /** - * A list of the exception types that should not be reported. + * A list of the exception types that are not reported. * * @var array */ protected $dontReport = [ - \Illuminate\Auth\AuthenticationException::class, - \Illuminate\Auth\Access\AuthorizationException::class, - \Symfony\Component\HttpKernel\Exception\HttpException::class, - \Illuminate\Database\Eloquent\ModelNotFoundException::class, - \Illuminate\Session\TokenMismatchException::class, - \Illuminate\Validation\ValidationException::class, + // + ]; + + /** + * A list of the inputs that are never flashed for validation exceptions. + * + * @var array + */ + protected $dontFlash = [ + 'password', + 'password_confirmation', ]; /** @@ -46,20 +50,4 @@ class Handler extends ExceptionHandler { return parent::render($request, $exception); } - - /** - * Convert an authentication exception into an unauthenticated response. - * - * @param \Illuminate\Http\Request $request - * @param \Illuminate\Auth\AuthenticationException $exception - * @return \Illuminate\Http\Response - */ - protected function unauthenticated($request, AuthenticationException $exception) - { - if ($request->expectsJson()) { - return response()->json(['error' => 'Unauthenticated.'], 401); - } - - return redirect()->guest(route('login')); - } } diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 66d34c3d..93bf68bf 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -18,6 +18,7 @@ class Kernel extends HttpKernel \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \App\Http\Middleware\TrimStrings::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, + \App\Http\Middleware\TrustProxies::class, ]; /** diff --git a/app/Http/Middleware/EncryptCookies.php b/app/Http/Middleware/EncryptCookies.php index 3aa15f8d..033136ad 100644 --- a/app/Http/Middleware/EncryptCookies.php +++ b/app/Http/Middleware/EncryptCookies.php @@ -2,9 +2,9 @@ namespace App\Http\Middleware; -use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter; +use Illuminate\Cookie\Middleware\EncryptCookies as Middleware; -class EncryptCookies extends BaseEncrypter +class EncryptCookies extends Middleware { /** * The names of the cookies that should not be encrypted. diff --git a/app/Http/Middleware/TrimStrings.php b/app/Http/Middleware/TrimStrings.php index 943e9a4d..5a50e7b5 100644 --- a/app/Http/Middleware/TrimStrings.php +++ b/app/Http/Middleware/TrimStrings.php @@ -2,9 +2,9 @@ namespace App\Http\Middleware; -use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer; +use Illuminate\Foundation\Http\Middleware\TrimStrings as Middleware; -class TrimStrings extends BaseTrimmer +class TrimStrings extends Middleware { /** * The names of the attributes that should not be trimmed. diff --git a/app/Http/Middleware/TrustProxies.php b/app/Http/Middleware/TrustProxies.php new file mode 100644 index 00000000..ef1c00d1 --- /dev/null +++ b/app/Http/Middleware/TrustProxies.php @@ -0,0 +1,29 @@ + 'FORWARDED', + Request::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR', + Request::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST', + Request::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT', + Request::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO', + ]; +} diff --git a/app/Http/Middleware/VerifyCsrfToken.php b/app/Http/Middleware/VerifyCsrfToken.php index a2c35414..0c13b854 100644 --- a/app/Http/Middleware/VerifyCsrfToken.php +++ b/app/Http/Middleware/VerifyCsrfToken.php @@ -2,9 +2,9 @@ namespace App\Http\Middleware; -use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier; +use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware; -class VerifyCsrfToken extends BaseVerifier +class VerifyCsrfToken extends Middleware { /** * The URIs that should be excluded from CSRF verification. diff --git a/artisan b/artisan index 44dc07b0..5c23e2e2 100755 --- a/artisan +++ b/artisan @@ -1,6 +1,8 @@ #!/usr/bin/env php =5.6.4", - "laravel/framework": "5.4.*", + "php": ">=7.0.0", + "fideloper/proxy": "~3.3", + "laravel/framework": "5.5.*", "laravel/tinker": "~1.0" }, "require-dev": { + "filp/whoops": "~2.0", "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", - "phpunit/phpunit": "~5.7" + "phpunit/phpunit": "~6.0" }, "autoload": { "classmap": [ @@ -28,20 +30,22 @@ "Tests\\": "tests/" } }, + "extra": { + "laravel": { + "dont-discover": [ + ] + } + }, "scripts": { "post-root-package-install": [ - "php -r \"file_exists('.env') || copy('.env.example', '.env');\"" + "@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" ], "post-create-project-cmd": [ - "php artisan key:generate" + "@php artisan key:generate" ], - "post-install-cmd": [ - "Illuminate\\Foundation\\ComposerScripts::postInstall", - "php artisan optimize" - ], - "post-update-cmd": [ - "Illuminate\\Foundation\\ComposerScripts::postUpdate", - "php artisan optimize" + "post-autoload-dump": [ + "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", + "@php artisan package:discover" ] }, "config": { diff --git a/config/app.php b/config/app.php index a5839259..0e4ebed1 100644 --- a/config/app.php +++ b/config/app.php @@ -167,7 +167,6 @@ return [ /* * Package Service Providers... */ - Laravel\Tinker\TinkerServiceProvider::class, /* * Application Service Providers... diff --git a/config/session.php b/config/session.php index e2779ad8..71ad0ed1 100644 --- a/config/session.php +++ b/config/session.php @@ -122,7 +122,10 @@ return [ | */ - 'cookie' => 'laravel_session', + 'cookie' => env( + 'SESSION_COOKIE', + str_slug(env('APP_NAME', 'laravel'), '_').'_session' + ), /* |-------------------------------------------------------------------------- @@ -176,4 +179,19 @@ return [ 'http_only' => true, + /* + |-------------------------------------------------------------------------- + | Same-Site Cookies + |-------------------------------------------------------------------------- + | + | This option determines how your cookies behave when cross-site requests + | take place, and can be used to mitigate CSRF attacks. By default, we + | do not enable this as other CSRF protection services are in place. + | + | Supported: "lax", "strict" + | + */ + + 'same_site' => null, + ]; diff --git a/database/factories/ModelFactory.php b/database/factories/UserFactory.php similarity index 55% rename from database/factories/ModelFactory.php rename to database/factories/UserFactory.php index 7926c794..061d75a2 100644 --- a/database/factories/ModelFactory.php +++ b/database/factories/UserFactory.php @@ -1,18 +1,19 @@ define(App\User::class, function (Faker\Generator $faker) { +$factory->define(App\User::class, function (Faker $faker) { static $password; return [ diff --git a/package.json b/package.json index 630a2442..dedcbef7 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,21 @@ { - "private": true, - "scripts": { - "dev": "npm run development", - "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", - "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", - "watch-poll": "npm run watch -- --watch-poll", - "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", - "prod": "npm run production", - "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" - }, - "devDependencies": { - "axios": "^0.16.2", - "bootstrap-sass": "^3.3.7", - "cross-env": "^5.0.1", - "jquery": "^3.1.1", - "laravel-mix": "^1.0", - "lodash": "^4.17.4", - "vue": "^2.1.10" - } + "private": true, + "scripts": { + "dev": "npm run development", + "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", + "watch-poll": "npm run watch -- --watch-poll", + "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", + "prod": "npm run production", + "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" + }, + "devDependencies": { + "axios": "^0.16.2", + "bootstrap-sass": "^3.3.7", + "cross-env": "^5.0.1", + "jquery": "^3.1.1", + "laravel-mix": "^1.0", + "lodash": "^4.17.4", + "vue": "^2.1.10" + } } diff --git a/phpunit.xml b/phpunit.xml index 9ecda835..bb9c4a7e 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,7 +1,7 @@ */ +define('LARAVEL_START', microtime(true)); + /* |-------------------------------------------------------------------------- | Register The Auto Loader @@ -19,7 +21,7 @@ | */ -require __DIR__.'/../bootstrap/autoload.php'; +require __DIR__.'/../vendor/autoload.php'; /* |-------------------------------------------------------------------------- diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 486dc271..f31e495c 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -3,9 +3,7 @@ namespace Tests\Feature; use Tests\TestCase; -use Illuminate\Foundation\Testing\WithoutMiddleware; -use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; class ExampleTest extends TestCase { diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 5663bb49..e9fe19c6 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -3,8 +3,7 @@ namespace Tests\Unit; use Tests\TestCase; -use Illuminate\Foundation\Testing\DatabaseMigrations; -use Illuminate\Foundation\Testing\DatabaseTransactions; +use Illuminate\Foundation\Testing\RefreshDatabase; class ExampleTest extends TestCase {