Merge remote-tracking branch 'forked/2.4' into upgrade-google2fa
# Conflicts: # composer.lock
This commit is contained in:
@@ -73,7 +73,8 @@ class ScheduleController extends AbstractApiController
|
||||
Binput::get('status'),
|
||||
Binput::get('scheduled_at'),
|
||||
Binput::get('completed_at'),
|
||||
Binput::get('components', [])
|
||||
Binput::get('components', []),
|
||||
Binput::get('notify', false)
|
||||
));
|
||||
} catch (QueryException $e) {
|
||||
throw new BadRequestHttpException();
|
||||
|
||||
@@ -45,8 +45,7 @@ class MetricController extends Controller
|
||||
public function showAddMetric()
|
||||
{
|
||||
return View::make('dashboard.metrics.add')
|
||||
->withPageTitle(trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard'))
|
||||
->withAcceptableThresholds(Metric::ACCEPTABLE_THRESHOLDS);
|
||||
->withPageTitle(trans('dashboard.metrics.add.title').' - '.trans('dashboard.dashboard'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,8 +131,7 @@ class MetricController extends Controller
|
||||
{
|
||||
return View::make('dashboard.metrics.edit')
|
||||
->withPageTitle(trans('dashboard.metrics.edit.title').' - '.trans('dashboard.dashboard'))
|
||||
->withMetric($metric)
|
||||
->withAcceptableThresholds(Metric::ACCEPTABLE_THRESHOLDS);
|
||||
->withMetric($metric);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@ use AltThree\Validator\ValidationException;
|
||||
use CachetHQ\Cachet\Bus\Commands\Schedule\CreateScheduleCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Schedule\DeleteScheduleCommand;
|
||||
use CachetHQ\Cachet\Bus\Commands\Schedule\UpdateScheduleCommand;
|
||||
use CachetHQ\Cachet\Integrations\Contracts\System;
|
||||
use CachetHQ\Cachet\Models\IncidentTemplate;
|
||||
use CachetHQ\Cachet\Models\Schedule;
|
||||
use GrahamCampbell\Binput\Facades\Binput;
|
||||
@@ -35,13 +36,21 @@ class ScheduleController extends Controller
|
||||
*/
|
||||
protected $subMenu = [];
|
||||
|
||||
/**
|
||||
* The system instance.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Integrations\Contracts\System
|
||||
*/
|
||||
protected $system;
|
||||
|
||||
/**
|
||||
* Creates a new schedule controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
public function __construct(System $system)
|
||||
{
|
||||
$this->system = $system;
|
||||
View::share('subTitle', trans('dashboard.schedule.title'));
|
||||
}
|
||||
|
||||
@@ -70,7 +79,8 @@ class ScheduleController extends Controller
|
||||
|
||||
return View::make('dashboard.maintenance.add')
|
||||
->withPageTitle(trans('dashboard.schedule.add.title').' - '.trans('dashboard.dashboard'))
|
||||
->withIncidentTemplates($incidentTemplates);
|
||||
->withIncidentTemplates($incidentTemplates)
|
||||
->withNotificationsEnabled($this->system->canNotifySubscribers());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -87,7 +97,8 @@ class ScheduleController extends Controller
|
||||
Binput::get('status', Schedule::UPCOMING),
|
||||
Binput::get('scheduled_at'),
|
||||
Binput::get('completed_at'),
|
||||
Binput::get('components', [])
|
||||
Binput::get('components', []),
|
||||
Binput::get('notify', false)
|
||||
));
|
||||
} catch (ValidationException $e) {
|
||||
return cachet_redirect('dashboard.schedule.create')
|
||||
|
||||
@@ -31,7 +31,7 @@ class SubscriberController extends Controller
|
||||
{
|
||||
return View::make('dashboard.subscribers.index')
|
||||
->withPageTitle(trans('dashboard.subscribers.subscribers').' - '.trans('dashboard.dashboard'))
|
||||
->withSubscribers(Subscriber::all());
|
||||
->withSubscribers(Subscriber::with('subscriptions.component')->get());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,9 +15,11 @@ use Barryvdh\Cors\HandleCors;
|
||||
use CachetHQ\Cachet\Http\Middleware\Admin;
|
||||
use CachetHQ\Cachet\Http\Middleware\ApiAuthentication;
|
||||
use CachetHQ\Cachet\Http\Middleware\Authenticate;
|
||||
use CachetHQ\Cachet\Http\Middleware\CacheControl;
|
||||
use CachetHQ\Cachet\Http\Middleware\Localize;
|
||||
use CachetHQ\Cachet\Http\Middleware\ReadyForUse;
|
||||
use CachetHQ\Cachet\Http\Middleware\RedirectIfAuthenticated;
|
||||
use CachetHQ\Cachet\Http\Middleware\RemoteUserAuthenticate;
|
||||
use CachetHQ\Cachet\Http\Middleware\SetupAlreadyCompleted;
|
||||
use CachetHQ\Cachet\Http\Middleware\SubscribersConfigured;
|
||||
use CachetHQ\Cachet\Http\Middleware\Throttler;
|
||||
@@ -44,16 +46,18 @@ class Kernel extends HttpKernel
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'admin' => Admin::class,
|
||||
'can' => Authorize::class,
|
||||
'cors' => HandleCors::class,
|
||||
'auth' => Authenticate::class,
|
||||
'auth.api' => ApiAuthentication::class,
|
||||
'guest' => RedirectIfAuthenticated::class,
|
||||
'localize' => Localize::class,
|
||||
'ready' => ReadyForUse::class,
|
||||
'setup' => SetupAlreadyCompleted::class,
|
||||
'subscribers' => SubscribersConfigured::class,
|
||||
'throttle' => Throttler::class,
|
||||
'admin' => Admin::class,
|
||||
'auth.api' => ApiAuthentication::class,
|
||||
'auth.remoteuser' => RemoteUserAuthenticate::class,
|
||||
'auth' => Authenticate::class,
|
||||
'cache' => CacheControl::class,
|
||||
'can' => Authorize::class,
|
||||
'cors' => HandleCors::class,
|
||||
'guest' => RedirectIfAuthenticated::class,
|
||||
'localize' => Localize::class,
|
||||
'ready' => ReadyForUse::class,
|
||||
'setup' => SetupAlreadyCompleted::class,
|
||||
'subscribers' => SubscribersConfigured::class,
|
||||
'throttle' => Throttler::class,
|
||||
];
|
||||
}
|
||||
|
||||
37
app/Http/Middleware/CacheControl.php
Normal file
37
app/Http/Middleware/CacheControl.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class CacheControl
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
$response = $next($request);
|
||||
|
||||
$maxAge = time() + 30;
|
||||
|
||||
$response->header('Cache-Control', 'public,max-age='.$maxAge);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
53
app/Http/Middleware/RemoteUserAuthenticate.php
Normal file
53
app/Http/Middleware/RemoteUserAuthenticate.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class RemoteUserAuthenticate
|
||||
{
|
||||
/**
|
||||
* Create a new remote user authenticate instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if ($remoteUser = $request->server('REMOTE_USER')) {
|
||||
$user = User::where('email', '=', $remoteUser)->first();
|
||||
|
||||
if ($user instanceof User && $this->auth->guest()) {
|
||||
$this->auth->login($user);
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -52,10 +52,6 @@ class SubscribersConfigured
|
||||
*/
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (!$this->config->get('setting.enable_subscribers')) {
|
||||
return cachet_redirect('status-page');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ namespace CachetHQ\Cachet\Http\Middleware;
|
||||
|
||||
use Fideloper\Proxy\TrustProxies as Middleware;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
* This is the trust proxies middleware class.
|
||||
@@ -42,6 +43,8 @@ class TrustProxies extends Middleware
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->proxies = empty(env('TRUSTED_PROXIES')) ? '*' : explode(',', trim(env('TRUSTED_PROXIES')));
|
||||
$proxies = Config::get('trustedproxies.proxies');
|
||||
|
||||
$this->proxies = empty($proxies) ? '*' : explode(',', trim($proxies));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class ApiSystemRoutes
|
||||
$router->group(['middleware' => ['auth.api']], function (Registrar $router) {
|
||||
$router->get('ping', 'GeneralController@ping');
|
||||
$router->get('version', 'GeneralController@version');
|
||||
$router->get('status', 'GeneralController@status');
|
||||
$router->get('status', ['uses' => 'GeneralController@status', 'middleware' => ['cache']]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user