Skip to content

Commit 63a0a01

Browse files
Refactor diagrams for clarity and add setup timeline
Updated the Token Lifecycle diagram in `architecture-diagrams.md`: - Added detailed states, transitions, and explanatory notes. - Grouped related states into nested structures for readability. - Enhanced the Token Lifecycle Stages section with step-by-step details. Improved the Setup Flow Overview in `quick-start.md`: - Renamed steps for consistency and clarity. - Reorganized subgraphs with descriptive names. - Added color-coded styles for visual distinction. - Introduced a Setup Timeline summarizing configuration steps. Streamlined both diagrams by removing redundant transitions and aligning with best practices for `mermaid` syntax.
1 parent 644cd89 commit 63a0a01

2 files changed

Lines changed: 92 additions & 44 deletions

File tree

docs/authentication/architecture-diagrams.md

Lines changed: 75 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -264,67 +264,104 @@ graph TB
264264

265265
```mermaid
266266
stateDiagram-v2
267-
[*] --> Login: User Initiates Login
267+
[*] --> Login
268+
Login --> TokenIssuance
269+
TokenIssuance --> TokenStorage
270+
TokenStorage --> TokenUsage
271+
TokenUsage --> TokenRefresh
272+
TokenRefresh --> TokenUsage
273+
TokenUsage --> TokenRevocation
274+
TokenRevocation --> TokenExpiration
275+
TokenExpiration --> [*]
268276
269-
Login --> TokenIssuance: Authenticate with External ID
270-
TokenIssuance --> TokenStorage: Store Tokens Securely
277+
state Login {
278+
[*] --> UserInitiatesLogin
279+
}
271280
272281
state TokenIssuance {
273-
[*] --> IDToken: ID Token (User Identity)
274-
[*] --> AccessToken: Access Token (API Authorization)
275-
[*] --> RefreshToken: Refresh Token (Long-lived)
282+
[*] --> IDToken
283+
[*] --> AccessToken
284+
[*] --> RefreshToken
276285
}
277286
278287
state TokenStorage {
279-
[*] --> WebStorage: Web: HttpOnly Cookies/SessionStorage
280-
[*] --> DesktopStorage: Desktop: Encrypted Cache (DPAPI/Keychain)
288+
[*] --> WebStorage
289+
[*] --> DesktopStorage
281290
}
282291
283-
TokenStorage --> TokenUsage: Attach to API Requests
284-
285292
state TokenUsage {
286-
[*] --> RequestHeader: Authorization: Bearer <access_token>
287-
RequestHeader --> GatewayValidation: Gateway Validates Token
288-
289-
state GatewayValidation {
290-
[*] --> VerifySignature: Verify Signature (Public Key)
291-
VerifySignature --> CheckExpiration: Check Expiration (nbf, exp)
292-
CheckExpiration --> ValidateIssuer: Validate Issuer (iss)
293-
ValidateIssuer --> ValidateAudience: Validate Audience (aud)
294-
}
295-
296-
GatewayValidation --> ProcessRequest: Forward to Backend
293+
[*] --> RequestHeader
294+
RequestHeader --> GatewayValidation
295+
GatewayValidation --> ProcessRequest
297296
}
298297
299-
TokenUsage --> TokenRefresh: Before Expiration
298+
state GatewayValidation {
299+
[*] --> VerifySignature
300+
VerifySignature --> CheckExpiration
301+
CheckExpiration --> ValidateIssuer
302+
ValidateIssuer --> ValidateAudience
303+
}
300304
301305
state TokenRefresh {
302-
[*] --> SilentAcquisition: Try Silent Token Acquisition
303-
SilentAcquisition --> UseRefreshToken: Use Refresh Token if Needed
304-
UseRefreshToken --> ReAuthenticate: Re-authenticate if Refresh Fails
306+
[*] --> SilentAcquisition
307+
SilentAcquisition --> UseRefreshToken
308+
UseRefreshToken --> ReAuthenticate
305309
}
306310
307-
TokenRefresh --> TokenUsage: Continue with New Token
308-
309-
TokenUsage --> TokenRevocation: User Logout
310-
311311
state TokenRevocation {
312-
[*] --> ClearCache: Remove from Client Cache
313-
ClearCache --> ClearSession: Clear Session
314-
ClearSession --> SignOutEndpoint: Redirect to Sign-out Endpoint
312+
[*] --> ClearCache
313+
ClearCache --> ClearSession
314+
ClearSession --> SignOutEndpoint
315315
}
316316
317-
TokenRevocation --> TokenExpiration: Token Becomes Invalid
318-
319317
state TokenExpiration {
320-
[*] --> NaturalExpiration: Natural Expiration (1 hour)
321-
[*] --> ManualRevocation: Manual Revocation
322-
[*] --> SignOut: User Sign-out
318+
[*] --> NaturalExpiration
319+
[*] --> ManualRevocation
320+
[*] --> SignOut
323321
}
324322
325-
TokenExpiration --> [*]
323+
note right of Login
324+
User clicks login button
325+
or visits protected resource
326+
end note
327+
328+
note right of TokenIssuance
329+
ID Token: User identity claims
330+
Access Token: API authorization
331+
Refresh Token: Long-lived renewal
332+
end note
333+
334+
note right of TokenStorage
335+
Web: HttpOnly cookies or SessionStorage
336+
Desktop: Encrypted cache (DPAPI/Keychain)
337+
end note
338+
339+
note right of TokenUsage
340+
Authorization: Bearer access_token
341+
Gateway validates all requests
342+
end note
343+
344+
note right of TokenRefresh
345+
Before expiration (typically 1 hour)
346+
Silent refresh when possible
347+
end note
348+
349+
note right of TokenRevocation
350+
User logout or security event
351+
Clear all cached tokens
352+
end note
326353
```
327354

