@xdev-asia/xdev-knowledge-mcp 1.0.38 → 1.0.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/01-phan-1-kien-truc-nen-tang/lessons/04-bai-4-threat-modeling-stride-dread.md +79 -114
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/02-phan-2-iam-keycloak/lessons/01-bai-5-setup-keycloak-realm-benh-vien.md +33 -84
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/02-phan-2-iam-keycloak/lessons/02-bai-6-phan-quyen-rbac-abac.md +6 -23
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/02-phan-2-iam-keycloak/lessons/03-bai-7-smart-on-fhir-oauth2-oidc.md +25 -36
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/02-phan-2-iam-keycloak/lessons/04-bai-8-mfa-passkeys-emergency-access.md +7 -23
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/03-phan-3-data-layer-postgresql/lessons/01-bai-9-postgresql-security-hardening.md +23 -69
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/03-phan-3-data-layer-postgresql/lessons/02-bai-10-ma-hoa-du-lieu-postgresql.md +25 -80
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/03-phan-3-data-layer-postgresql/lessons/03-bai-11-row-level-security-column-encryption.md +26 -55
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/03-phan-3-data-layer-postgresql/lessons/04-bai-12-audit-logging-cdc-pgaudit.md +51 -87
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/04-phan-4-microservices-quarkus/lessons/03-bai-15-ma-hoa-end-to-end-microservices.md +18 -63
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/04-phan-4-microservices-quarkus/lessons/04-bai-16-mtls-service-mesh.md +26 -88
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/05-phan-5-compliance-audit/lessons/01-bai-17-hipaa-technical-safeguards.md +50 -61
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/05-phan-5-compliance-audit/lessons/02-bai-18-audit-trail-opentelemetry-elk.md +11 -34
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/05-phan-5-compliance-audit/lessons/03-bai-19-data-masking-anonymization.md +113 -223
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/05-phan-5-compliance-audit/lessons/04-bai-20-backup-disaster-recovery.md +92 -149
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/06-phan-6-production-van-hanh/lessons/01-bai-21-zero-trust-architecture.md +126 -271
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/06-phan-6-production-van-hanh/lessons/02-bai-22-container-kubernetes-security.md +10 -52
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/06-phan-6-production-van-hanh/lessons/03-bai-23-penetration-testing.md +51 -90
- package/content/series/architecture/xay-dung-he-thong-y-te-microservices/chapters/06-phan-6-production-van-hanh/lessons/04-bai-24-capstone-deploy-production.md +137 -232
- package/package.json +1 -1
|
@@ -27,19 +27,7 @@ course:
|
|
|
27
27
|
|
|
28
28
|
### 1.1. Quy trình Threat Modeling
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
┌──────────────────────────────────────────────────────────┐
|
|
32
|
-
│ Threat Modeling Process │
|
|
33
|
-
│ │
|
|
34
|
-
│ 1. Define Scope ──▶ 2. Decompose ──▶ 3. Identify │
|
|
35
|
-
│ & Objectives Application Threats │
|
|
36
|
-
│ │ │ │
|
|
37
|
-
│ │ ┌─────────────────────┘ │
|
|
38
|
-
│ │ ▼ │
|
|
39
|
-
│ └──────── 6. Validate ◀── 5. Rate ◀── 4. Mitigate │
|
|
40
|
-
│ & Iterate Threats Threats │
|
|
41
|
-
└──────────────────────────────────────────────────────────┘
|
|
42
|
-
```
|
|
30
|
+

|
|
43
31
|
|
|
44
32
|
### 1.2. Khi nào cần Threat Modeling?
|
|
45
33
|
|
|
@@ -68,58 +56,46 @@ STRIDE là framework phân loại threats do Microsoft phát triển:
|
|
|
68
56
|
|
|
69
57
|
#### S - Spoofing (Giả mạo danh tính)
|
|
70
58
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
│ → Reduce token theft window │
|
|
91
|
-
│ │
|
|
92
|
-
│ M3: DPoP (Proof-of-Possession) │
|
|
93
|
-
│ → Token bound to client certificate │
|
|
94
|
-
│ │
|
|
95
|
-
│ M4: Refresh token rotation │
|
|
96
|
-
│ → One-time use refresh tokens │
|
|
97
|
-
│ │
|
|
98
|
-
│ M5: mTLS between services │
|
|
99
|
-
│ → Service identity verification │
|
|
100
|
-
└────────────────────────────────────────────┘
|
|
101
|
-
```
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+
**Threat:** Attacker giả mạo JWT token để truy cập Patient API
|
|
62
|
+
|
|
63
|
+
**Attack Vector:**
|
|
64
|
+
|
|
65
|
+
1. Steal JWT từ browser localStorage
|
|
66
|
+
2. Forge JWT với modified claims (role: "admin")
|
|
67
|
+
3. Replay expired token
|
|
68
|
+
|
|
69
|
+
**Affected Components:** API Gateway, Patient Service, Clinical Service
|
|
70
|
+
|
|
71
|
+
**Mitigations:**
|
|
72
|
+
|
|
73
|
+
- **M1:** Keycloak OIDC token validation — quarkus-oidc auto-verifies signature
|
|
74
|
+
- **M2:** Short-lived access tokens (5 min) — giảm token theft window
|
|
75
|
+
- **M3:** DPoP (Proof-of-Possession) — token bound to client certificate
|
|
76
|
+
- **M4:** Refresh token rotation — one-time use refresh tokens
|
|
77
|
+
- **M5:** mTLS between services — service identity verification
|
|
102
78
|
|
|
103
79
|
#### T - Tampering (Giả mạo dữ liệu)
|
|
104
80
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
81
|
+

