Skip to content

Commit 5dccc02

Browse files
docs: add Flow C and Flow D documentation for self-service profile updates and social identity linking; remove outdated SPA flow documentation; update README with architecture changes
Jira Ticket: https://linuxfoundation.atlassian.net/browse/LFXV2-888 Assisted by [Claude Code](https://claude.ai/code) Signed-off-by: Mauricio Zanetti Salomao <mauriciozanetti86@gmail.com>
1 parent fc70924 commit 5dccc02

File tree

6 files changed

+92
-86
lines changed

6 files changed

+92
-86
lines changed

docs/auth-flows/C-spa-profile-update-oidc.md renamed to docs/auth-flows/C-profile-update.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# Flow C: Self-Service Profile Update via SPA OIDC for Management API audience ('self' Auth0 access)
1+
# Flow C: Self-Service Profile Update via Regular Web Client
22

33
## Description
4-
OpenID Connect (OIDC) flow for the Auth0 Management API audience, allowing users to manage their own profiles (self Auth0 access). This flow shares the same client used by Flow D’s SPA client.
4+
Flow for the Auth0 Management API audience, allowing users to manage their own profiles ("self" Auth0 access). This flow uses the LFX One Profile Client (regular web application) and implements a dual authentication pattern where users first authenticate with the main LFX One client, then obtain additional access tokens for Management API access.
55

66
## Sequence Diagram
77

@@ -14,7 +14,7 @@ sequenceDiagram
1414
participant Auth0 as Auth0 Authentication API
1515
participant Auth0Mgmt as Auth0 Management API
1616
17-
Note over User,Auth0Mgmt: Flow C: 2nd OIDC flow for Management API audience<br/>("self" Auth0 access)
17+
Note over User,Auth0Mgmt: Flow C: Secondary authentication flow for Management API audience<br/>("self" Auth0 access)
1818
1919
User->>SSR: Request to update own profile
2020
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Flow D: Link Social Identity via Regular Web Client (No Audience)
2+
3+
## Description
4+
Regular web client flow for linking social identities by authenticating with the social provider. Uses the LFX One Profile Client and access_token_mgmt_self from Flow C (Management API token) to perform the actual linking operation. This flow uses server-side redirects instead of popup/webmessage pattern.
5+
6+
## Sequence Diagram
7+
8+
```mermaid
9+
sequenceDiagram
10+
participant Browser as User Browser
11+
participant SSR as LFX One SSR
12+
participant Auth0 as Auth0 Authentication API
13+
participant NATS as NATS
14+
participant AuthSvc as Auth Service
15+
participant Auth0Mgmt as Auth0 Management API
16+
17+
Note over Browser,Auth0Mgmt: Flow D: Link social identity via regular web client<br/>(no audience - just authenticate with social provider)
18+
19+
Browser->>SSR: User clicks "Link Google"<br/>(or other social provider)
20+
21+
SSR->>Auth0: D1: GET /authorize<br/>w/ "LFX One Profile" client<br/>response_type=code<br/>[NO audience]<br/>connection=google-oauth2<br/>redirect_uri=SSR_callback
22+
23+
Auth0->>Browser: Present social provider<br/>authentication
24+
25+
Browser->>Auth0: User authenticates with<br/>social provider
26+
27+
Auth0->>SSR: D2: Redirect with auth_code
28+
29+
SSR->>Auth0: D3: POST /oauth2/token<br/>[authorization_code grant]<br/>w/ "LFX One Profile" client credentials<br/>+ auth_code<br/>[NO audience]
30+
31+
Auth0-->>SSR: D4: access_token_social<br/>for /userinfo (IGNORE) +<br/>id_token_social
32+
33+
Note over SSR: SSR uses<br/>access_token_mgmt_self from Flow C<br/>(Management API token)
34+
35+
SSR->>NATS: D5: Publish link request<br/>with access_token_mgmt_self + id_token_social
36+
Note over NATS,AuthSvc: Auth Service subscribed to NATS subject
37+
NATS->>AuthSvc: Deliver request
38+
39+
AuthSvc->>Auth0Mgmt: Link social identity<br/>using access_token_mgmt_self<br/>w/ id_token_social claims
40+
41+
Auth0Mgmt-->>AuthSvc: Identity linked successfully
42+
AuthSvc->>NATS: Publish response
43+
NATS->>SSR: Deliver response
44+
45+
SSR-->>Browser: Update UI with<br/>newly linked identity
46+
47+
Note over Browser,Auth0Mgmt: Auth Service abstracts all Auth0 Management API calls
48+
```

