2단계 인증은 7.0.6 에서 서버측이 갖춰졌지만 인증번호를 입력할 화면이 어느 버전에도
없었다. 그래서 그 설정을 켠 사이트는 관리자를 포함한 전원이 로그인할 수 없었다.
원인은 `POST /api/auth/login` 이 조건에 따라 **다른 형태의 200** 을 돌려준다는 것이다.
평소에는 `{token, user}` 지만 2단계 인증이 켜져 있으면 `{two_factor_required,
challenge_id, ...}` 를 돌려준다. 프론트는 앞의 형태만 선언하고 `response.data.user.language`
를 바로 읽었으므로 그 자리에서 TypeError 가 났고, 영문 원문이 로그인 화면에 그대로 노출됐다.
서버는 정상 응답했으므로 서버 로그에는 아무 흔적도 남지 않는다.
이어서 `setToken(undefined)` 가 `localStorage` 에 문자열 `"undefined"` 를 남겼다.
이 값은 truthy 라 이후 모든 요청이 `Bearer undefined` 로 나가 401 이 되고, 사용자에게는
「세션이 만료되었습니다」로 보인다. 관리자 로그인은 한발 더 나가 `null->isAdmin` 으로
500 이 되어, 설정을 되돌릴 수단까지 함께 사라졌다.
## 구현
- 로그인 응답을 판별 유니온(`LoginResult`)으로 표현하고, 형태를 판별한 뒤에 읽는다.
`ApiClient.setToken` 은 비어 있지 않은 문자열만 저장한다.
- 사용자·관리자 로그인 화면에 인증번호 입력 단계를 추가했다. 같은 카드 안에서 넘어가며
「인증번호 다시 받기」와 「처음부터」를 제공한다. 관리자 판정은 코드 확인에 성공한 뒤에
수행하고, 거부할 때는 그 직전에 발급된 토큰을 회수한다.
- 재발송(`login/two-factor/resend`)은 기존 challenge 를 취소하고 새로 발행한다. 유효한
코드를 여러 개 살려 두면 대입 시도의 표적이 넓어진다.
- 인증번호를 보내지 못하면 401 이 아니라 503 으로 답한다. 자격 증명은 올바른데 401 로
뭉개면 사용자는 비밀번호를 의심하며 같은 시도를 반복하고, 운영자는 메일 설정이 깨진
사실을 알 방법이 없다.
- 공개 본인인증 경로(`identity/verify`·`cancel`)가 로그인 목적의 challenge 를 소진하지
못하도록 403 게이트를 세웠다. 소진되면 그 challenge 로 영영 로그인할 수 없다.
- 로그인 시도 제한 429 응답이 다국어 문구를 싣도록 했다(종전에는 프레임워크 기본 영문).
- 다국어 파라미터에서 파이프 표현식이 평가되지 않아 「유효시간 까지」처럼 값이 빠지던
문제를 함께 고쳤다. 같은 결함이 문의 목록 화면에도 있었다.
## 이번 점검에서 함께 고친 것
- 계정 잠금(423)·발송 실패(503) 응답이 사용자·관리자 컨트롤러에 동일하게 복제돼 있었고
그 주석 자신은 "단일 지점에서 만든다" 고 적혀 있었다. 페이로드에 필드가 하나 추가되면
한쪽만 따라가 같은 실패를 두 화면이 다르게 안내하게 된다 — 트레이트로 통합했다.
- 테스트가 개발자 자신의 사이트 설정을 읽고 있었다. 2단계 인증을 켜 둔 환경에서는 로그인
성공을 전제한 테스트가 503 으로 깨지는데 실패 메시지가 원인을 가리키지도 않는다.
같은 결함군을 위해 이미 존재하던 단일 지점에 그 축을 추가했다.
## 버전
코어 7.0.11 · sirsoft-basic 1.1.4 · sirsoft-admin_basic 1.0.9 ·
번들 일본어팩 3종 · 템플릿 엔진 engine-v1.65.0.
121 lines
4.5 KiB
PHP
121 lines
4.5 KiB
PHP
<?php
|
|
|
|
return [
|
|
'providers' => [
|
|
'mail' => [
|
|
'label' => 'Email',
|
|
'settings' => [
|
|
'code_length' => 'Verification code length',
|
|
'code_length_help' => 'Number of digits in the verification code (default 6, min 4, max 10).',
|
|
'from_address' => 'From address',
|
|
'from_address_help' => 'Leave blank to use the system default sender.',
|
|
],
|
|
],
|
|
],
|
|
|
|
'errors' => [
|
|
'verification_required' => 'Identity verification is required.',
|
|
'challenge_not_found' => 'Invalid verification request.',
|
|
'wrong_provider' => 'This verification request must be handled by a different provider.',
|
|
'invalid_state' => 'This verification request has already been processed.',
|
|
'expired' => 'The verification has expired. Please try again.',
|
|
'max_attempts' => 'Too many attempts. Please request a new code.',
|
|
'invalid_code' => 'The verification code is incorrect.',
|
|
'invalid_verification_token' => 'Invalid verification token.',
|
|
'missing_target' => 'A verification target (email or phone) is required.',
|
|
'target_mismatch' => 'The verified target does not match the requested one.',
|
|
'purpose_not_supported' => 'The selected provider does not support this purpose.',
|
|
'provider_unavailable' => 'Identity verification provider is not available.',
|
|
'generic' => 'Identity verification failed.',
|
|
'missing_scope_or_target' => 'Both scope and target are required to resolve a policy.',
|
|
'admin_policy_has_no_default' => 'Admin-created policies do not have a declared default.',
|
|
'reset_field_failed' => 'Failed to reset the field to its declared default. Check if the field is valid.',
|
|
'cannot_delete_system_policy' => 'System-declared policies cannot be deleted. Only administrator-created policies can be deleted.',
|
|
'purpose_not_allowed' => 'This verification request cannot be handled on this screen.',
|
|
],
|
|
|
|
'messages' => [
|
|
'challenge_requested' => 'A verification code has been sent.',
|
|
'challenge_verified' => 'Identity verification completed.',
|
|
'challenge_cancelled' => 'Verification request has been cancelled.',
|
|
],
|
|
|
|
'logs' => [
|
|
'activity' => [
|
|
'requested' => 'Identity verification code sent to :email.',
|
|
'verified' => 'Identity verification completed.',
|
|
'failed' => 'Identity verification failed.',
|
|
'expired' => 'Identity verification expired.',
|
|
'cancelled' => 'Identity verification cancelled.',
|
|
],
|
|
],
|
|
|
|
'purposes' => [
|
|
'signup' => [
|
|
'label' => 'Signup Verification',
|
|
'description' => 'Verify ownership of email/phone for new sign-ups.',
|
|
],
|
|
'password_reset' => [
|
|
'label' => 'Password Reset',
|
|
'description' => 'Verify identity before resetting a forgotten password.',
|
|
],
|
|
'self_update' => [
|
|
'label' => 'Self Update',
|
|
'description' => 'Verify identity when a logged-in user changes their own contact info.',
|
|
],
|
|
'sensitive_action' => [
|
|
'label' => 'Sensitive Action',
|
|
'description' => 'Re-verify before sensitive actions such as account deletion or admin operations.',
|
|
],
|
|
'login' => [
|
|
'label' => 'Two-Factor Login',
|
|
'description' => 'Require one more step after the password when two-factor authentication is enabled.',
|
|
],
|
|
],
|
|
|
|
'channels' => [
|
|
'email' => 'Email',
|
|
],
|
|
|
|
'origin_types' => [
|
|
'route' => 'Route',
|
|
'hook' => 'Hook',
|
|
'policy' => 'Policy',
|
|
'middleware' => 'Middleware',
|
|
'api' => 'Direct API call',
|
|
'custom' => 'Custom',
|
|
'system' => 'System',
|
|
],
|
|
|
|
'policy' => [
|
|
'scope' => [
|
|
'route' => 'Route',
|
|
'hook' => 'Hook',
|
|
'custom' => 'Custom',
|
|
],
|
|
'fail_mode' => [
|
|
'block' => 'Block (HTTP 428)',
|
|
'log_only' => 'Log only',
|
|
],
|
|
'applies_to' => [
|
|
'self' => 'Self',
|
|
'admin' => 'Admin',
|
|
'both' => 'Both',
|
|
],
|
|
'source_type' => [
|
|
'core' => 'Core',
|
|
'module' => 'Module',
|
|
'plugin' => 'Plugin',
|
|
'admin' => 'Admin',
|
|
],
|
|
],
|
|
|
|
'message' => [
|
|
'scope_type' => [
|
|
'provider_default' => 'Provider default',
|
|
'purpose' => 'Per purpose',
|
|
'policy' => 'Per policy',
|
|
],
|
|
],
|
|
];
|