2026-03-26 15:29:55 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace Config;
|
|
|
|
|
|
|
|
|
|
use CodeIgniter\Config\BaseConfig;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 로그인·2차 인증(TOTP) 관련 설정
|
|
|
|
|
*
|
2026-04-08 00:23:21 +09:00
|
|
|
* .env 의 auth.requireTotp 가 Config 기본값보다 우선합니다. 끄려면 반드시 false 로 두세요.
|
|
|
|
|
* 예:
|
|
|
|
|
* auth.requireTotp = false
|
|
|
|
|
* auth.requireTotp = true # 운영에서 2FA 켤 때
|
|
|
|
|
* auth.totpIssuer = "종량제 시스템"
|
2026-03-26 15:29:55 +09:00
|
|
|
*/
|
|
|
|
|
class Auth extends BaseConfig
|
|
|
|
|
{
|
2026-04-08 00:23:21 +09:00
|
|
|
/** false 이면 로그인 시 TOTP·등록 유도 없음. 운영에서 켤 때 .env 에 auth.requireTotp = true */
|
|
|
|
|
public bool $requireTotp = false;
|
2026-03-26 15:29:55 +09:00
|
|
|
|
|
|
|
|
/** 인증 앱에 표시되는 발급자(issuer) */
|
2026-04-08 00:23:21 +09:00
|
|
|
public string $totpIssuer = '종량제 시스템';
|
2026-03-26 15:29:55 +09:00
|
|
|
|
|
|
|
|
/** TOTP 연속 실패 시 세션 종료 전 허용 횟수 */
|
|
|
|
|
public int $totpMaxAttempts = 5;
|
|
|
|
|
|
|
|
|
|
/** 비밀번호 통과 후 2단계 완료까지 허용 시간(초) */
|
|
|
|
|
public int $pending2faTtlSeconds = 600;
|
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
|
|
$require = env('auth.requireTotp');
|
|
|
|
|
if ($require !== null && $require !== '') {
|
|
|
|
|
$this->requireTotp = filter_var($require, FILTER_VALIDATE_BOOLEAN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$issuer = env('auth.totpIssuer');
|
|
|
|
|
if (is_string($issuer) && $issuer !== '') {
|
|
|
|
|
$this->totpIssuer = $issuer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$max = env('auth.totpMaxAttempts');
|
|
|
|
|
if ($max !== null && $max !== '' && is_numeric($max)) {
|
|
|
|
|
$this->totpMaxAttempts = max(1, (int) $max);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$ttl = env('auth.pending2faTtlSeconds');
|
|
|
|
|
if ($ttl !== null && $ttl !== '' && is_numeric($ttl)) {
|
|
|
|
|
$this->pending2faTtlSeconds = max(60, (int) $ttl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|