|
|
82
|
+
|
|
83
|
+
**Threat:** Insider sửa đổi kết quả xét nghiệm trong lab_db
|
|
84
|
+
|
|
85
|
+
**Attack Vector:**
|
|
86
|
+
|
|
87
|
+
1. DBA trực tiếp UPDATE lab_results table
|
|
88
|
+
2. Khai thác SQL injection để sửa dữ liệu
|
|
89
|
+
3. Intercept và modify API response
|
|
90
|
+
|
|
91
|
+
**Mitigations:**
|
|
92
|
+
|
|
93
|
+
- **M1:** pgAudit logging (log all DML)
|
|
94
|
+
- **M2:** Database triggers cho change tracking
|
|
95
|
+
- **M3:** Digital signatures cho lab results
|
|
96
|
+
- **M4:** Immutable audit log (append-only)
|
|
97
|
+
- **M5:** Dual control cho critical changes
|
|
98
|
+
- **M6:** Row versioning with checksums
|
|
123
99
|
|
|
124
100
|
```sql
|
|
125
101
|
-- Integrity protection: Row versioning with checksum
|
|
@@ -227,25 +203,25 @@ public PatientSummaryDTO getPatient(@PathParam("id") UUID id) {
|
|
|
227
203
|
|
|
228
204
|
#### D - Denial of Service
|
|
229
205
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
206
|
+

|
|
207
|
+
|
|
208
|
+
**Threat:** Tấn công DDoS khiến hệ thống cấp cứu ngừng hoạt động
|
|
209
|
+
|
|
210
|
+
**Impact trong Y Tế:**
|
|
211
|
+
|
|
212
|
+
- Không thể tra cứu dị ứng thuốc → kê đơn sai → nguy hiểm
|
|
213
|
+
- Không truy cập được lab results → chẩn đoán chậm
|
|
214
|
+
- Hệ thống đặt lịch down → bệnh nhân không thể đến khám
|
|
215
|
+
|
|
216
|
+
**Mitigations:**
|
|
217
|
+
|
|
218
|
+
- **M1:** Rate limiting at API Gateway
|
|
219
|
+
- **M2:** Circuit breaker (Quarkus Fault Tolerance)
|
|
220
|
+
- **M3:** Auto-scaling Kubernetes pods
|
|
221
|
+
- **M4:** CDN/WAF (Cloudflare, AWS Shield)
|
|
222
|
+
- **M5:** Database connection pooling
|
|
223
|
+
- **M6:** Fallback mode / offline capability
|
|
224
|
+
- **M7:** Priority queuing for ER requests
|
|
249
225
|
|
|
250
226
|
#### E - Elevation of Privilege
|
|
251
227
|
|
|
@@ -349,39 +325,28 @@ public class PrescriptionResource {
|
|
|
349
325
|
|
|
350
326
|
### 5.1. Attack Tree: Steal Patient Medical Records
|
|
351
327
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
│ │ └── 2.1.3 Doctor accesses non-patient [DREAD: 6.0]
|
|
375
|
-
│ │
|
|
376
|
-
│ └── 2.2 Stolen Credentials
|
|
377
|
-
│ ├── 2.2.1 Shared workstation session [DREAD: 6.2]
|
|
378
|
-
│ └── 2.2.2 Post-it password [DREAD: 5.0]
|
|
379
|
-
│
|
|
380
|
-
└── 3. Supply Chain Attack
|
|
381
|
-
├── 3.1 Compromised dependency [DREAD: 7.8]
|
|
382
|
-
├── 3.2 Malicious Docker image [DREAD: 6.4]
|
|
383
|
-
└── 3.3 Compromised CI/CD pipeline [DREAD: 7.0]
|
|
384
|
-
```
|
|
328
|
+

