@@ -1,8 +1,14 @@
|
||||
<?php
|
||||
|
||||
// Loaded exclusively by the guarded QA router. Never log request bodies or cookie values.
|
||||
use App\Http\Middleware\HandleInertiaRequests;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Encryption\DecryptException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Session\FileSessionHandler;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use PragmaRX\Google2FA\Google2FA;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class PortalQaAuthTrace
|
||||
@@ -71,11 +77,11 @@ class PortalQaAuthTrace
|
||||
if ($request->isMethod('POST') && $request->is('login')) {
|
||||
$email = $request->input('email');
|
||||
$password = $request->input('password');
|
||||
$actor = \App\Models\User::find(18);
|
||||
$actor = User::find(18);
|
||||
$emailMatches = is_string($email) && $actor && $email === $actor->email;
|
||||
$loginInputCheck = ['expected_qa_account' => 18, 'email_exact_matches_qa18' => (bool) $emailMatches,
|
||||
'password_matches_qa18' => $emailMatches && is_string($password)
|
||||
? \Illuminate\Support\Facades\Hash::check($password, $actor->password) : null];
|
||||
? Hash::check($password, $actor->password) : null];
|
||||
unset($email, $password, $actor);
|
||||
}
|
||||
$persisted = null;
|
||||
@@ -92,15 +98,15 @@ class PortalQaAuthTrace
|
||||
}
|
||||
$middleware = $request->route() ? app('router')->gatherRouteMiddleware($request->route()) : [];
|
||||
$handlerDirectory = null;
|
||||
if ($request->hasSession() && $request->session()->getHandler() instanceof \Illuminate\Session\FileSessionHandler) {
|
||||
$property = new \ReflectionProperty(\Illuminate\Session\FileSessionHandler::class, 'path');
|
||||
if ($request->hasSession() && $request->session()->getHandler() instanceof FileSessionHandler) {
|
||||
$property = new ReflectionProperty(FileSessionHandler::class, 'path');
|
||||
$handlerDirectory = $property->getValue($request->session()->getHandler());
|
||||
}
|
||||
$entry = ['at_utc' => gmdate('c'), 'trace' => $trace, 'method' => $request->method(), 'path' => '/'.$request->path(),
|
||||
'origin' => $request->getSchemeAndHttpHost(), 'cookie_name_counts' => $names,
|
||||
'inertia' => $request->headers->has('X-Inertia'), 'json_expected' => $request->expectsJson(),
|
||||
'inertia_version_matches' => $request->headers->has('X-Inertia-Version')
|
||||
? hash_equals((string) app(\App\Http\Middleware\HandleInertiaRequests::class)->version($request), (string) $request->headers->get('X-Inertia-Version')) : null,
|
||||
? hash_equals((string) app(HandleInertiaRequests::class)->version($request), (string) $request->headers->get('X-Inertia-Version')) : null,
|
||||
'qa_restored_account_rejected' => $request->attributes->get('qa_restored_account_rejected', false),
|
||||
'login_input_check' => $loginInputCheck, // Booleans only: no submitted values or password fingerprints.
|
||||
'mfa_input_check' => $request->attributes->get('qa_mfa_input_check'),
|
||||
@@ -138,13 +144,15 @@ class PortalQaSessionTrace
|
||||
$code = $request->input('code');
|
||||
$check = ['account_id' => 18, 'six_digits' => is_string($code) && preg_match('/^[0-9]{6}$/D', $code) === 1];
|
||||
try {
|
||||
$actor = \App\Models\User::findOrFail(18);
|
||||
$actor = User::findOrFail(18);
|
||||
$secret = app('encrypter')->decrypt($actor->two_factor_secret);
|
||||
$check['secret_decrypts'] = is_string($secret);
|
||||
if ($check['six_digits'] && $check['secret_decrypts']) {
|
||||
$engine = new \PragmaRX\Google2FA\Google2FA;
|
||||
$engine = new Google2FA;
|
||||
$window = config('fortify-options.two-factor-authentication.window');
|
||||
if (is_int($window)) $engine->setWindow($window);
|
||||
if (is_int($window)) {
|
||||
$engine->setWindow($window);
|
||||
}
|
||||
$previous = app('cache.store')->get('fortify.2fa_codes.'.md5($code));
|
||||
$check['matches_configured_time_window'] = $engine->verifyKey($secret, $code);
|
||||
$check['previously_used_in_cache'] = $previous !== null;
|
||||
@@ -152,9 +160,9 @@ class PortalQaSessionTrace
|
||||
$engine->setWindow(12);
|
||||
$check['matches_wider_diagnostic_window_only'] = ! $check['matches_configured_time_window'] && $engine->verifyKey($secret, $code);
|
||||
}
|
||||
} catch (\Illuminate\Contracts\Encryption\DecryptException) {
|
||||
} catch (DecryptException) {
|
||||
$check['secret_decrypts'] = false;
|
||||
} catch (\Throwable) {
|
||||
} catch (Throwable) {
|
||||
$check['diagnostic_unavailable'] = true;
|
||||
} finally {
|
||||
unset($code, $actor, $secret, $engine, $previous);
|
||||
|
||||
Reference in New Issue
Block a user