You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-50Lines changed: 12 additions & 50 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -162,43 +162,14 @@ To retrieve user metadata, send a NATS request to the following subject:
162
162
**Subject:**`lfx.auth-service.user_metadata.read`
163
163
**Pattern:** Request/Reply
164
164
165
-
The service supports two lookup strategies based on the input format, providing both authoritative identification and convenient username-based searches.
166
-
167
-
##### Input Format and Strategy Selection
168
-
169
-
The service automatically determines the lookup strategy based on the input format:
The service takes a token and validates/retrieves user data from the target identity provider based on the `USER_REPOSITORY_TYPE` environment variable configuration.
189
166
190
167
##### Request Payload
191
168
192
-
The request payload should be a plain text identifier (no JSON wrapping required):
169
+
The request payload should be a token (no JSON wrapping required):
193
170
194
-
**Canonical Lookup:**
195
171
```
196
-
auth0|123456789
197
-
```
198
-
199
-
**Search Lookup:**
200
-
```
201
-
john.doe
172
+
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
202
173
```
203
174
204
175
##### Reply
@@ -236,35 +207,26 @@ The service returns a structured reply with user metadata:
236
207
}
237
208
```
238
209
239
-
**Error Reply (Invalid Input):**
210
+
**Error Reply (Invalid Token):**
240
211
```json
241
212
{
242
213
"success": false,
243
-
"error": "input is required"
214
+
"error": "invalid token"
244
215
}
245
216
```
246
217
247
-
##### Examples using NATS CLI
218
+
##### Example using NATS CLI
248
219
249
220
```bash
250
-
# Canonical lookup (subject identifier)
251
-
# Note: Use quotes to escape the pipe character in shell commands
-**Canonical lookups** are the preferred method for system-to-system communication
261
-
-**Search lookups** are provided for convenience and user-facing interfaces
262
-
- The pipe character (`|`) in canonical identifiers must be escaped with quotes in shell commands
263
-
- Both strategies return the same metadata format on success
264
-
- The service supports **Auth0**, **Authelia**, and **mock** repositories based on configuration
265
-
- When using mock or authelia mode, the service simulates Auth0 behavior for development and testing
266
-
- For detailed Auth0-specific behavior and limitations, see the [Auth0 Integration Documentation](internal/infrastructure/auth0/README.md)
267
-
- For detailed Authelia-specific behavior and SUB management, see the [Authelia Integration Documentation](internal/infrastructure/authelia/README.md)
226
+
- The service validates the token and extracts user information from the target identity provider
227
+
- The target identity provider is determined by the `USER_REPOSITORY_TYPE` environment variable
228
+
- For detailed Auth0-specific behavior and limitations, see: [`internal/infrastructure/auth0/README.md`](internal/infrastructure/auth0/README.md)
229
+
- For detailed Authelia-specific behavior and SUB management, see: [`internal/infrastructure/authelia/README.md`](internal/infrastructure/authelia/README.md)
Copy file name to clipboardExpand all lines: internal/infrastructure/auth0/README.md
+33-33Lines changed: 33 additions & 33 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,51 +4,51 @@ This package provides Auth0 integration for the LFX v2 Auth Service, implementin
4
4
5
5
## Overview
6
6
7
-
The Auth0 integration supports two primary lookup strategies for user metadata retrieval, providing both authoritative identification and convenient username-based searches.
7
+
The Auth0 integration takes a JWT token and validates/retrieves user data from the Auth0 identity provider. The system parses the JWT token to extract user identification information and performs lookups through the Auth0 Management API.
8
8
9
-
## User Identification Strategies
9
+
## Token Support
10
10
11
-
### Canonical Lookup Strategy (Recommended)
11
+
The Auth0 integration supports JWT (JSON Web Token) parsing to extract user identification information. When a JWT token is provided as input, the system automatically extracts the `sub` (subject) claim and uses it for user lookups.
12
12
13
-
**Format:**`<connection>|<provider_user_id>`
13
+
### JWT Token Processing
14
14
15
-
The canonical lookup is the **authoritative, standard way to identify a user**, regardless of which provider they come from. The sub (subject) identifier is the authoritative identifier that uniquely identifies a user across the entire Auth0 tenant.
15
+
**Token Format:** JWT tokens issued by Auth0
16
16
17
-
**Examples:**
18
-
*`auth0|123456789` — Auth0 Database connection user
19
-
*`google-oauth2|987654321` — Google OAuth2 user
20
-
*`github|456789123` — GitHub OAuth2 user
21
-
*`samlp|enterprise|user123` — SAML Enterprise connection user
22
-
*`linkedin|789123456` — LinkedIn OAuth2 user
23
-
24
-
**Auth0 Management API Call:**
25
-
```http
26
-
GET /api/v2/users/{sub}
17
+
**Token Structure:**
18
+
```json
19
+
{
20
+
"iss": "https://{{tenant}}.auth0.com/",
21
+
"sub": "auth0|user123",
22
+
"aud": "https://{{tenant}}.auth0.com/api/v2/",
23
+
"iat": 1759751739,
24
+
"exp": 1759755339,
25
+
"scope": "read:current_user",
26
+
"azp": "O8sQ4Jbr3At8buVR3IkrTRlejPZFWenI"
27
+
}
27
28
```
28
29
29
-
**Benefits:**
30
-
-**Authoritative**: Guaranteed unique identifier across all connections
31
-
-**Fast**: Direct lookup by primary key
32
-
-**Reliable**: No ambiguity about which user is being referenced
33
-
-**Cross-provider**: Works regardless of authentication provider
34
-
35
-
### Search Lookup Strategy (Convenience)
30
+
### Token Processing Flow
36
31
37
-
**Format:**`<username>`
32
+
1.**Token Validation**: Validates the JWT token signature and expiration
33
+
2.**Sub Extraction**: Extracts the `sub` claim from the token payload
34
+
3.**User Lookup**: Uses the extracted `sub` value for direct user lookup via Auth0 Management API
35
+
4.**Auth0 API Call**: Performs direct user lookup using the `sub` identifier
36
+
5.**User Data Retrieval**: Returns user metadata from Auth0
38
37
39
-
Username lookups are **convenience only** and help avoid connection collisions. This strategy searches for users by their username within the Username-Password-Authentication connection.
38
+
### Auth0 Management API Integration
40
39
41
-
**Examples:**
42
-
-`john.doe`
43
-
-`jane.smith`
44
-
-`developer123`
40
+
**Canonical Lookup (Recommended):**
41
+
```http
42
+
GET /api/v2/users/{sub}
43
+
```
45
44
46
-
**Auth0 Management API Call:**
45
+
**Search Lookup (Convenience):**
47
46
```http
48
47
GET /api/v2/users?q=identities.user_id:{username} AND identities.connection:Username-Password-Authentication
49
48
```
50
49
51
-
**Limitations:**
52
-
-**Connection-specific**: Only works within Username-Password-Authentication connection
53
-
-**Slower**: Requires search query instead of direct lookup
54
-
-**Limited scope**: Cannot find users from social or enterprise connections
50
+
### Important Notes
51
+
52
+
-**JWT Signature Validation**: Full JWT signature validation is performed using Auth0's public keys
53
+
-**Token Expiration**: JWT tokens are validated for expiration and freshness
54
+
-**Auth0 Management API**: Uses Auth0's Management API for user data retrieval
0 commit comments