@@ -92,6 +92,117 @@ nats request lfx.auth-service.email_to_username zephyr.stormwind@mythicaltech.io
9292
9393---
9494
95+ ### User Metadata Retrieval
96+
97+ To retrieve user metadata, send a NATS request to the following subject:
98+
99+ ** Subject:** ` lfx.auth-service.user_metadata.read `
100+ ** Pattern:** Request/Reply
101+
102+ The service supports two lookup strategies based on the input format, providing both authoritative identification and convenient username-based searches.
103+
104+ ##### Input Format and Strategy Selection
105+
106+ The service automatically determines the lookup strategy based on the input format:
107+
108+ - ** Canonical Lookup** (contains ` | ` ): ` <connection>|<provider_user_id> ` - Subject identifier
109+ - ** Search Lookup** (no ` | ` ): ` <username> ` - Convenience lookup
110+
111+ ##### Canonical Lookup Strategy (Recommended)
112+
113+ ** Format:** ` <connection>|<provider_user_id> `
114+
115+ The canonical lookup is the ** authoritative, standard way to identify a user** , regardless of which provider they come from.
116+
117+ ** Examples:** ` auth0|123456789 ` , ` google-oauth2|987654321 ` , ` samlp|my-connection|user123 `
118+
119+ ##### Search Lookup Strategy (Convenience)
120+
121+ ** Format:** ` <username> `
122+
123+ Username lookups are ** convenience only** and help avoid connection collisions within the Username-Password-Authentication connection.
124+
125+ ** Examples:** ` john.doe ` , ` jane.smith ` , ` developer123 `
126+
127+ ##### Request Payload
128+
129+ The request payload should be a plain text identifier (no JSON wrapping required):
130+
131+ ** Canonical Lookup:**
132+ ```
133+ auth0|123456789
134+ ```
135+
136+ ** Search Lookup:**
137+ ```
138+ john.doe
139+ ```
140+
141+ ##### Reply
142+
143+ The service returns a structured reply with user metadata:
144+
145+ ** Success Reply:**
146+ ``` json
147+ {
148+ "success" : true ,
149+ "data" : {
150+ "name" : " John Doe" ,
151+ "given_name" : " John" ,
152+ "family_name" : " Doe" ,
153+ "job_title" : " Software Engineer" ,
154+ "organization" : " Example Corp" ,
155+ "country" : " United States" ,
156+ "state_province" : " California" ,
157+ "city" : " San Francisco" ,
158+ "address" : " 123 Main Street" ,
159+ "postal_code" : " 94102" ,
160+ "phone_number" : " +1-555-0123" ,
161+ "t_shirt_size" : " L" ,
162+ "picture" : " https://example.com/avatar.jpg" ,
163+ "zoneinfo" : " America/Los_Angeles"
164+ }
165+ }
166+ ```
167+
168+ ** Error Reply (User Not Found):**
169+ ``` json
170+ {
171+ "success" : false ,
172+ "error" : " user not found"
173+ }
174+ ```
175+
176+ ** Error Reply (Invalid Input):**
177+ ``` json
178+ {
179+ "success" : false ,
180+ "error" : " input is required"
181+ }
182+ ```
183+
184+ ##### Examples using NATS CLI
185+
186+ ``` bash
187+ # Canonical lookup (subject identifier)
188+ # Note: Use quotes to escape the pipe character in shell commands
189+ nats request lfx.auth-service.user_metadata.read " auth0|123456789"
190+
191+ # Search lookup (convenience username lookup)
192+ nats request lfx.auth-service.user_metadata.read john.doe
193+
194+ ```
195+
196+ ** Important Notes:**
197+ - ** Canonical lookups** are the preferred method for system-to-system communication
198+ - ** Search lookups** are provided for convenience and user-facing interfaces
199+ - The pipe character (` | ` ) in canonical identifiers must be escaped with quotes in shell commands
200+ - Both strategies return the same metadata format on success
201+ - When using mock or authelia mode, the service simulates Auth0 behavior for development and testing
202+ - For detailed Auth0-specific behavior and limitations, see the [ Auth0 Integration Documentation] ( internal/infrastructure/auth0/README.md )
203+
204+ ---
205+
95206### User Update Operation
96207
97208To update a user profile, send a NATS request to the following subject:
0 commit comments