docs/auth-flows/D-spa-social-identity-linking.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

docs/auth-flows/E-passwordless-email-linking.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
# Flow E: Link Email Identity via Passwordless
22

33
## Description
4-
SPA/SSR flow for linking additional email addresses to a user's account using passwordless authentication. All Auth0 API calls (both passwordless and Management API) are made by Auth Service, with SSR communicating via NATS pub/sub pattern. Uses access_token_mgmt_self from Flow C (Management API token) to perform the actual linking operation. The user verifies ownership of the email by entering a one-time verification code in LFX One.
4+
SSR flow for linking additional email addresses to a user's account using passwordless authentication. Uses the LFX One Profile Client for the passwordless OTP flow. All Auth0 API calls (both passwordless and Management API) are made by Auth Service, with SSR communicating via NATS pub/sub pattern. Uses access_token_mgmt_self from Flow C (Management API token) to perform the actual linking operation. The user verifies ownership of the email by entering a one-time verification code in LFX One.
55

66
## Sequence Diagram
77

88
```mermaid
99
sequenceDiagram
10-
participant Browser as User Browser/SPA
10+
participant Browser as User Browser
1111
participant SSR as LFX One SSR
1212
participant NATS as NATS
1313
participant AuthSvc as Auth Service
1414
participant Auth0 as Auth0 Authentication API
1515
participant MUA as Mail User Agent
1616
participant Auth0Mgmt as Auth0 Management API
1717
18-
Note over Browser,Auth0Mgmt: Flow E: Link email identity via passwordless<br/>(email verification with OTP code)
18+
Note over Browser,Auth0Mgmt: Flow E: Link email identity via passwordless<br/>(email verification with OTP code using LFX One Profile Client)
1919
2020
Browser->>SSR: User clicks "Add Email"<br/>and enters new email address
2121
2222
SSR->>NATS: E1: Publish passwordless<br/>start request with email
2323
Note over NATS,AuthSvc: Auth Service subscribed to NATS subject
2424
NATS->>AuthSvc: Deliver request
2525
26-
AuthSvc->>Auth0: E2: POST /passwordless/start<br/>w/ "LFX One Passwordless" client credentials<br/>email=new_email@example.com<br/>connection=email<br/>send=code
26+
AuthSvc->>Auth0: E2: POST /passwordless/start<br/>w/ "LFX One Profile" client credentials<br/>email=new_email@example.com<br/>connection=email<br/>send=code
2727
2828
Auth0->>MUA: Send verification code
2929
@@ -41,7 +41,7 @@ sequenceDiagram
4141
SSR->>NATS: E3: Publish verification request<br/>with code + access_token_mgmt_self
4242
NATS->>AuthSvc: Deliver request
4343
44-
AuthSvc->>Auth0: E4: POST /oauth2/token<br/>[passwordless grant]<br/>w/ "LFX One Passwordless" client credentials<br/>username=new_email@example.com<br/>otp=verification_code<br/>[NO audience]
44+
AuthSvc->>Auth0: E4: POST /oauth2/token<br/>[passwordless grant]<br/>w/ "LFX One Profile" client credentials<br/>username=new_email@example.com<br/>otp=verification_code<br/>[NO audience]
4545
4646
Auth0-->>AuthSvc: E5: access_token_pwdless<br/>for /userinfo (IGNORE) +<br/>id_token_pwdless
4747

docs/auth-flows/README.md

Lines changed: 36 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ This directory contains sequence diagrams documenting the authentication flows u
77
The authentication architecture uses multiple Auth0 clients and flows to support different use cases:
88

99
- **LFX One Client**: Regular web application used for server-side rendering authentication with LFX v2 API access
10-
- **LFX One Profile Client**: Single Page Application (SPA) used for social account linking and self-service Auth0 access (user profile updates)
11-
- **LFX One Passwordless Client**: Regular web application used for passwordless email linking flow via Auth Service. This client supports the OTP grant type and may use different validation in the postLogin action.
10+
- **LFX One Profile Client**: Regular web application used for social account linking, self-service Auth0 access (user profile updates), and passwordless email linking. This client supports both Authorization Code flow for Management API access and OTP grant type for passwordless flows.
1211
- **LFX V2 Auth Service Client**: Machine-to-machine client used by Auth Service for reading user profiles
1312

1413
## Authentication Flows
@@ -17,20 +16,17 @@ The authentication architecture uses multiple Auth0 clients and flows to support
1716
|------|-------------|-------------|----------|---------|
1817
| [Flow A](A-auth-service-m2m-profile-lookup.md) | Auth Service M2M | Auth Service M2M | `auth0_mgmt` | Read user profiles and check email-to-username mappings |
1918
| [Flow B](B-lfx-one-login-ssr-oidc.md) | LFX One Login (SSR OIDC) | LFX One | `lfxv2` | Authenticate users and obtain access tokens for LFX v2 API |
20-
| [Flow C](C-spa-profile-update-oidc.md) | Self-Service Profile Updates | LFX One Profile | `auth0_mgmt` | Allow users to update their own profiles via Management API |
21-
| [Flow D](D-spa-social-identity-linking.md) | Social Identity Linking | LFX One Profile | None | Link social identities (Google, GitHub, etc.) to user accounts |
22-
| [Flow E](E-passwordless-email-linking.md) | Email Identity Linking | LFX One Passwordless | None | Link additional email addresses using passwordless OTP verification |
19+
| [Flow C](C-profile-update.md) | Self-Service Profile Updates | LFX One Profile | `auth0_mgmt` | Allow users to update their own profiles via Management API |
20+
| [Flow D](D-social-identity-linking.md) | Social Identity Linking | LFX One Profile | None | Link social identities (Google, GitHub, etc.) to user accounts |
21+
| [Flow E](E-passwordless-email-linking.md) | Email Identity Linking | LFX One Profile | None | Link additional email addresses using passwordless OTP verification |
2322

2423
## Client Descriptions
2524

2625
### LFX One Client
2726
The main server-side rendering client used for user authentication. This is a regular web application client that implements the authorization code flow with grant types `authorization_code` and `refresh_token` (plus `password-realm` in dev environments for Cypress testing). It obtains access tokens with the `lfxv2` audience for accessing the LFX v2 API (Traefik/Heimdall). This client is used exclusively in Flow B for the initial user login.
2827

2928
### LFX One Profile Client
30-
This client is used for social account linking and self-service Auth0 access. This is a **Single Page Application (SPA)** client (`app_type: spa`) that uses the authorization code flow with PKCE and public client authentication (no client secret). It implements the popup/webmessage flow for social identity linking and allows users to update their own profiles through the Auth0 Management API with restricted permissions (users can only modify their own data). Used in Flows C and D.
31-
32-
### LFX One Passwordless Client
33-
A specialized client used for the passwordless email linking flow, primarily by the Auth Service. This is a **regular web application** client (`app_type: regular_web`) that uses the passwordless OTP grant type (`http://auth0.com/oauth/grant-type/passwordless/otp`). This client is specifically designed for email verification flows and may use different validation logic in the postLogin action compared to other clients. Used exclusively in Flow E.
29+
A **regular web application** client (`app_type: regular_web`) used for Auth0 Management API access and passwordless flows. This client uses the authorization code flow for obtaining Management API access tokens that allow users to update their own profiles and link identities. It also supports the passwordless OTP grant type (`http://auth0.com/oauth/grant-type/passwordless/otp`) for email verification flows. This client implements a dual authentication pattern where users first authenticate with the main LFX One client, then use this client to obtain additional access tokens for specific audiences (Management API) or perform passwordless verification. Used in Flows C, D, and E.
3430

