Herzen, Reichweite und App-Anbindung (0.30.0)
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m10s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 6m3s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m33s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m25s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m28s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m27s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m26s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m27s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m12s
Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 6m10s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Failing after 6m3s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 7m33s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 7m25s
CI / PHP 8.3 / mysql:8.0 (pull_request) Failing after 7m28s
CI / PHP 8.4 / mysql:8.0 (pull_request) Failing after 7m27s
CI / PHP 8.3 / mysql:8.4 (pull_request) Failing after 6m26s
CI / PHP 8.4 / mysql:8.4 (pull_request) Failing after 6m27s
CI / Bekannte Sicherheitslücken in Paketen (pull_request) Successful in 44s
CI / Build-Artefakte aktuell (pull_request) Successful in 1m12s
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d9fcc7a9b4
commit
b3e2b525e1
161 changed files with 1249 additions and 342 deletions
60
app/Http/Controllers/AppConnectController.php
Normal file
60
app/Http/Controllers/AppConnectController.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Support\AppConnect;
|
||||
use App\Support\Audit;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Inertia\Response;
|
||||
use Symfony\Component\HttpFoundation\Response as HttpResponse;
|
||||
|
||||
/**
|
||||
* „App verbinden“: Die Inhaus-App öffnet diese Seite im Browser. So klappt die Anmeldung
|
||||
* auch mit Microsoft & Co.; die Person bestätigt, danach geht es zurück in die App.
|
||||
*/
|
||||
class AppConnectController extends Controller
|
||||
{
|
||||
public function show(Request $request): Response
|
||||
{
|
||||
$data = $this->validated($request);
|
||||
|
||||
return Inertia::render('AppConnect', [
|
||||
'deviceName' => $data['device_name'],
|
||||
'query' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function confirm(Request $request): HttpResponse
|
||||
{
|
||||
$data = $this->validated($request);
|
||||
$code = AppConnect::issueCode($request->user()->id, $data['code_challenge'], $data['device_name']);
|
||||
Audit::log('api.app_connect', ['user' => $request->user()->id, 'device' => $data['device_name']]);
|
||||
|
||||
$separator = str_contains($data['redirect_uri'], '?') ? '&' : '?';
|
||||
|
||||
return Inertia::location($data['redirect_uri'].$separator.http_build_query(['code' => $code, 'state' => $data['state']]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{redirect_uri: string, device_name: string, code_challenge: string, state: string}
|
||||
*/
|
||||
private function validated(Request $request): array
|
||||
{
|
||||
$data = $request->validate([
|
||||
'redirect_uri' => ['required', 'string', 'max:500'],
|
||||
'device_name' => ['nullable', 'string', 'max:100'],
|
||||
'code_challenge' => ['required', 'string'],
|
||||
'state' => ['required', 'string', 'max:200'],
|
||||
]);
|
||||
|
||||
abort_unless(AppConnect::allowedRedirect($data['redirect_uri']) && AppConnect::validChallenge($data['code_challenge']), 400, 'Ungültige Anfrage der App.');
|
||||
|
||||
return [
|
||||
'redirect_uri' => $data['redirect_uri'],
|
||||
'device_name' => trim($data['device_name'] ?? '') ?: 'Inhaus-App',
|
||||
'code_challenge' => $data['code_challenge'],
|
||||
'state' => $data['state'],
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue