Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
GetAppMonitoringCredentialsEndpoint
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
20
0.00% covered (danger)
0.00%
0 / 1
 handle
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
20
1<?php
2
3namespace Olz\Apps\Monitoring\Endpoints;
4
5use Olz\Api\OlzTypedEndpoint;
6use PhpTypeScriptApi\HttpError;
7
8/**
9 * @extends OlzTypedEndpoint<
10 *   ?array{},
11 *   array{username: non-empty-string, password: non-empty-string}
12 * >
13 */
14class GetAppMonitoringCredentialsEndpoint extends OlzTypedEndpoint {
15    protected function handle(mixed $input): mixed {
16        if (!$this->authUtils()->hasPermission('all')) {
17            throw new HttpError(403, "Kein Zugriff!");
18        }
19
20        $user = $this->authUtils()->getCurrentUser();
21        $this->log()->info("Monitoring credentials access by {$user?->getUsername()}.");
22
23        return [
24            'username' => $this->envUtils()->getAppMonitoringUsername() ?: '-',
25            'password' => $this->envUtils()->getAppMonitoringPassword() ?: '-',
26        ];
27    }
28}