This document describes the NATS subject for retrieving user email addresses.
To retrieve user email addresses (both primary and alternate emails), send a NATS request to the following subject:
Subject: lfx.auth-service.user_emails.read
Pattern: Request/Reply
The service supports a hybrid approach for user email retrieval, accepting multiple input types and automatically determining the appropriate lookup strategy based on the input format.
The service intelligently handles different input types:
- JWT Tokens (Auth0) or Authelia Tokens (Authelia)
- Subject Identifiers (canonical user IDs)
- Usernames
The request payload can be any of the following formats (no JSON wrapping required):
JWT Token (Auth0):
eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9...
Subject Identifier:
auth0|123456789
Username:
john.doe
The service automatically determines the lookup strategy based on input format:
- Token Strategy: If input is a JWT/Authelia token, validates the token and extracts the subject identifier
- Canonical Lookup: If input contains
|(pipe character) or is a UUID, treats as subject identifier for direct lookup - Username Search: If input doesn't match above patterns, treats as username for search lookup
The service returns a structured reply with user email information:
Success Reply:
{
"success": true,
"data": {
"primary_email": "john.doe@example.com",
"alternate_emails": [
{
"email": "john.doe@personal.com",
"verified": true
},
{
"email": "j.doe@company.com",
"verified": false
}
]
}
}Success Reply (No Alternate Emails):
{
"success": true,
"data": {
"primary_email": "john.doe@example.com",
"alternate_emails": []
}
}Error Reply (User Not Found):
{
"success": false,
"error": "user not found"
}Error Reply (Invalid Token):
{
"success": false,
"error": "invalid token"
}primary_email(string): The user's primary email address registered with the identity provideralternate_emails(array): List of alternate email addresses linked to the user accountemail(string): The alternate email addressverified(boolean): Whether the alternate email has been verified
# Retrieve user emails using JWT token
nats request lfx.auth-service.user_emails.read "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
# Retrieve user emails using subject identifier
nats request lfx.auth-service.user_emails.read "auth0|123456789"
# Retrieve user emails using username
nats request lfx.auth-service.user_emails.read "john.doe"# Get and format the response
nats request lfx.auth-service.user_emails.read "john.doe" | jq '.'
# Extract only the primary email
nats request lfx.auth-service.user_emails.read "john.doe" | jq -r '.data.primary_email'
# List all verified alternate emails
nats request lfx.auth-service.user_emails.read "john.doe" | jq -r '.data.alternate_emails[] | select(.verified == true) | .email'
# Count total email addresses (primary + alternates)
nats request lfx.auth-service.user_emails.read "john.doe" | jq '.data.alternate_emails | length + 1'Important Notes:
- The service automatically detects input type and applies the appropriate lookup strategy
- JWT tokens are validated for signature and expiration before extracting subject information
- The target identity provider is determined by the
USER_REPOSITORY_TYPEenvironment variable - Primary email is always present if the user exists
- Alternate emails array may be empty if the user has not linked any additional email addresses
- Only verified alternate emails should be considered as confirmed user identities
- For detailed Auth0-specific behavior and limitations, see:
../internal/infrastructure/auth0/README.md - For detailed Authelia-specific behavior and SUB management, see:
../internal/infrastructure/authelia/README.md
When you need to verify if a user owns a specific email address:
# Get all user emails
nats request lfx.auth-service.user_emails.read "john.doe"When you need to send notifications to all verified user email addresses:
# Extract all verified emails (primary + verified alternates)
nats request lfx.auth-service.user_emails.read "john.doe" | \
jq -r '(.data.primary_email, (.data.alternate_emails[] | select(.verified == true) | .email))'When displaying email options for account recovery:
# Show all verified email addresses for recovery selection
nats request lfx.auth-service.user_emails.read "auth0|123456789" | \
jq '.data.alternate_emails[] | select(.verified == true)'To check if an email is already associated with a user account, use the email lookup subjects:
lfx.auth-service.email_to_username- Get username from emaillfx.auth-service.email_to_sub- Get user ID from email
See email_lookups.md for more details on these subjects.
- Email Lookup:
email_lookups.md - Email Verification:
email_verification.md - User Metadata:
user_metadata.md - Identity Linking:
identity_linking.md