|
|
329
|
+
|
|
330
|
+
**Goal: Steal Patient Medical Records**
|
|
331
|
+
|
|
332
|
+
| Attack Path | DREAD | Priority |
|
|
333
|
+
|---|---|---|
|
|
334
|
+
| 1.1.1 SQL Injection | 8.6 | CRITICAL |
|
|
335
|
+
| 1.1.2 XSS to steal session | 7.2 | HIGH |
|
|
336
|
+
| 1.1.3 IDOR to access other patients | 7.0 | HIGH |
|
|
337
|
+
| 1.2.1 Credential stuffing | 5.4 | MEDIUM |
|
|
338
|
+
| 1.2.2 Phishing doctor credentials | 6.8 | HIGH |
|
|
339
|
+
| 1.2.3 Brute force Keycloak | 3.2 | LOW |
|
|
340
|
+
| 1.3.1 MITM on API calls | 4.6 | MEDIUM |
|
|
341
|
+
| 1.3.2 DNS spoofing | 4.2 | MEDIUM |
|
|
342
|
+
| 2.1.1 DBA exports database | 6.8 | HIGH |
|
|
343
|
+
| 2.1.2 Admin disables audit | 5.6 | MEDIUM |
|
|
344
|
+
| 2.1.3 Doctor accesses non-patient | 6.0 | MEDIUM |
|
|
345
|
+
| 2.2.1 Shared workstation session | 6.2 | MEDIUM |
|
|
346
|
+
| 2.2.2 Post-it password | 5.0 | MEDIUM |
|
|
347
|
+
| 3.1 Compromised dependency | 7.8 | HIGH |
|
|
348
|
+
| 3.2 Malicious Docker image | 6.4 | HIGH |
|
|
349
|
+
| 3.3 Compromised CI/CD pipeline | 7.0 | HIGH |
|
|
385
350
|
|
|
386
351
|
## 6. Từ Threat Model đến Security Requirements
|
|
387
352
|
|
|
@@ -26,46 +26,13 @@ course:
|
|
|
26
26
|
|
|
27
27
|
Khi xây dựng hệ thống y tế cho nhiều bệnh viện/phòng khám, có 3 chiến lược:
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
│ │ Realm │ │ Realm │ │ Realm │ │
|
|
37
|
-
│ └──────────┘ └──────────┘ └──────────┘ │
|
|
38
|
-
│ → Isolated users, roles, clients │
|
|
39
|
-
│ → Best for: Independent hospitals │
|
|
40
|
-
└───────────────────────────────────────────┘
|
|
41
|
-
|
|
42
|
-
Strategy B: Shared Realm + Organizations (Keycloak 26+)
|
|
43
|
-
┌───────────────────────────────────────────┐
|
|
44
|
-
│ Keycloak Instance │
|
|
45
|
-
│ ┌──────────────────────────────────────┐ │
|
|
46
|
-
│ │ Healthcare Realm │ │
|
|
47
|
-
│ │ ┌─────────┐ ┌─────────┐ ┌────────┐ │ │
|
|
48
|
-
│ │ │ Org: │ │ Org: │ │ Org: │ │ │
|
|
49
|
-
│ │ │ BV CR │ │ BV BD │ │ BV ND │ │ │
|
|
50
|
-
│ │ └─────────┘ └─────────┘ └────────┘ │ │
|
|
51
|
-
│ │ → Shared identity + org isolation │ │
|
|
52
|
-
│ │ → Best for: Hospital networks │ │
|
|
53
|
-
│ └──────────────────────────────────────┘ │
|
|
54
|
-
└───────────────────────────────────────────┘
|
|
55
|
-
|
|
56
|
-
Strategy C: Shared Realm + Groups (Simple)
|
|
57
|
-
┌───────────────────────────────────────────┐
|
|
58
|
-
│ Keycloak Instance │
|
|
59
|
-
│ ┌──────────────────────────────────────┐ │
|
|
60
|
-
│ │ Healthcare Realm │ │
|
|
61
|
-
│ │ Groups: /hospitals/bv-cho-ray │ │
|
|
62
|
-
│ │ /hospitals/bv-binh-dan │ │
|
|
63
|
-
│ │ /hospitals/bv-nhan-dan │ │
|
|
64
|
-
│ │ → Simple, less isolation │ │
|
|
65
|
-
│ │ → Best for: Small clinic networks │ │
|
|
66
|
-
│ └──────────────────────────────────────┘ │
|
|
67
|
-
└───────────────────────────────────────────┘
|
|
68
|
-
```
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
| Strategy | Mô hình | Isolation | Phù hợp |
|
|
32
|
+
|----------|---------|-----------|----------|
|
|
33
|
+
| **A: Realm per Hospital** | Mỗi bệnh viện 1 Realm riêng | Cao nhất — isolated users, roles, clients | Bệnh viện độc lập |
|
|
34
|
+
| **B: Shared Realm + Organizations** | 1 Healthcare Realm, mỗi BV là 1 Organization | Trung bình — shared identity + org isolation | Chuỗi bệnh viện, Sở Y tế |
|
|
35
|
+
| **C: Shared Realm + Groups** | 1 Realm, phân chia bằng Groups | Thấp — simple, less isolation | Phòng khám nhỏ |
|
|
69
36
|
|
|
70
37
|
### 1.2. Khuyến nghị cho Y Tế Việt Nam
|
|
71
38
|
|
|
@@ -143,29 +110,23 @@ Strategy C: Shared Realm + Groups (Simple)
|
|
|
143
110
|
|
|
144
111
|
### 3.1. Clients Overview
|
|
145
112
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
│ audit-service │ Confidential│ Audit/Logging │
|
|
164
|
-
│ api-gateway │ Confidential│ Kong/APISIX │
|
|
165
|
-
│ admin-cli │ Confidential│ Admin Operations │
|
|
166
|
-
│ fhir-server │ Confidential│ HAPI FHIR Server │
|
|
167
|
-
└─────────────────────┴─────────────┴─────────────────┘
|
|
168
|
-
```
|
|
113
|
+
| Client | Type | Description |
|
|
114
|
+
|--------|------|-------------|
|
|
115
|
+
| his-web-app | Public | HIS Web Frontend |
|
|
116
|
+
| emr-web-app | Public | EMR Web Frontend |
|
|
117
|
+
| patient-portal | Public | Patient Portal |
|
|
118
|
+
| mobile-doctor-app | Public | Doctor Mobile App |
|
|
119
|
+
| patient-service | Confidential | Patient API |
|
|
120
|
+
| clinical-service | Confidential | Clinical API |
|
|
121
|
+
| lab-service | Confidential | Lab Results API |
|
|
122
|
+
| pharmacy-service | Confidential | Pharmacy API |
|
|
123
|
+
| scheduling-service | Confidential | Scheduling API |
|
|
124
|
+
| billing-service | Confidential | Billing API |
|
|
125
|
+
| notification-service | Confidential | Notifications |
|
|
126
|
+
| audit-service | Confidential | Audit/Logging |
|
|
127
|
+
| api-gateway | Confidential | Kong/APISIX |
|
|
128
|
+
| admin-cli | Confidential | Admin Operations |
|
|
129
|
+
| fhir-server | Confidential | HAPI FHIR Server |
|
|
169
130
|
|
|
170
131
|
### 3.2. Patient Portal Client (Public)
|
|
171
132
|
|
|
@@ -400,27 +361,15 @@ Realm Roles:
|
|
|
400
361
|
|
|
401
362
|
### 6.2. Shared Workstation Support
|
|
402
363
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
├──────────────────────────────────────────────┤
|
|
413
|
-
│ Option 2: Auto-logoff + Quick re-auth │
|
|
414
|
-
│ → Session timeout 10-15 min + PIN │
|
|
415
|
-
│ → Pro: Simple, no hardware needed │
|
|
416
|
-
│ → Con: Slower than badge │
|
|
417
|
-
├──────────────────────────────────────────────┤
|
|
418
|
-
│ Option 3: Virtual Desktop (VDI) │
|
|
419
|
-
│ → Each user has own virtual desktop │
|
|
420
|
-
│ → Pro: Full isolation │
|
|
421
|
-
│ → Con: Expensive, higher latency │
|
|
422
|
-
└──────────────────────────────────────────────┘
|
|
423
|
-
```
|
|
364
|
+
Bệnh viện thường có shared workstations — nhiều bác sĩ/y tá dùng chung 1 máy tính. Giải pháp:
|
|
365
|
+
|
|
366
|
+

|
|
367
|
+
|
|
368
|
+
| Option | Cơ chế | Ưu điểm | Hạn chế |
|
|
369
|
+
|--------|---------|---------|----------|
|
|
370
|
+
| **1. Fast User Switching** | Keycloak short session + badge login | Nhanh, tiện lợi | Cần infrastructure (badge reader) |
|
|
371
|
+
| **2. Auto-logoff + Quick re-auth** | Session timeout 10-15 min + PIN | Simple, no hardware needed | Chậm hơn badge |
|
|
372
|
+
| **3. Virtual Desktop (VDI)** | Mỗi user 1 virtual desktop riêng | Full isolation | Đắt, higher latency |
|
|
424
373
|
|
|
425
374
|
## 7. Realm Export/Import Automation
|
|
426
375
|
|
|
@@ -23,7 +23,6 @@ course:
|
|
|
23
23
|
|
|
24
24
|

|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
### 1.1. Role-Based Access Control (RBAC)
|
|
28
27
|
|
|
29
28
|
RBAC gán quyền dựa trên **vai trò** của người dùng trong tổ chức:
|
|
@@ -58,28 +57,12 @@ Policy: ALLOW if
|
|
|
58
57
|
|
|
59
58
|
### 1.3. Kết hợp RBAC + ABAC cho Y Tế
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
│ ├── Is user a nurse? → Can access vital signs │
|
|
68
|
-
│ └── Is user a patient? → Can access own records │
|
|
69
|
-
│ │
|
|
70
|
-
│ Layer 2: ABAC (Keycloak Authorization Services) │
|
|
71
|
-
│ ├── Department match? → Only own department data │
|
|
72
|
-
│ ├── Treatment relationship? → Assigned patients only │
|
|
73
|
-
│ ├── Time-based? → After-hours requires MFA │
|
|
74
|
-
│ └── Location-based? → External requires VPN │
|
|
75
|
-
│ │
|
|
76
|
-
│ Layer 3: RLS (PostgreSQL Row-Level Security) │
|
|
77
|
-
│ └── Database enforces per-row access based on JWT │
|
|
78
|
-
│ │
|
|
79
|
-
│ Layer 4: Consent (Patient consent check) │
|
|
80
|
-
│ └── Patient has granted access for this purpose? │
|
|
81
|
-
└──────────────────────────────────────────────────────┘
|
|
82
|
-
```
|
|
60
|
+
| Layer | Tên | Cơ chế | Ví dụ |
|
|
61
|
+
|-------|-----|---------|--------|
|
|
62
|
+
| **Layer 1** | RBAC (Keycloak Roles) | Is user a doctor? → Can access clinical data. Is user a nurse? → Can access vital signs. Is user a patient? → Can access own records. | `@RolesAllowed("doctor")` |
|
|
63
|
+
| **Layer 2** | ABAC (Keycloak Authorization Services) | Department match? → Only own department data. Treatment relationship? → Assigned patients only. Time-based? → After-hours requires MFA. Location-based? → External requires VPN. | Custom policies |
|
|
64
|
+
| **Layer 3** | RLS (PostgreSQL Row-Level Security) | Database enforces per-row access based on JWT claims | `CREATE POLICY` |
|
|
65
|
+
| **Layer 4** | Consent (Patient consent check) | Patient has granted access for this purpose? | FHIR Consent resource |
|
|
83
66
|
|
|
84
67
|
## 2. Keycloak Authorization Services
|
|
85
68
|
|
|
@@ -23,7 +23,6 @@ course:
|
|
|
23
23
|
|
|
24
24
|

