2FAuth/app/Http/Controllers/SystemController.php

64 lines
2.1 KiB
PHP
Raw Normal View History

2022-07-21 15:48:23 +02:00
<?php
namespace App\Http\Controllers;
2022-07-30 17:51:02 +02:00
use App\Facades\Settings;
2022-11-22 15:15:52 +01:00
use App\Services\ReleaseRadarService;
2022-07-21 15:48:23 +02:00
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class SystemController extends Controller
{
/**
* Get detailed information about the current installation
2022-11-22 15:15:52 +01:00
*
2022-07-21 15:48:23 +02:00
* @return \Illuminate\Http\JsonResponse
*/
public function infos(Request $request)
{
2022-11-22 15:15:52 +01:00
$infos = [];
$infos['Date'] = date(DATE_RFC2822);
$infos['userAgent'] = $request->header('user-agent');
2022-07-21 15:48:23 +02:00
// App info
2022-11-22 15:15:52 +01:00
$infos['Version'] = config('2fauth.version');
$infos['Environment'] = config('app.env');
$infos['Debug'] = var_export(config('app.debug'), true);
$infos['Cache driver'] = config('cache.default');
$infos['Log channel'] = config('logging.default');
$infos['Log level'] = env('LOG_LEVEL');
$infos['DB driver'] = DB::getDriverName();
2022-07-21 15:48:23 +02:00
// PHP info
2022-11-22 15:15:52 +01:00
$infos['PHP version'] = PHP_VERSION;
$infos['Operating system'] = PHP_OS;
$infos['interface'] = PHP_SAPI;
2022-07-21 15:48:23 +02:00
// Auth info
if ($request->user()) {
2022-11-22 15:15:52 +01:00
$infos['Auth guard'] = config('auth.defaults.guard');
if ($infos['Auth guard'] === 'reverse-proxy-guard') {
2022-11-22 15:15:52 +01:00
$infos['Auth proxy header for user'] = config('auth.auth_proxy_headers.user');
$infos['Auth proxy header for email'] = config('auth.auth_proxy_headers.email');
}
$infos['webauthn user verification'] = config('larapass.login_verify');
2022-11-22 15:15:52 +01:00
$infos['Trusted proxies'] = config('2fauth.trustedProxies') ?: 'none';
2022-07-21 15:48:23 +02:00
}
// User info
if ($request->user()) {
$infos['options'] = Settings::all()->toArray();
2022-07-21 15:48:23 +02:00
}
return response()->json($infos);
}
2022-09-21 21:50:41 +02:00
/**
* Get latest release
2022-11-22 15:15:52 +01:00
*
2022-09-21 21:50:41 +02:00
* @return \Illuminate\Http\JsonResponse
*/
public function latestRelease(Request $request, ReleaseRadarService $releaseRadar)
2022-09-21 21:50:41 +02:00
{
$release = $releaseRadar->manualScan();
2022-09-21 21:50:41 +02:00
return response()->json(['newRelease' => $release]);
2022-09-21 21:50:41 +02:00
}
}