SystemController.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace App\Http\Controllers;
  3. use App\Facades\Settings;
  4. use App\Services\ReleaseRadarService;
  5. use Illuminate\Http\Request;
  6. use Illuminate\Support\Carbon;
  7. use Illuminate\Support\Facades\DB;
  8. class SystemController extends Controller
  9. {
  10. /**
  11. * Get detailed information about the current installation
  12. *
  13. * @return \Illuminate\Http\JsonResponse
  14. */
  15. public function infos(Request $request)
  16. {
  17. $infos = [];
  18. $infos['common']['Date'] = date(DATE_RFC2822);
  19. $infos['common']['userAgent'] = $request->header('user-agent');
  20. // App info
  21. $infos['common']['Version'] = config('2fauth.version');
  22. $infos['common']['Environment'] = config('app.env');
  23. $infos['common']['Install path'] = '/' . config('2fauth.config.appSubdirectory');
  24. $infos['common']['Debug'] = var_export(config('app.debug'), true);
  25. $infos['common']['Cache driver'] = config('cache.default');
  26. $infos['common']['Log channel'] = config('logging.default');
  27. $infos['common']['Log level'] = env('LOG_LEVEL');
  28. $infos['common']['DB driver'] = DB::getDriverName();
  29. // PHP info
  30. $infos['common']['PHP version'] = PHP_VERSION;
  31. $infos['common']['Operating system'] = PHP_OS;
  32. $infos['common']['interface'] = PHP_SAPI;
  33. // Auth & Security infos
  34. if (! is_null($request->user())) {
  35. $infos['common']['Auth guard'] = config('auth.defaults.guard');
  36. if ($infos['common']['Auth guard'] === 'reverse-proxy-guard') {
  37. $infos['common']['Auth proxy logout url'] = config('2fauth.config.proxyLogoutUrl');
  38. $infos['common']['Auth proxy header for user'] = config('auth.auth_proxy_headers.user');
  39. $infos['common']['Auth proxy header for email'] = config('auth.auth_proxy_headers.email');
  40. }
  41. $infos['common']['webauthn user verification'] = config('webauthn.user_verification');
  42. $infos['common']['Trusted proxies'] = config('2fauth.config.trustedProxies') ?: 'none';
  43. // Admin settings
  44. if ($request->user()->is_admin == true) {
  45. $infos['admin_settings']['useEncryption'] = Settings::get('useEncryption');
  46. $infos['admin_settings']['lastRadarScan'] = Carbon::parse(Settings::get('lastRadarScan'))->format('Y-m-d H:i:s');
  47. $infos['admin_settings']['checkForUpdate'] = Settings::get('CheckForUpdate');
  48. }
  49. }
  50. // User info
  51. if ($request->user()) {
  52. $infos['user_preferences'] = $request->user()->preferences->toArray();
  53. }
  54. return response()->json($infos);
  55. }
  56. /**
  57. * Get latest release
  58. *
  59. * @return \Illuminate\Http\JsonResponse
  60. */
  61. public function latestRelease(Request $request, ReleaseRadarService $releaseRadar)
  62. {
  63. $release = $releaseRadar->manualScan();
  64. return response()->json(['newRelease' => $release]);
  65. }
  66. }