- new app_otp_cache table + OtpCache entity (ResourceEnum::OtpCache) - PostgresOtpRepository upsert/find/delete keyed by email - register/resend persist otp_hash+expiry after email sent (no orphan OTP) - verify_email validates via OtpManager::validate_otp_hash, single-use delete - 8 unit tests pass, e2e verified: wrong OTP 400, correct OTP 200
2.6 KiB
2.6 KiB
Dimentorin — Catatan Temuan Infra (Dev Audit, 2026-08-04)
Dokumen ini mencatat temuan yang membutuhkan perhatian tim sebelum produksi.
Semua diuji lokal (Postgres dimentorin, backend :4099).
1. SMTP email verification broken (blocker aktivasi user baru)
- Endpoint
POST /v1/iam/auth/send-otpgagal:SMTP transport error (535): Username and Password not accepted— kredensial.env(SMTP_EMAIL=dev@example.com,SMTP_PASSWORD=dev) ditolak Google SMTP. POST /v1/iam/auth/verify-emailtetap butuh OTP untuk memanggil, tapi lihat poin 2.- Dampak: mentee/mentor baru tak bisa menerima OTP lewat email → tak bisa aktivasi → tak bisa login, kecuali via verify-email langsung.
- Diperlukan: SMTP credential institution yang valid (Gmail App Password atau SMTP relay), sebaiknya dari BWS secret management, bukan hardcode.
2. ✅ FIXED — verify-email TIDAK memverifikasi OTP (security issue)
Status: FIXED di branch feat/dimentorin-postgres (2026-08-04).
imphnen-iam/src/auth/application/mod.rs → verify_email():
- OTP sekarang dipersist ke tabel
app_otp_cache(entity baruimphnen-entities/src/seaorm/common/otp_cache.rs, resourceapp_otp_cachesudah direncanakan diResourceEnum::OtpCache). register()&resend_otp()menyimpanotp_hash+expires_atsetelah email terkirim (kalau email gagal, tidak ada OTP yatim / OTP lama tidak di-overwrite).verify_email()memanggilOtpManager::validate_otp_hash(stored_hash, expires_at, payload.otp)sebelum setis_active.validate_otp_hashditambahkan keOtpManager(pure hash+expiry tanpa perlu plaintext code).- OTP single-use: di-delete setelah verifikasi sukses. Reuse / OTP tanpa cache / OTP expired semua ditolak (400).
- Uji lokal (Postgres, :4099): OTP salah → 400 "Invalid or expired OTP", user tetap inactive; OTP benar → 200 "Email verified successfully", user aktif, OTP dihapus; verify ulang → 400 "User already active"; email tanpa OTP → 400 "No OTP issued".
- Tabel dibuat via SQL manual (
create_schema.rsditambahotp_cacheuntuk bootstrap penuh).
3. (OK, sudah benar) Register mentor + booking
POST /v1/dimentorin/mentors/create→ 200, user + mentor profile dibuat, statuspending, user tak tampil di list public sampai verified.POST /v1/dimentorin/mentors/{id}/sessions/create→ 200, session pending.- Kedua endpoint fungsional setelah fix UUID (commit
9b5efef).
Rekomendasi
Tangani #1 dan #2 sebelum go-live. #2 adalah kelas bug "OTP di-generate tapi tak dipakai" — sisi verifikasi email saat ini tidak lebih dari form "set is_active=true tanpa autentikasi".