CPG-CRM FSD Auth

FSD — Admin CRM

A. Document controlA. Kiểm soát tài liệu

Doc IDCPG-FSD-CPG-CRM_FSD_Auth
VersionPhiên bản1.1
StatusTrạng tháiDraft
OwnerCPG BA / Architecture
AudienceĐối tượngFrontend, Backend, FlyPay Support, QA, Product
ClassificationPhân loạiInternal
Effective dateNgày hiệu lực01/12/2026
Related docs Admin CRM Index · BR/NFR Catalog

B. Version historyB. Lịch sử phiên bản

Version Date Author ChangesThay đổi
1.0 14/01/2026 Khoa Trinh Version 1.0
1.1 28/07/2026 Khoa Trinh Version 1.1, update change password, wrong password, security section

C. Table of contentsC. Mục lục

D. ContentD. Nội dung

1. Module Scope

Provide authentication, authorization entry points, user session handling, language selection, notifications access, and global navigation for the system

2. User Roles

Role

Description

Guest User

Unauthenticated user accessing login, forgot password, and language selection

Authenticated User

Logged-in system user accessing protected features

3. Functional Requirements

3.1 Features

3.1.1 User Login

Item

Description

Description

Allow users to authenticate using email and password

Inputs

Email address, password

Validation

Required fields, valid email format

Output

Authenticated session or error message

Security

Password masked, HTTPS required

3.1.2 Two-Factor Authentication (2FA)

Item

Description

Description

Verify user identity using a 6-digit OTP after login

Trigger

Login attempt for 2FA-enabled account

Input

6-digit verification code

Options

Verify, Resend Code, Cancel

Security

Time-limited OTP, retry limit

3.1.3 Forgot Password

Item

Description

Description

Allow users to reset password via email

Input

Email address

Process

Send reset link via email

Constraints

Reset link valid for 24 hours

3.1.4 Change Password

Item

Description

Description

Notify the user has changed password via email, allow the user deactivate this account immediately if they notice an unusual event.

Process

Deactive link was included in Password changed notify via email

Constraints

Deactive link valid for 24 hours

3.1.5 Wrong Password

Item

Description

Description

Deactive user account after 5 failed login.

Process

Submit the wrong password 5 times, the account will be deactivated. Reset counter once login success.

Constraints

Login email exist

3.1.6 Logout

Item

Description

Description

Terminate current user session

Scope

Current session only

Result

Redirect to login page

3.1.7 Language Selection

Item

Description

Description

Allow users to select system language

Supported Languages

English, Khmer, Chinese

Persistence

Saved per user session/account

3.1.8 Notifications Preview

Item

Description

Description

Display recent notifications in dropdown

Notification Types

Merchant, Ticket, Financial, System

Actions

Mark as read, View all notifications

3.1.9 My Account Menu

Item

Description

Description

Quick access menu for user-related actions

Options

My Profile, Change Password, Log Out

3.1.10 Sidebar Navigation

Item

Description

Description

Primary navigation for system modules

Items

Dashboard, Merchants, Risk & Compliance, Ticket Support, Accounts, Transactions, Reports, Audit Logs, System

Behavior

Expand/Collapse sections, highlight active module

3.2 Use Cases

Detailed use-case catalog for this module is maintained under 08_UC:Catalog use case chi tiết của module này được quản lý tại 08_UC:

4. User Interface

4.1 Login Screen

Element

Description

Email Field

Input for user email

Password Field

Masked password input

Remember Me

Optional session persistence

Forgot Password Link

Redirect to password reset

Sign In Button

Submit login form

4.2 Two-Factor Authentication Modal

Element

Description

OTP Input

6 separate digit inputs

Resend Code

Request new OTP

Verify Button

Submit OTP

Cancel Button

Abort login

4.3 Forgot Password Modal

Element

Description

Email Input

User email

Reset Button

Send reset email

Note

Reset link validity information

4.4 Notifications Dropdown

Element

Description

Notification List

Recent unread notifications

Badge Counter

Number of unread notifications

Mark All as Read

Bulk action

View All

Navigate to full notifications page

4.5 Sidebar Navigation

Element

Description

Logo

System branding

Menu Items

Module navigation

Expand Icon

Show/hide submenus

Profile Shortcut

Link to My Profile

5. Data Requirements

5.1 Data Dictionary

Users:

See CPG-CRM/FSD_Setting_URG, 5.1 Data Dictionary

5.2 Data Models

Entity Relationship

See CPG-CRM/FSD_Setting_URG, 5.1 Data Dictionary

Status / Enums

Enum Name

Values

NotificationType

Merchant, Ticket, Financial, System

NotificationStatus

Unread, Read

AuthStatus

Pending, Verified, Failed

LanguageCode

en, km, zh

6. API Routes

