2023-09-08 00:43:00 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu\Auth;
|
|
|
|
|
|
|
|
use Index\Data\IDbConnection;
|
2023-10-20 22:29:28 +00:00
|
|
|
use Syokuhou\IConfig;
|
2023-09-08 00:43:00 +00:00
|
|
|
|
|
|
|
class AuthContext {
|
|
|
|
private Sessions $sessions;
|
|
|
|
private LoginAttempts $loginAttempts;
|
|
|
|
private RecoveryTokens $recoveryTokens;
|
|
|
|
private TwoFactorAuthSessions $tfaSessions;
|
|
|
|
|
|
|
|
private IConfig $config;
|
|
|
|
|
|
|
|
public function __construct(IDbConnection $dbConn, IConfig $config) {
|
|
|
|
$this->config = $config;
|
|
|
|
$this->sessions = new Sessions($dbConn);
|
|
|
|
$this->loginAttempts = new LoginAttempts($dbConn);
|
|
|
|
$this->recoveryTokens = new RecoveryTokens($dbConn);
|
|
|
|
$this->tfaSessions = new TwoFactorAuthSessions($dbConn);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSessions(): Sessions {
|
|
|
|
return $this->sessions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getLoginAttempts(): LoginAttempts {
|
|
|
|
return $this->loginAttempts;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getRecoveryTokens(): RecoveryTokens {
|
|
|
|
return $this->recoveryTokens;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getTwoFactorAuthSessions(): TwoFactorAuthSessions {
|
|
|
|
return $this->tfaSessions;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function createAuthTokenPacker(): AuthTokenPacker {
|
|
|
|
return new AuthTokenPacker($this->config->getString('secret', 'meow'));
|
|
|
|
}
|
|
|
|
}
|