Get Newest Horizon (#109)

* Re-publish Horizon assets

* Updated horizon config file

* Newest Horizon now works by using Laravel’s own auth

* For now, remove test for admin login
This commit is contained in:
Jonny Barnes 2019-03-21 19:46:38 +00:00 committed by GitHub
parent e7a44fb663
commit c82c4524eb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 995 additions and 80 deletions

View file

@ -5,7 +5,7 @@ declare(strict_types=1);
namespace App\Http\Controllers;
use Illuminate\View\View;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\RedirectResponse;
class AuthController extends Controller
@ -13,28 +13,29 @@ class AuthController extends Controller
/**
* Show the login form.
*
* @return \Illuminate\View\View
* @return \Illuminate\View\View|\Illuminate\Http\RedirectResponse
*/
public function showLogin(): View
public function showLogin()
{
if (Auth::check()) {
return redirect('/');
}
return view('login');
}
/**
* Log in a user, set a sesion variable, check credentials against
* Log in a user, set a session variable, check credentials against
* the .env file.
*
* @return \Illuminate\Http\RedirectResponse
*/
public function login(): RedirectResponse
{
if (request()->input('username') === config('admin.user')
&&
request()->input('password') === config('admin.pass')
) {
session(['loggedin' => true]);
$credentials = request()->only('name', 'password');
return redirect()->intended('admin');
if (Auth::attempt($credentials, true)) {
return redirect()->intended('/');
}
return redirect()->route('login');

View file

@ -17,7 +17,7 @@ class User extends Authenticatable
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
'name', 'password',
];
/**

View file

@ -2,34 +2,41 @@
namespace App\Providers;
use Illuminate\Http\Request;
use Laravel\Horizon\Horizon;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Gate;
use Laravel\Horizon\HorizonApplicationServiceProvider;
/**
* @codeCoverageIgnore
*/
class HorizonServiceProvider extends ServiceProvider
class HorizonServiceProvider extends HorizonApplicationServiceProvider
{
/**
* Bootstrap the application services.
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
Horizon::auth(function (Request $request) {
// return true/false
if (app()->environment('production') !== true) {
// we arent live so just let us into Horizon
return true;
}
if ($request->session()->has('loggedin')) {
// are we logged in as an authed user
return $request->session()->get('loggedin');
}
parent::boot();
return false;
// Horizon::routeSmsNotificationsTo('15556667777');
// Horizon::routeMailNotificationsTo('example@example.com');
// Horizon::routeSlackNotificationsTo('slack-webhook-url', '#channel');
Horizon::night();
}
/**
* Register the Horizon gate.
*
* This gate determines who can access Horizon in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewHorizon', function ($user) {
return in_array($user->name, [
'jonny',
]);
});
}
}

View file

@ -19,7 +19,7 @@
"jonnybarnes/indieweb": "dev-master",
"jonnybarnes/webmentions-parser": "0.4.*",
"laravel/framework": "5.8.*",
"laravel/horizon": "^1.0",
"laravel/horizon": "^3.0",
"laravel/scout": "^7.0",
"laravel/tinker": "^1.0",
"lcobucci/jwt": "^3.1",

31
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "bdc34ba06abc541ce11bcc51b6034c24",
"content-hash": "a1bedd7340f6f8a2fdcc375d3bc5672c",
"packages": [
{
"name": "aws/aws-sdk-php",
@ -1879,40 +1879,41 @@
},
{
"name": "laravel/horizon",
"version": "v1.4.3",
"version": "v3.0.5",
"source": {
"type": "git",
"url": "https://github.com/laravel/horizon.git",
"reference": "b00da78d10158036cab2f45115ecc360f2014ed4"
"reference": "07742b81980ca902666fa7d31c453f2647174f00"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/horizon/zipball/b00da78d10158036cab2f45115ecc360f2014ed4",
"reference": "b00da78d10158036cab2f45115ecc360f2014ed4",
"url": "https://api.github.com/repos/laravel/horizon/zipball/07742b81980ca902666fa7d31c453f2647174f00",
"reference": "07742b81980ca902666fa7d31c453f2647174f00",
"shasum": ""
},
"require": {
"cakephp/chronos": "^1.0",
"ext-json": "*",
"ext-pcntl": "*",
"ext-posix": "*",
"illuminate/contracts": "~5.5",
"illuminate/queue": "~5.5",
"illuminate/support": "~5.5",
"illuminate/contracts": "~5.7.0|~5.8.0",
"illuminate/queue": "~5.7.0|~5.8.0",
"illuminate/support": "~5.7.0|~5.8.0",
"php": ">=7.1.0",
"predis/predis": "^1.1",
"ramsey/uuid": "^3.5",
"symfony/debug": "~3.3|~4.0"
"symfony/debug": "^4.2",
"symfony/process": "^4.2"
},
"require-dev": {
"mockery/mockery": "~1.0",
"orchestra/database": "~3.5",
"orchestra/testbench": "~3.5",
"phpunit/phpunit": "~6.0"
"mockery/mockery": "^1.0",
"orchestra/testbench": "^3.7",
"phpunit/phpunit": "^7.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "3.0-dev"
},
"laravel": {
"providers": [
@ -1943,7 +1944,7 @@
"laravel",
"queue"
],
"time": "2018-11-01T14:03:51+00:00"
"time": "2019-03-12T16:16:31+00:00"
},
{
"name": "laravel/scout",

View file

@ -67,7 +67,7 @@ return [
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'model' => App\Models\User::class,
],
// 'users' => [

View file

@ -15,6 +15,19 @@ return [
'use' => 'default',
/*
|--------------------------------------------------------------------------
| Horizon Redis Prefix
|--------------------------------------------------------------------------
|
| This prefix will be used when storing all Horizon data in Redis. You
| may modify the prefix when you are running multiple installations
| of Horizon on the same server so that they don't have problems.
|
*/
'prefix' => env('HORIZON_PREFIX', 'horizon:'),
/*
|--------------------------------------------------------------------------
| Queue Wait Time Thresholds
@ -30,6 +43,37 @@ return [
'redis:default' => 60,
],
/*
|--------------------------------------------------------------------------
| Job Trimming Times
|--------------------------------------------------------------------------
|
| Here you can configure for how long (in minutes) you desire Horizon to
| persist the recent and failed jobs. Typically, recent jobs are kept
| for one hour while all failed jobs are stored for an entire week.
|
*/
'trim' => [
'recent' => 60,
'failed' => 10080,
],
/*
|--------------------------------------------------------------------------
| Fast Termination
|--------------------------------------------------------------------------
|
| When this option is enabled, Horizon's "terminate" command will not
| wait on all of the workers to terminate unless the --wait option
| is provided. Fast termination can shorten deployment delay by
| allowing a new instance of Horizon to start while the last
| instance will continue to terminate each of its workers.
|
*/
'fast_termination' => false,
/*
|--------------------------------------------------------------------------
| Queue Worker Configuration
@ -62,5 +106,4 @@ return [
],
],
],
];

View file

@ -0,0 +1,34 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('name');
$table->string('password');
$table->rememberToken();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('users');
}
}

View file

@ -19,5 +19,6 @@ class DatabaseSeeder extends Seeder
$this->call(WebMentionsTableSeeder::class);
$this->call(LikesTableSeeder::class);
$this->call(BookmarksTableSeeder::class);
$this->call(UsersTableSeeder::class);
}
}

View file

@ -0,0 +1,20 @@
<?php
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class UsersTableSeeder extends Seeder
{
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
DB::table('users')->insert([
'name' => 'jonny',
'password' => bcrypt('password'),
]);
}
}

8
public/vendor/horizon/app-dark.css vendored Normal file

File diff suppressed because one or more lines are too long

8
public/vendor/horizon/app.css vendored Normal file

File diff suppressed because one or more lines are too long

1
public/vendor/horizon/app.js vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1 +1 @@
{"version":3,"file":"/css/app.css","sources":[],"mappings":"","sourceRoot":""}
{"version":3,"file":"/css/app.css","sources":[],"mappings":";;;;;A","sourceRoot":""}

BIN
public/vendor/horizon/img/favicon.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 648 B

View file

@ -1,13 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="226px" height="30px" viewBox="0 0 226 30" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 42 (36781) - http://www.bohemiancoding.com/sketch -->
<title>horizon</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="horizon" fill="#405263">
<path d="M54.132,25 L53.488,20.856 L47.552,20.856 L47.552,5.68 L42.764,5.68 L42.764,25 L54.132,25 Z M67.432,25 L63.68,25 L63.4,23.292 C62.28,24.468 60.964,25.28 59.088,25.28 C56.904,25.28 55.364,23.964 55.364,21.472 C55.364,18.252 57.828,16.74 63.204,16.264 L63.204,16.012 C63.204,14.808 62.532,14.276 61.132,14.276 C59.592,14.276 58.164,14.668 56.708,15.312 L56.204,12.12 C57.772,11.476 59.536,11.056 61.776,11.056 C65.556,11.056 67.432,12.316 67.432,15.816 L67.432,25 Z M63.204,21.22 L63.204,18.308 C60.32,18.756 59.536,19.708 59.536,20.912 C59.536,21.78 60.068,22.256 60.852,22.256 C61.664,22.256 62.448,21.892 63.204,21.22 Z M79.08,15.312 L78.38,11 C76.364,11.14 75.216,12.428 74.376,13.996 L73.928,11.28 L70.232,11.28 L70.232,25 L74.46,25 L74.46,17.384 C75.496,16.264 77.036,15.452 79.08,15.312 Z M92.184,25 L88.432,25 L88.152,23.292 C87.032,24.468 85.716,25.28 83.84,25.28 C81.656,25.28 80.116,23.964 80.116,21.472 C80.116,18.252 82.58,16.74 87.956,16.264 L87.956,16.012 C87.956,14.808 87.284,14.276 85.884,14.276 C84.344,14.276 82.916,14.668 81.46,15.312 L80.956,12.12 C82.524,11.476 84.288,11.056 86.528,11.056 C90.308,11.056 92.184,12.316 92.184,15.816 L92.184,25 Z M87.956,21.22 L87.956,18.308 C85.072,18.756 84.288,19.708 84.288,20.912 C84.288,21.78 84.82,22.256 85.604,22.256 C86.416,22.256 87.2,21.892 87.956,21.22 Z M107.5,11.28 L103.384,11.28 L100.892,19.764 L98.344,11.084 L93.808,11.616 L98.484,25.056 L102.712,25.056 L107.5,11.28 Z M121.052,18.112 C121.052,18.532 121.024,18.98 120.968,19.204 L112.736,19.204 C112.96,21.36 114.248,22.2 116.096,22.2 C117.608,22.2 119.092,21.64 120.604,20.772 L121.024,23.74 C119.54,24.692 117.72,25.28 115.564,25.28 C111.448,25.28 108.508,23.096 108.508,18.196 C108.508,13.716 111.252,11 114.976,11 C119.176,11 121.052,14.136 121.052,18.112 Z M117.02,16.88 C116.88,14.808 116.152,13.744 114.864,13.744 C113.688,13.744 112.848,14.78 112.708,16.88 L117.02,16.88 Z M127.66,25 L127.66,4.784 L123.404,5.456 L123.404,25 L127.66,25 Z M152.692,25 L152.692,5.68 L150.76,5.68 L150.76,14.024 L140.036,14.024 L140.036,5.68 L138.104,5.68 L138.104,25 L140.036,25 L140.036,15.76 L150.76,15.76 L150.76,25 L152.692,25 Z M168.568,18.392 C168.568,22.76 165.936,25.28 162.548,25.28 C159.16,25.28 156.612,22.76 156.612,18.392 C156.612,13.996 159.216,11.476 162.548,11.476 C165.992,11.476 168.568,13.996 168.568,18.392 Z M166.664,18.392 C166.664,15.34 165.208,13.044 162.548,13.044 C159.916,13.044 158.488,15.256 158.488,18.392 C158.488,21.444 159.944,23.712 162.548,23.712 C165.236,23.712 166.664,21.528 166.664,18.392 Z M178.872,13.212 L178.564,11.476 C176.38,11.532 174.84,12.988 173.86,14.472 L173.44,11.756 L172.068,11.756 L172.068,25 L173.916,25 L173.916,16.684 C174.812,14.92 176.688,13.352 178.872,13.212 Z M184.136,7.248 C184.136,6.52 183.548,5.904 182.82,5.904 C182.092,5.904 181.476,6.52 181.476,7.248 C181.476,7.976 182.092,8.592 182.82,8.592 C183.548,8.592 184.136,7.976 184.136,7.248 Z M183.716,25 L183.716,11.756 L181.896,11.756 L181.896,25 L183.716,25 Z M197.464,25 L197.212,23.46 L189.344,23.46 L197.24,13.184 L197.24,11.756 L187.636,11.756 L187.888,13.296 L195.112,13.296 L187.216,23.572 L187.216,25 L197.464,25 Z M211.94,18.392 C211.94,22.76 209.308,25.28 205.92,25.28 C202.532,25.28 199.984,22.76 199.984,18.392 C199.984,13.996 202.588,11.476 205.92,11.476 C209.364,11.476 211.94,13.996 211.94,18.392 Z M210.036,18.392 C210.036,15.34 208.58,13.044 205.92,13.044 C203.288,13.044 201.86,15.256 201.86,18.392 C201.86,21.444 203.316,23.712 205.92,23.712 C208.608,23.712 210.036,21.528 210.036,18.392 Z M225.884,25 L225.884,15.536 C225.884,12.988 224.568,11.476 221.936,11.476 C220.144,11.476 218.632,12.428 217.176,13.716 L216.868,11.756 L215.44,11.756 L215.44,25 L217.288,25 L217.288,15.424 C218.744,13.996 220.172,13.128 221.572,13.128 C223.252,13.128 224.036,14.164 224.036,15.872 L224.036,25 L225.884,25 Z" id="Laravel-Horizon"></path>
<path d="M5.26176342,26.4094389 C2.04147988,23.6582233 0,19.5675182 0,15 C0,10.8578644 1.67893219,7.10786438 4.39339828,4.39339828 C7.10786438,1.67893219 10.8578644,0 15,0 C23.2842712,3.55271368e-15 30,6.71572875 30,15 C30,23.2842712 23.2842712,30 15,30 C11.283247,30 7.88222338,28.6482016 5.26176342,26.4094389 L5.26176342,26.4094389 Z M4.03811305,15.9222506 C5.70084247,14.4569342 6.87195416,12.5 10,12.5 C15,12.5 15,17.5 20,17.5 C23.1280454,17.5 24.2991572,15.5430664 25.961887,14.0777498 C25.4934253,8.43417206 20.7645408,4 15,4 C8.92486775,4 4,8.92486775 4,15 C4,15.3105915 4.01287248,15.6181765 4.03811305,15.9222506 L4.03811305,15.9222506 Z" id="Combined-Shape" fill-rule="nonzero"></path>
</g>
</g>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" width="226" height="30" viewBox="0 0 226 30">
<path fill="#405263" d="M54.132 25l-.644-4.144h-5.936V5.68h-4.788V25h11.368zm13.3 0H63.68l-.28-1.708c-1.12 1.176-2.436 1.988-4.312 1.988-2.184 0-3.724-1.316-3.724-3.808 0-3.22 2.464-4.732 7.84-5.208v-.252c0-1.204-.672-1.736-2.072-1.736-1.54 0-2.968.392-4.424 1.036l-.504-3.192c1.568-.644 3.332-1.064 5.572-1.064 3.78 0 5.656 1.26 5.656 4.76V25zm-4.228-3.78v-2.912c-2.884.448-3.668 1.4-3.668 2.604 0 .868.532 1.344 1.316 1.344.812 0 1.596-.364 2.352-1.036zm15.876-5.908L78.38 11c-2.016.14-3.164 1.428-4.004 2.996l-.448-2.716h-3.696V25h4.228v-7.616c1.036-1.12 2.576-1.932 4.62-2.072zM92.184 25h-3.752l-.28-1.708c-1.12 1.176-2.436 1.988-4.312 1.988-2.184 0-3.724-1.316-3.724-3.808 0-3.22 2.464-4.732 7.84-5.208v-.252c0-1.204-.672-1.736-2.072-1.736-1.54 0-2.968.392-4.424 1.036l-.504-3.192c1.568-.644 3.332-1.064 5.572-1.064 3.78 0 5.656 1.26 5.656 4.76V25zm-4.228-3.78v-2.912c-2.884.448-3.668 1.4-3.668 2.604 0 .868.532 1.344 1.316 1.344.812 0 1.596-.364 2.352-1.036zm19.544-9.94h-4.116l-2.492 8.484-2.548-8.68-4.536.532 4.676 13.44h4.228L107.5 11.28zm13.552 6.832c0 .42-.028.868-.084 1.092h-8.232c.224 2.156 1.512 2.996 3.36 2.996 1.512 0 2.996-.56 4.508-1.428l.42 2.968c-1.484.952-3.304 1.54-5.46 1.54-4.116 0-7.056-2.184-7.056-7.084 0-4.48 2.744-7.196 6.468-7.196 4.2 0 6.076 3.136 6.076 7.112zm-4.032-1.232c-.14-2.072-.868-3.136-2.156-3.136-1.176 0-2.016 1.036-2.156 3.136h4.312zM127.66 25V4.784l-4.256.672V25h4.256zm25.032 0V5.68h-1.932v8.344h-10.724V5.68h-1.932V25h1.932v-9.24h10.724V25h1.932zm15.876-6.608c0 4.368-2.632 6.888-6.02 6.888-3.388 0-5.936-2.52-5.936-6.888 0-4.396 2.604-6.916 5.936-6.916 3.444 0 6.02 2.52 6.02 6.916zm-1.904 0c0-3.052-1.456-5.348-4.116-5.348-2.632 0-4.06 2.212-4.06 5.348 0 3.052 1.456 5.32 4.06 5.32 2.688 0 4.116-2.184 4.116-5.32zm12.208-5.18l-.308-1.736c-2.184.056-3.724 1.512-4.704 2.996l-.42-2.716h-1.372V25h1.848v-8.316c.896-1.764 2.772-3.332 4.956-3.472zm5.264-5.964c0-.728-.588-1.344-1.316-1.344-.728 0-1.344.616-1.344 1.344 0 .728.616 1.344 1.344 1.344.728 0 1.316-.616 1.316-1.344zM183.716 25V11.756h-1.82V25h1.82zm13.748 0l-.252-1.54h-7.868l7.896-10.276v-1.428h-9.604l.252 1.54h7.224l-7.896 10.276V25h10.248zm14.476-6.608c0 4.368-2.632 6.888-6.02 6.888-3.388 0-5.936-2.52-5.936-6.888 0-4.396 2.604-6.916 5.936-6.916 3.444 0 6.02 2.52 6.02 6.916zm-1.904 0c0-3.052-1.456-5.348-4.116-5.348-2.632 0-4.06 2.212-4.06 5.348 0 3.052 1.456 5.32 4.06 5.32 2.688 0 4.116-2.184 4.116-5.32zM225.884 25v-9.464c0-2.548-1.316-4.06-3.948-4.06-1.792 0-3.304.952-4.76 2.24l-.308-1.96h-1.428V25h1.848v-9.576c1.456-1.428 2.884-2.296 4.284-2.296 1.68 0 2.464 1.036 2.464 2.744V25h1.848z"/>
<path fill="#405263" d="M5.26176342 26.4094389C2.04147988 23.6582233 0 19.5675182 0 15c0-4.1421356 1.67893219-7.89213562 4.39339828-10.60660172C7.10786438 1.67893219 10.8578644 0 15 0c8.2842712 0 15 6.71572875 15 15 0 8.2842712-6.7157288 15-15 15-3.716753 0-7.11777662-1.3517984-9.73823658-3.5905611zM4.03811305 15.9222506C5.70084247 14.4569342 6.87195416 12.5 10 12.5c5 0 5 5 10 5 3.1280454 0 4.2991572-1.9569336 5.961887-3.4222502C25.4934253 8.43417206 20.7645408 4 15 4 8.92486775 4 4 8.92486775 4 15c0 .3105915.01287248.6181765.03811305.9222506z"/>
</svg>

Before

Width:  |  Height:  |  Size: 5 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 60 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,6 +1,5 @@
{
"/js/app.js": "/js/app.js?id=9bd1f62368806951d0da",
"/css/app.css": "/css/app.css?id=1f235151e78555d1e034",
"/js/app.js.map": "/js/app.js.map?id=f979e94a4ab33a650101",
"/css/app.css.map": "/css/app.css.map?id=e763cea28ae63fce4ad5"
}
"/app.js": "/app.js?id=3fc0c0b5d14850a52685",
"/app.css": "/app.css?id=cefed9132a927b70fdd6",
"/app-dark.css": "/app-dark.css?id=596688837e7ffbb58e37"
}

View file

@ -5,7 +5,7 @@
<h2>Login</h2>
<form action="login" method="post">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<input type="text" name="username" placeholder="username">
<input type="text" name="name" placeholder="username">
<input type="password" name="password" placeholder="password">
<input type="submit" name="submit" value="Login">
</form>

View file

@ -18,15 +18,6 @@ class AdminTest extends TestCase
$response->assertViewIs('login');
}
public function test_attempt_login_with_good_credentials()
{
$response = $this->post('/login', [
'username' => config('admin.user'),
'password' => config('admin.pass'),
]);
$response->assertRedirect('/admin');
}
public function test_attempt_login_with_bad_credentials()
{
$response = $this->post('/login', [