3531
### LFX V2 Auth Service M2M Client
3632
A **machine-to-machine (M2M)** client named "LFX V2 Auth Service" that uses the client credentials grant type. This client has restricted permissions with only `read:users` scope (but **not** `update:users`) for the Auth0 Management API. It is used exclusively by the Auth Service to perform read-only operations such as profile lookups and checking email-to-username mappings. Used exclusively in Flow A.
@@ -78,3 +74,34 @@ All Auth0 Management API calls are abstracted through the Auth Service, which co
7874
4. **Token Scoping**: Each access token is scoped to specific audiences and permissions
7975
5. **Abstraction Layer**: Management API calls go through Auth Service, not directly from client
8076

77+
## Architecture Changes (December 2025)
78+
79+
### Consolidation to Regular Web Clients
80+
81+
Based on the PoC implementation in `poc/2025-12-Express-Two-Audiences`, the authentication architecture has been updated to remove the SPA client and consolidate to regular web applications:
82+
83+
**Previous Architecture:**
84+
- LFX One Client (Regular Web) - Main login
85+
- LFX One Profile Client (SPA) - Management API access and social linking
86+
- LFX One Passwordless Client (Regular Web) - Email verification
87+
88+
**Updated Architecture:**
89+
- LFX One Client (Regular Web) - Main login for LFX v2 API access
90+
- LFX One Profile Client (Regular Web) - All Management API operations, social linking, and passwordless flows
91+
92+
### Dual Authentication Pattern
93+
94+
The new architecture implements a dual authentication pattern:
95+
96+
1. **Primary Authentication**: Users first authenticate with the LFX One Client to establish their session and get LFX v2 API access
97+
2. **Secondary Authentication**: When Management API access is needed, users authenticate again with the LFX One Management Client to get audience-specific tokens
98+
99+
This pattern provides better security isolation and allows for different scopes and permissions for different purposes while maintaining a unified user experience.
100+
101+
### Benefits
102+
103+
- **Simplified Architecture**: Fewer clients to manage and configure
104+
- **Better Security**: Clear separation between different token audiences
105+
- **Consistent UX**: All flows use server-side redirects instead of mixed SPA/popup patterns
106+
- **Easier Deployment**: No client-side secret management or CORS concerns
107+

internal/infrastructure/auth0/README.md

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -183,23 +183,6 @@ The email verification and linking functionality is exposed via three NATS subje
183183
- Verifies the token has the required `update:current_user_identities` scope
184184
- Uses the extracted `user_id` to make the identity linking API call with the `link_with` ID token
185185

186-
### Auth0 Configuration Requirements
187-
188-
To enable email verification, configure the following in your Auth0 tenant:
189-
190-
1. **Enable Passwordless Connection:**
191-
- Go to Authentication → Passwordless
192-
- Enable the Email connection
193-
- Configure email template for OTP delivery
194-
195-
2. **Application Configuration:**
196-
- Ensure your Auth0 application has passwordless authentication enabled
197-
- Configure callback URLs if needed
198-
199-
3. **Email Template:**
200-
- Customize the OTP email template in Authentication → Passwordless → Email
201-
- Template should include the `{{ code }}` placeholder for the 6-digit OTP
202-
203186
### Security & Rate Limiting
204187

205188
**Auth0 Security Features:**

0 commit comments

Comments
 (0)