|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
### 1.1. SMART là gì?
|
|
28
27
|
|
|
29
28
|
**SMART (Substitutable Medical Applications, Reusable Technologies)** on FHIR là một tiêu chuẩn mở cho phép các ứng dụng third-party truy cập dữ liệu y tế một cách an toàn thông qua FHIR APIs. SMART định nghĩa:
|
|
@@ -35,41 +34,31 @@ course:
|
|
|
35
34
|
|
|
36
35
|
### 1.2. SMART App Launch Flows
|
|
37
36
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
┌──────────────────────────────────────────────────────┐
|
|
64
|
-
│ Backend Services Authorization │
|
|
65
|
-
│ │
|
|
66
|
-
│ 1. Service authenticates with signed JWT assertion │
|
|
67
|
-
│ 2. Keycloak validates JWT and issues access token │
|
|
68
|
-
│ 3. Service accesses FHIR resources │
|
|
69
|
-
│ → No user interaction required │
|
|
70
|
-
│ → Used for: data sync, analytics, reporting │
|
|
71
|
-
└──────────────────────────────────────────────────────┘
|
|
72
|
-
```
|
|
37
|
+
**EHR Launch Flow:**
|
|
38
|
+
|
|
39
|
+
1. User clicks "Launch App" in EHR
|
|
40
|
+
2. EHR sends launch request with context (patient ID, encounter ID)
|
|
41
|
+
3. App redirects to Authorization Server (Keycloak)
|
|
42
|
+
4. User authenticates (or SSO)
|
|
43
|
+
5. Keycloak issues access token with SMART scopes
|
|
44
|
+
6. App uses token to access FHIR resources
|
|
45
|
+
|
|
46
|
+
**Standalone Launch Flow:**
|
|
47
|
+
|
|
48
|
+
1. User opens app directly (e.g., mobile app)
|
|
49
|
+
2. App redirects to Keycloak for authentication
|
|
50
|
+
3. User authenticates with credentials + MFA
|
|
51
|
+
4. App requests SMART scopes
|
|
52
|
+
5. If patient context needed → patient picker
|
|
53
|
+
6. Keycloak issues access token
|
|
54
|
+
7. App accesses FHIR resources
|
|
55
|
+
|
|
56
|
+
**Backend Services Authorization:**
|
|
57
|
+
|
|
58
|
+
1. Service authenticates with signed JWT assertion
|
|
59
|
+
2. Keycloak validates JWT and issues access token
|
|
60
|
+
3. Service accesses FHIR resources
|
|
61
|
+
→ No user interaction required. Used for: data sync, analytics, reporting.
|
|
73
62
|
|
|
74
63
|
## 2. SMART Scopes
|
|
75
64
|
|
|
@@ -23,7 +23,6 @@ course:
|
|
|
23
23
|
|
|
24
24
|

|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
### 1.1. Thách thức MFA trong Bệnh viện
|
|
28
27
|
|
|
29
28
|
Bệnh viện có môi trường vận hành đặc biệt so với doanh nghiệp thông thường:
|
|
@@ -38,28 +37,13 @@ Bệnh viện có môi trường vận hành đặc biệt so với doanh nghi
|
|
|
38
37
|
|
|
39
38
|
### 1.2. MFA Factor Matrix
|
|
40
39
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
│ │ WebAuthn │ │ │
|
|
49
|
-
├──────────────┼───────────┼────────────┼──────────────────┤
|
|
50
|
-
│ Nurse │ Proximity │ PIN (6 │ TOTP App │
|
|
51
|
-
│ │ Badge │ digits) │ │
|
|
52
|
-
├──────────────┼───────────┼────────────┼──────────────────┤
|
|
53
|
-
│ Lab Tech │ TOTP App │ Security │ Recovery codes │
|
|
54
|
-
│ │ │ Key │ │
|
|
55
|
-
├──────────────┼───────────┼────────────┼──────────────────┤
|
|
56
|
-
│ Admin │ Security │ TOTP App │ Admin recovery │
|
|
57
|
-
│ │ Key │ │ procedure │
|
|
58
|
-
├──────────────┼───────────┼────────────┼──────────────────┤
|
|
59
|
-
│ Patient │ SMS OTP │ Email OTP │ Support call │
|
|
60
|
-
│ Portal │ │ │ │
|
|
61
|
-
└──────────────┴───────────┴────────────┴──────────────────┘
|
|
62
|
-
```
|
|
40
|
+
| User Type | Primary | Secondary | Fallback |
|
|
41
|
+
|-----------|---------|-----------|----------|
|
|
42
|
+
| **Doctor** | Passkey / WebAuthn | TOTP App | Recovery codes |
|
|
43
|
+
| **Nurse** | Proximity Badge | PIN (6 digits) | TOTP App |
|
|
44
|
+
| **Lab Tech** | TOTP App | Security Key | Recovery codes |
|
|
45
|
+
| **Admin** | Security Key | TOTP App | Admin recovery procedure |
|
|
46
|
+
| **Patient Portal** | SMS OTP | Email OTP | Support call |
|
|
63
47
|
|
|
64
48
|
## 2. Keycloak Authentication Flow cho Y Tế
|
|
65
49
|
|