Skip to content

Commit

Permalink
Various config updates
Browse files Browse the repository at this point in the history
* Updates default .env template
* Drops redis facade from config/app.php
* Sets same-site cookies to be 'lax' and updates CORS paths
* Adds 'ably' as a supported broadcaster (whatever ably is...)
* Adds an `unverified` factory state, although it may not stay
* Updates `RedirectIfAuthenticated` to support multiple guards
* Adds `uuid` field to `failed_jobs` table for batching support
* Prevents `current_password` from being flashed in exception handler
* Removes unused `report()` and `render()` exception handler methods
* Removes unused `bindings` alias from `Http\Kernel::$routeMiddleware`
* Removes unused `filesystems.cloud` config option
* Enables overriding of log level with `LOG_LEVEL` environment variable
* Adds `auth.password` and `validation.multiple_of` to lang files
  • Loading branch information
dshoreman committed Feb 27, 2021
1 parent b7ffec5 commit 3cc4031
Show file tree
Hide file tree
Showing 19 changed files with 56 additions and 66 deletions.
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ APP_REGISTRATION=false
DB_PASSWORD=vagrant

LOG_CHANNEL=stack
LOG_LEVEL=debug

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PASSPORT_CLIENT_ID=
PASSPORT_CLIENT_SECRET=
25 changes: 1 addition & 24 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
namespace Servidor\Exceptions;

use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Symfony\Component\HttpFoundation\Response;
use Throwable;

class Handler extends ExceptionHandler
{
Expand All @@ -22,29 +20,8 @@ class Handler extends ExceptionHandler
* @var string[]
*/
protected $dontFlash = [
'current_password',
'password',
'password_confirmation',
];

/**
* Report or log an exception.
*
* @throws Throwable
*/
public function report(Throwable $exception): void
{
parent::report($exception);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
*
* @throws Throwable
*/
public function render($request, Throwable $e): Response
{
return parent::render($request, $e);
}
}
1 change: 0 additions & 1 deletion app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class Kernel extends HttpKernel
protected $routeMiddleware = [
'auth' => \Servidor\Http\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \Servidor\Http\Middleware\RedirectIfAuthenticated::class,
Expand Down
16 changes: 9 additions & 7 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,25 @@
namespace Servidor\Http\Middleware;

use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Servidor\Providers\RouteServiceProvider;

class RedirectIfAuthenticated
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string|null $guard
* Redirect authed users to home for guest-only routes.
*
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
public function handle(Request $request, Closure $next, ?string ...$guards)
{
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
$guards = empty($guards) ? [null] : $guards;

foreach ($guards as $guard) {
if (Auth::guard($guard)->check()) {
return redirect(RouteServiceProvider::HOME);
}
}

return $next($request);
Expand Down
1 change: 0 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
'Password' => Illuminate\Support\Facades\Password::class,
'Queue' => Illuminate\Support\Facades\Queue::class,
'Redirect' => Illuminate\Support\Facades\Redirect::class,
'Redis' => Illuminate\Support\Facades\Redis::class,
'Request' => Illuminate\Support\Facades\Request::class,
'Response' => Illuminate\Support\Facades\Response::class,
'Route' => Illuminate\Support\Facades\Route::class,
Expand Down
7 changes: 6 additions & 1 deletion config/broadcasting.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
| framework when an event needs to be broadcast. You may set this to
| any of the connections defined in the "connections" array below.
|
| Supported: "pusher", "redis", "log", "null"
| Supported: "pusher", "ably", "redis", "log", "null"
|
*/

Expand Down Expand Up @@ -39,6 +39,11 @@
],
],

'ably' => [
'driver' => 'ably',
'key' => env('ABLY_KEY'),
],

'redis' => [
'driver' => 'redis',
'connection' => 'default',
Expand Down
8 changes: 5 additions & 3 deletions config/cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
| using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function.
|
| Supported: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb"
|
*/

'default' => env('CACHE_DRIVER', 'file'),
Expand All @@ -28,6 +25,9 @@
| well as their drivers. You may even define multiple stores for the
| same cache driver to group types of items stored in your caches.
|
| Supported drivers: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb", "null"
|
*/

'stores' => [
Expand All @@ -44,6 +44,7 @@
'driver' => 'database',
'table' => 'cache',
'connection' => null,
'lock_connection' => null,
],

'file' => [
Expand Down Expand Up @@ -73,6 +74,7 @@
'redis' => [
'driver' => 'redis',
'connection' => 'cache',
'lock_connection' => 'default',
],

'dynamodb' => [
Expand Down
2 changes: 1 addition & 1 deletion config/cors.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
|
*/

'paths' => ['api/*'],
'paths' => ['api/*', 'sanctum/csrf-cookie'],

'allowed_methods' => ['*'],

Expand Down
12 changes: 0 additions & 12 deletions config/filesystems.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,6 @@
*/
'default' => env('FILESYSTEM_DRIVER', 'local'),

/*
|--------------------------------------------------------------------------
| Default Cloud Filesystem Disk
|--------------------------------------------------------------------------
|
| Many applications store files both locally and in the cloud. For this
| reason, you may specify a default "cloud" driver here. This driver
| will be bound as the Cloud disk implementation in the container.
|
*/
'cloud' => env('FILESYSTEM_CLOUD', 's3'),

/*
|--------------------------------------------------------------------------
| Filesystem Disks
Expand Down
12 changes: 6 additions & 6 deletions config/logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
'single' => [
'driver' => 'single',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],

'daily' => [
'driver' => 'daily',
'path' => storage_path('logs/laravel.log'),
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
'days' => 14,
],

Expand All @@ -58,12 +58,12 @@
'url' => env('LOG_SLACK_WEBHOOK_URL'),
'username' => 'Laravel Log',
'emoji' => ':boom:',
'level' => 'critical',
'level' => env('LOG_LEVEL', 'critical'),
],

'papertrail' => [
'driver' => 'monolog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
'handler' => SyslogUdpHandler::class,
'handler_with' => [
'host' => env('PAPERTRAIL_URL'),
Expand All @@ -82,12 +82,12 @@

'syslog' => [
'driver' => 'syslog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],

'errorlog' => [
'driver' => 'errorlog',
'level' => 'debug',
'level' => env('LOG_LEVEL', 'debug'),
],

'null' => [
Expand Down
2 changes: 1 addition & 1 deletion config/queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
*/

'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'),
'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs',
],
Expand Down
2 changes: 1 addition & 1 deletion config/session.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,5 @@
|
*/

'same_site' => null, // change to 'lax'? investigate!
'same_site' => 'lax',
];
12 changes: 12 additions & 0 deletions database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,16 @@ public function definition(): array
'remember_token' => Str::random(10),
];
}

