Files
breadcrumb-the-shire/lib/Service/Auth/AuthGatewayFactory.php
fs 549d9dd6f4 test(auth): add 33 unit tests for AuthService and RememberMeService
AuthServiceTest (17 tests): canLoginToTenant, refreshSessionAuthState,
loginUserById, login email-not-verified branch.
RememberMeServiceTest (16 tests): rememberUser, autoLoginFromCookie
(all 11 branches), forgetCurrentUser, forgetAllForUser,
expireAllTokensByAdmin.

Also fixes: 3 PHPStan errors in FrontendTelemetryIngestService,
8 CS-Fixer violations in out-of-scope files (ordered_imports,
braces_position).

All quality gates green: QG-001 (429 tests/0 failures),
QG-002 (0 errors), QG-003 (11 arch tests pass), QG-006 (0 violations).

Task: AUTH-LOGIN-REVIEW-001

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 11:43:31 +01:00

125 lines
4.8 KiB
PHP

<?php
namespace MintyPHP\Service\Auth;
use MintyPHP\Service\Access\AccessServicesFactory;
use MintyPHP\Service\Access\PermissionGateway;
use MintyPHP\Service\Settings\SettingsApiPolicyGateway;
use MintyPHP\Service\Settings\SettingsAppGateway;
use MintyPHP\Service\Settings\SettingsDefaultsGateway;
use MintyPHP\Service\Settings\SettingServicesFactory;
use MintyPHP\Service\Settings\SettingsMicrosoftGateway;
use MintyPHP\Service\Tenant\TenantScopeService;
use MintyPHP\Service\User\UserServicesFactory;
class AuthGatewayFactory
{
private ?SettingsMicrosoftGateway $settingsMicrosoftGateway = null;
private ?SettingsApiPolicyGateway $settingsApiPolicyGateway = null;
private ?SettingsDefaultsGateway $settingsDefaultsGateway = null;
private ?SettingsAppGateway $settingsAppGateway = null;
private ?PermissionGateway $permissionGateway = null;
private ?AuthSettingsGateway $authSettingsGateway = null;
private ?AuthScopeGateway $authScopeGateway = null;
private ?AuthPermissionGateway $authPermissionGateway = null;
private ?AuthTenantGateway $authTenantGateway = null;
private ?AuthCryptoGateway $authCryptoGateway = null;
private ?AuthTenantSsoGateway $authTenantSsoGateway = null;
private ?AuthSavedFilterGateway $authSavedFilterGateway = null;
private ?AuthAvatarGateway $authAvatarGateway = null;
private ?AuthExternalIdentityGateway $authExternalIdentityGateway = null;
public function __construct(
private readonly AuthRepositoryFactory $authRepositoryFactory,
private readonly AccessServicesFactory $accessServicesFactory,
private readonly UserServicesFactory $userServicesFactory,
private readonly SettingServicesFactory $settingServicesFactory,
private readonly TenantScopeService $tenantScopeService
) {
}
public function createAuthSettingsGateway(): AuthSettingsGateway
{
return $this->authSettingsGateway ??= new AuthSettingsGateway(
$this->createSettingsMicrosoftGateway(),
$this->createSettingsApiPolicyGateway(),
$this->createSettingsDefaultsGateway(),
$this->createSettingsAppGateway()
);
}
public function createAuthScopeGateway(): AuthScopeGateway
{
return $this->authScopeGateway ??= new AuthScopeGateway($this->tenantScopeService);
}
public function createAuthPermissionGateway(): AuthPermissionGateway
{
return $this->authPermissionGateway ??= new AuthPermissionGateway($this->createPermissionGateway());
}
public function createAuthTenantGateway(): AuthTenantGateway
{
return $this->authTenantGateway ??= new AuthTenantGateway(
$this->authRepositoryFactory->createTenantRepository()
);
}
public function createAuthCryptoGateway(): AuthCryptoGateway
{
return $this->authCryptoGateway ??= new AuthCryptoGateway();
}
public function createAuthTenantSsoGateway(TenantSsoService $tenantSsoService): AuthTenantSsoGateway
{
return $this->authTenantSsoGateway ??= new AuthTenantSsoGateway($tenantSsoService);
}
public function createAuthSavedFilterGateway(): AuthSavedFilterGateway
{
return $this->authSavedFilterGateway ??= new AuthSavedFilterGateway(
$this->userServicesFactory->createUserSavedFilterService()
);
}
public function createAuthAvatarGateway(): AuthAvatarGateway
{
return $this->authAvatarGateway ??= new AuthAvatarGateway(
$this->userServicesFactory->createUserAvatarService()
);
}
public function createAuthExternalIdentityGateway(): AuthExternalIdentityGateway
{
return $this->authExternalIdentityGateway ??= new AuthExternalIdentityGateway(
$this->authRepositoryFactory->createUserExternalIdentityRepository()
);
}
private function createPermissionGateway(): PermissionGateway
{
return $this->permissionGateway ??= $this->accessServicesFactory->createPermissionGateway();
}
private function createSettingsMicrosoftGateway(): SettingsMicrosoftGateway
{
return $this->settingsMicrosoftGateway ??= $this->settingServicesFactory->createSettingsMicrosoftGateway();
}
private function createSettingsApiPolicyGateway(): SettingsApiPolicyGateway
{
return $this->settingsApiPolicyGateway ??= $this->settingServicesFactory->createSettingsApiPolicyGateway();
}
private function createSettingsDefaultsGateway(): SettingsDefaultsGateway
{
return $this->settingsDefaultsGateway ??= $this->settingServicesFactory->createSettingsDefaultsGateway();
}
private function createSettingsAppGateway(): SettingsAppGateway
{
return $this->settingsAppGateway ??= $this->settingServicesFactory->createSettingsAppGateway();
}
}