355+
**Token Lifecycle Stages:**
356+
357+
1. **Login**: User initiates authentication with Microsoft Entra External ID
358+
2. **Token Issuance**: External ID returns ID, Access, and Refresh tokens
359+
3. **Token Storage**: Secure storage based on platform (web vs desktop)
360+
4. **Token Usage**: Tokens attached to API requests for authorization
361+
5. **Token Refresh**: Silent renewal before expiration using refresh tokens
362+
6. **Token Revocation**: Manual logout or automatic cleanup
363+
7. **Token Expiration**: Natural expiration or forced invalidation
364+
328365
## Comparison: Azure AD B2C vs Microsoft Entra External ID
329366

330367
```mermaid

docs/authentication/quick-start.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,24 +73,24 @@ var app = PublicClientApplicationBuilder
7373

7474
```mermaid
7575
flowchart TD
76-
Start[Start Setup] --> Azure[1. Azure Portal Setup<br/>2 minutes]
77-
Azure --> Gateway[2. Gateway Configuration<br/>1 minute]
78-
Gateway --> Client[3. Client Configuration<br/>2 minutes]
76+
Start[Start Setup] --> Azure[Step 1: Azure Portal Setup<br/>2 minutes]
77+
Azure --> Gateway[Step 2: Gateway Configuration<br/>1 minute]
78+
Gateway --> Client[Step 3: Client Configuration<br/>2 minutes]
7979
Client --> Test[Test Implementation]
8080
81-
subgraph "Azure Setup"
81+
subgraph "Azure Setup Steps"
8282
CreateApp[Create App Registration]
8383
GetIDs[Get Client ID & Tenant ID]
8484
CreateApp --> GetIDs
8585
end
8686
87-
subgraph "Gateway Setup"
87+
subgraph "Gateway Setup Steps"
8888
AppSettings[Update appsettings.json]
8989
ProgramCS[Configure Program.cs]
9090
AppSettings --> ProgramCS
9191
end
9292
93-
subgraph "Client Setup"
93+
subgraph "Client Setup Steps"
9494
BlazorConfig[Blazor WASM Config]
9595
DesktopConfig[WPF/MAUI Config]
9696
end
@@ -99,8 +99,19 @@ flowchart TD
9999
Gateway -.-> AppSettings
100100
Client -.-> BlazorConfig
101101
Client -.-> DesktopConfig
102+
103+
style Azure fill:#e3f2fd
104+
style Gateway fill:#e8f5e8
105+
style Client fill:#fff3e0
106+
style Test fill:#f3e5f5
102107
```
103108

109+
**Setup Timeline:**
110+
- **Step 1**: Azure Portal Setup (2 minutes)
111+
- **Step 2**: Gateway Configuration (1 minute)
112+
- **Step 3**: Client Configuration (2 minutes)
113+
- **Total**: ~5 minutes
114+
104115
## Common Configuration Patterns
105116

106117
### Pattern 1: Gateway Only Authentication

0 commit comments

Comments
 (0)