/**
* Indicate that the model's email address should be unverified.
*/
public function unverified(): Factory
{
return $this->state(function () {
return [
'email_verified_at' => null,
];
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public function up(): void
{
Schema::create('failed_jobs', function (Blueprint $table): void {
$table->id();
$table->string('uuid')->unique();
$table->text('connection');
$table->text('queue');
$table->longText('payload');
Expand Down
13 changes: 7 additions & 6 deletions public/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?php

use Illuminate\Contracts\Http\Kernel;
use Illuminate\Http\Request;

define('LARAVEL_START', microtime(true));

$maintenanceCache = __DIR__ . '/../storage/framework/maintenance.php';
Expand All @@ -11,12 +14,10 @@

$app = require_once __DIR__ . '/../bootstrap/app.php';

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
$request = Illuminate\Http\Request::capture()
);
$kernel = $app->make(Kernel::class);

$response->send();
$response = tap($kernel->handle(
$request = Request::capture()
))->send();

$kernel->terminate($request, $response);
2 changes: 1 addition & 1 deletion public/web.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
Rewrites requires Microsoft URL Rewrite Module for IIS
Download: https://www.microsoft.com/en-us/download/details.aspx?id=47337
Download: https://www.iis.net/downloads/microsoft/url-rewrite
Debug Help: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules
-->
<configuration>
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
*/

'failed' => 'These credentials do not match our records.',
'password' => 'The provided password is incorrect.',
'throttle' => 'Too many login attempts. Please try again in :seconds seconds.',
];
1 change: 1 addition & 0 deletions resources/lang/en/validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
'string' => 'The :attribute must be at least :min characters.',
'array' => 'The :attribute must have at least :min items.',
],
'multiple_of' => 'The :attribute must be a multiple of :value.',
'not_in' => 'The selected :attribute is invalid.',
'not_regex' => 'The :attribute format is invalid.',
'numeric' => 'The :attribute must be a number.',
Expand Down
2 changes: 1 addition & 1 deletion routes/console.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

Artisan::command('inspire', function (): void {
$this->comment(Inspiring::quote());
})->describe('Display an inspiring quote');
})->purpose('Display an inspiring quote');

0 comments on commit 3cc4031

Please sign in to comment.