Base path: /api/v1

6.1 Authentication APIs

Method

Route

Purpose

Notes

POST

/auth/login

Authenticate user

Email & password

POST

/auth/logout

Logout user

Invalidate session

POST

/auth/forgot-password

Send reset link

Email required

POST

/auth/reset-password

Reset password

Token-based

POST

/auth/2fa/verify

Verify OTP

6-digit code

POST

/auth/2fa/resend

Resend OTP

Rate limited

6.2 User Preferences APIs

Method

Route

Purpose

Notes

GET

/profile

Get user profile

Auth required

PUT

/profile/language

Update language

Persist preference

6.3 Notifications APIs

See CPG-CRM/FSD_Profile, 6.2 Notification APIs

6.4 Session & Navigation APIs

Method

Route

Purpose

Notes

GET

/profile/session

Get current session

Active user

GET

/profile/navigation

Get sidebar menu

Role-based

7. Security

7.1 Application security (Doc03)

Fleet-wide application security is defined in Doc03 - Application Security. This FSD does not restate Doc03.

Apply as baseline for CRM Auth (auth-service - admin / CRM identity plane):

Doc03 area

Relevance

Part A trust zones / identity planes

Admin JWT plane: issuer for CRM sessions (user_id, email, sid, permissions, grants)

Part A principles P1–P8

Zero trust at app boundaries; least privilege; MFA for privileged users; no secret/PII logging

G1–G9 General controls

JWT consumption pattern (consumers), Vault secrets, error envelope, correlation, SDLC, S2S discipline

APPSEC-ID-02

Dual identity planes (admin vs merchant issuers)

APPSEC-ID-03

Session revoke / opaque refresh hygiene

APPSEC-ID-04

MFA (TOTP 2FA) for privileged access

APPSEC-ID-05

Brute-force login mitigation (failed-attempt lockout)

APPSEC-ID-06 / 07

URG RBAC + field-level grants / masking

APPSEC-ID-11

Password hashing (bcrypt)

APPSEC-ID-13 / 14

Secrets via Vault; no hardcoded keys in prod path

APPSEC-ID-15 / 16 / 18 / 20

Stable error envelope; input validation; request_id; no secrets/PII in logs

Doc03 S1. auth-service

Module-specific deltas (JWT issuer, 2FA, sessions, URG DB re-check)

7.2 Specific security (Auth module)

Aligned with Doc03 S1. auth-service, control objectives CO-ID-01…04, CO-CR-02, and product FR in this FSD (login, 2FA, password reset, logout, session/navigation).

Control

Requirement

Notes

AuthN - Login

Email + password; password masked client-side; HTTPS at edge

password never logged

Password storage

bcrypt one-way hash; strength checks on set/change

APPSEC-ID-11; internal/auth/password.go

Password reset

Token-based reset; link time-bound (FSD: 24h); single-use intent

Rate-limit request path; no user enumeration in messages where feasible

2FA (TOTP)

After password, require 6-digit OTP for 2FA-enabled accounts; time-limited; retry limits

APPSEC-ID-04; secrets encrypted with TOTP_ENCRYPTION_KEY; pending 2FA token is short-lived and not a full session

JWT access token

HS256 access JWT with user_id, email, sid, permissions, grants; short-lived

Doc03 APPSEC-ID-02/03; consumers validate via pkg/auth + shared secret

Refresh / session

Opaque refresh in Redis; session rows hashed (SHA-256); list + revoke

APPSEC-ID-03; logout invalidates current session only (FSD 3.1.4)

Login lockout

Counter after failed attempts; lock/inactive as configured

APPSEC-ID-05; login_failed_attempts

AuthZ / URG

Effective permissions re-resolved from DB (not JWT claims alone) for sensitive admin actions

APPSEC-ID-06; EffectiveFlat / urgAll / urgAny; prevents stale-claim escalation

Security-action tokens

Short-lived tokens for sensitive UX (e.g. password change, phishing-code flows)

separate from long-lived session JWT

Public routes

Only documented guest endpoints: login, forgot/reset password, 2FA pending verify/resend

All other Auth APIs require valid session/JWT

Rate limiting

2FA resend and login attempts limited

S2S notifications

Auth → notification-service uses internal plane when notifying

Doc03 APPSEC-ID-08

Errors

Stable envelope (UNAUTHORIZED, FORBIDDEN, VALIDATION_ERROR, …); no stack/SQL/secrets

G3 / APPSEC-ID-15

Logging

Correlate via request_id; never log passwords, JWT, refresh, TOTP secrets, or reset tokens

G5 / APPSEC-ID-20

Secrets

JWT_SECRET, TOTP_ENCRYPTION_KEY, DB/Redis via Vault CSI in non-dev

APPSEC-ID-13

E. ReferencesE. Tham chiếu