diff --git a/app/Http/Controllers/SystemController.php b/app/Http/Controllers/SystemController.php
index 934f4367..af54e365 100644
--- a/app/Http/Controllers/SystemController.php
+++ b/app/Http/Controllers/SystemController.php
@@ -34,27 +34,15 @@ public function infos(Request $request)
$infos['common']['Operating system'] = PHP_OS;
$infos['common']['interface'] = PHP_SAPI;
// Auth & Security infos
- if (! is_null($request->user())) {
- $infos['common']['Auth guard'] = config('auth.defaults.guard');
- if ($infos['common']['Auth guard'] === 'reverse-proxy-guard') {
- $infos['common']['Auth proxy logout url'] = config('2fauth.config.proxyLogoutUrl');
- $infos['common']['Auth proxy header for user'] = config('auth.auth_proxy_headers.user');
- $infos['common']['Auth proxy header for email'] = config('auth.auth_proxy_headers.email');
- }
- $infos['common']['webauthn user verification'] = config('webauthn.user_verification');
- $infos['common']['Trusted proxies'] = config('2fauth.config.trustedProxies') ?: 'none';
-
- // Admin settings
- if ($request->user()->isAdministrator()) {
- $infos['admin_settings']['useEncryption'] = Settings::get('useEncryption');
- $infos['admin_settings']['lastRadarScan'] = Carbon::parse(Settings::get('lastRadarScan'))->format('Y-m-d H:i:s');
- $infos['admin_settings']['checkForUpdate'] = Settings::get('checkForUpdate');
- }
- }
- // User info
- if ($request->user()) {
- $infos['user_preferences'] = $request->user()->preferences->toArray();
+ $infos['common']['Auth guard'] = config('auth.defaults.guard');
+ if ($infos['common']['Auth guard'] === 'reverse-proxy-guard') {
+ $infos['common']['Auth proxy logout url'] = config('2fauth.config.proxyLogoutUrl');
+ $infos['common']['Auth proxy header for user'] = config('auth.auth_proxy_headers.user');
+ $infos['common']['Auth proxy header for email'] = config('auth.auth_proxy_headers.email');
}
+ $infos['common']['webauthn user verification'] = config('webauthn.user_verification');
+ $infos['common']['Trusted proxies'] = config('2fauth.config.trustedProxies') ?: 'none';
+ $infos['common']['lastRadarScan'] = Carbon::parse(Settings::get('lastRadarScan'))->format('Y-m-d H:i:s');
return response()->json($infos);
}
diff --git a/resources/js/views/About.vue b/resources/js/views/About.vue
index 0d94494a..fd241b11 100644
--- a/resources/js/views/About.vue
+++ b/resources/js/views/About.vue
@@ -1,35 +1,9 @@
@@ -87,36 +61,6 @@
{{ $t('commons.logos_by') }} 2FA Directory (MIT License)
-
- {{ $t('commons.environment') }}
-
-
-
- {{ $t('errors.error_during_data_fetching') }}
-
-
- {{ $t('settings.admin_settings') }}
-
-
-
-
- - {{setting}}: {{value}}
-
-
-
- {{ $t('settings.user_preferences') }}
-
-
-
-
- - {{preference}}: {{value}}
-
-
diff --git a/resources/js/views/admin/AppSetup.vue b/resources/js/views/admin/AppSetup.vue
index eb328bd7..8c0d1155 100644
--- a/resources/js/views/admin/AppSetup.vue
+++ b/resources/js/views/admin/AppSetup.vue
@@ -1,15 +1,20 @@
@@ -48,6 +62,18 @@
saveSetting('enableSso', val)" fieldName="enableSso" label="admin.forms.enable_sso.label" help="admin.forms.enable_sso.help" />
+ {{ $t('commons.environment') }}
+
+
+
+ -
+ {{ preference }}: {{ value }}
+
+
+
+
+ {{ $t('errors.error_during_data_fetching') }}
+
diff --git a/routes/web.php b/routes/web.php
index 34472005..6efdc661 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -77,7 +77,14 @@
return csrf_token();
});
-Route::get('infos', [SystemController::class, 'infos'])->name('system.infos');
+
+/**
+ * Routes protected by an authentication guard and restricted to administrators
+ */
+Route::group(['middleware' => ['behind-auth', 'admin']], function () {
+ Route::get('infos', [SystemController::class, 'infos'])->name('system.infos');
+});
+
Route::get('latestRelease', [SystemController::class, 'latestRelease'])->name('system.latestRelease');
/**
diff --git a/tests/Feature/Http/SystemControllerTest.php b/tests/Feature/Http/SystemControllerTest.php
index c6e1967e..65c2af28 100644
--- a/tests/Feature/Http/SystemControllerTest.php
+++ b/tests/Feature/Http/SystemControllerTest.php
@@ -15,12 +15,12 @@
#[CoversClass(SystemController::class)]
class SystemControllerTest extends FeatureTestCase
{
- use WithoutMiddleware;
+ //use WithoutMiddleware;
/**
* @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
*/
- protected $user;
+ protected $user, $admin;
/**
* @test
@@ -30,6 +30,26 @@ public function setUp() : void
parent::setUp();
$this->user = User::factory()->create();
+ $this->admin = User::factory()->administrator()->create();
+ }
+
+ /**
+ * @test
+ */
+ public function test_infos_returns_unauthorized()
+ {
+ $response = $this->json('GET', '/infos')
+ ->assertUnauthorized();
+ }
+
+ /**
+ * @test
+ */
+ public function test_infos_returns_forbidden()
+ {
+ $response = $this->actingAs($this->user, 'api-guard')
+ ->json('GET', '/infos')
+ ->assertForbidden();
}
/**
@@ -37,7 +57,8 @@ public function setUp() : void
*/
public function test_infos_returns_only_base_collection()
{
- $response = $this->json('GET', '/infos')
+ $response = $this->actingAs($this->admin, 'api-guard')
+ ->json('GET', '/infos')
->assertOk()
->assertJsonStructure([
'common' => [
@@ -54,61 +75,10 @@ public function test_infos_returns_only_base_collection()
'PHP version',
'Operating system',
'interface',
- ],
- ])
- ->assertJsonMissing([
- 'user_preferences',
- 'admin_settings',
- ]);
- }
-
- /**
- * @test
- */
- public function test_infos_returns_user_preferences_when_signed_in()
- {
- $response = $this->actingAs($this->user, 'api-guard')
- ->json('GET', '/infos')
- ->assertOk()
- ->assertJsonStructure([
- 'user_preferences' => [
- 'showOtpAsDot',
- 'closeOtpOnCopy',
- 'copyOtpOnDisplay',
- 'useBasicQrcodeReader',
- 'displayMode',
- 'showAccountsIcons',
- 'kickUserAfter',
- 'activeGroup',
- 'rememberActiveGroup',
- 'defaultGroup',
- 'defaultCaptureMode',
- 'useDirectCapture',
- 'useWebauthnOnly',
- 'getOfficialIcons',
- 'lang',
- ],
- ]);
- }
-
- /**
- * @test
- */
- public function test_infos_returns_admin_settings_when_signed_in_as_admin()
- {
- /**
- * @var \App\Models\User|\Illuminate\Contracts\Auth\Authenticatable
- */
- $admin = User::factory()->administrator()->create();
-
- $response = $this->actingAs($admin, 'api-guard')
- ->json('GET', '/infos')
- ->assertOk()
- ->assertJsonStructure([
- 'admin_settings' => [
- 'useEncryption',
- 'lastRadarScan',
- 'checkForUpdate',
+ 'Auth guard',
+ 'webauthn user verification',
+ 'Trusted proxies',
+ 'lastRadarScan'
],
]);
}
@@ -118,11 +88,12 @@ public function test_infos_returns_admin_settings_when_signed_in_as_admin()
*/
public function test_infos_returns_proxy_collection_when_signed_in_behind_proxy()
{
- $response = $this->actingAs($this->user, 'reverse-proxy-guard')
+ $response = $this->actingAs($this->admin, 'reverse-proxy-guard')
->json('GET', '/infos')
->assertOk()
->assertJsonStructure([
'common' => [
+ 'Auth proxy logout url',
'Auth proxy header for user',
'Auth proxy header for email',
],