Skip to content

API Sự kiện

Identity là một JWKS issuer theo mô hình pull; nó không tham gia vào Kafka. Các bề mặt bất đồng bộ là mail (Nodemailer), SMS (MQ-SMS), và phát sóng WebSocket.

1. Inbound

N/A. Identity chỉ phơi bày một bề mặt HTTP REST. Không có Kafka, BullMQ, hay tiếp nhận webhook.

2. Outbound — Mail

TriggerTemplateLocaleChuyển phát
AuthenticationService.signUp (sau khi tạo)welcome-{en|vi}từ userProfile.localeNodemailerComponent → SMTP
VerifyEmailService.requestVerificationverify-email-{en|vi}từ requestmã (6 chữ số) + URL xác thực
ForgotPasswordService.requestResetforgot-password-{en|vi}từ requestmã/token đặt lại
AuthenticationService.changePassword (sau khi cập nhật)password-changed-{en|vi}từ userthông báo xác nhận

Templates được seed bởi identity-0004-seed-mail-configurations.ts. Có thể chỉnh sửa runtime qua bảng Configuration (group=MAIL).

3. Outbound — SMS

TriggerTemplateLocale
PhoneOtpService.send (namespace=phone-auth)phone-auth-{en|vi}từ request
LinkAccountService.send (namespace=add-phone)add-phone-{en|vi}từ request

Provider: VN Pay SMS qua MQSMSComponent. Templates được seed bởi identity-0007-seed-sms-templates.ts. Cấu hình provider qua Configuration (group=SMS).

4. Outbound — WebSocket

IdentitySocketEventService phát sóng các sự kiện thuộc miền identity. Topics được phát qua ApplicationWebSocketComponent (Redis-backed).

Họ topicTriggerĐối tượng nhận
Trạng thái xác thực userđăng nhập, đăng xuất, đổi trạng tháimerchant admin / observability
Cập nhật role/permissionthay đổi policy definitiondashboards
Cập nhật profilethay đổi user profilebản thân + admin

Hằng số topic cụ thể được định nghĩa trong IdentityWebSocketTopics (trong components/websocket/); tham khảo source code để biết chuỗi chính xác.

5. Trạng thái OTP (Redis, không phải "events" nhưng đáng chú ý)

Các OTP service lưu trữ trạng thái trong Redis (không phải Kafka):

Mẫu keyMục đíchTTL
{namespace}:otp:{identifier}Mã đã hash5–15 phút mỗi flow
{namespace}:lock:{identifier}Khoá ở mức tài khoản sau khi vượt số lần thử tối đa10–15 phút
{namespace}:session:{token}Token phiên đã xác thực1–24 giờ mỗi flow
{namespace}:cooldown:{identifier}Cooldown gửi lại60s
{namespace}:daily:{identifier}Bộ đếm hạn ngạch hàng ngày24h

Namespaces: verify-email, verify-phone, forgot-password, phone-auth, add-phone, add-email.

6. Mẫu Request-Response

Bề mặt inbound "thực" là việc các sister service pull JWKS:

TừĐếnBề mặtTần suất
Sister VerifierApplicationIdentity /jw-certsHTTP GETTại thời điểm boot service + khi key-id không khớp

7. Trang liên quan

Proprietary and Confidential. Unauthorized copying, distribution, or use of this software is strictly prohibited.