Overview
RDSWeb Custom uses Active Directory (AD) integration with JWT-based sessions to provide secure authentication for RemoteApp access. The system supports both production AD environments and simulation mode for development.Authentication Flow
Login Process
The login flow involves several steps to securely authenticate users against Active Directory:1. Username Normalization
RDSWeb Custom accepts multiple username formats:username- Simple username (uses default domain)DOMAIN\username- Windows domain format[email protected]- UPN format
2. Active Directory Lookup
The system uses a service account with read-only permissions to query AD. This is an enterprise security best practice:- Anonymous LDAP queries are disabled in most AD environments
- Service account has read-only permissions (cannot modify AD)
- User credentials are validated through a separate bind operation
- Allows retrieval of user attributes (groups, email, display name)
3. Credential Validation
After finding the user’s DN (Distinguished Name), the system performs a second LDAP bind using the user’s actual credentials:- Service account never has access to user passwords
- User credentials are validated by AD itself
- All AD password policies are enforced
4. Group Membership Extraction
The system extracts AD group memberships from thememberOf attribute:
JWT Session Management
After successful AD authentication, the system creates a JWT token containing user information:Token Structure
Secure Cookie Storage
Tokens are stored in httpOnly cookies for security:httpOnlyprevents XSS attacks from stealing tokenssecureensures tokens only travel over HTTPSsameSiteprotects against CSRF attacks- Short expiration times reduce token theft impact
Token Verification
Every authenticated request verifies the JWT:API Endpoints
Login
Get Current User
Logout
Error Handling
The authentication system returns specific error codes for different failure scenarios:| Error Code | Description | HTTP Status |
|---|---|---|
MISSING_FIELDS | Username or password not provided | 400 |
INVALID_CREDENTIALS | Wrong username or password | 401 |
USER_NOT_FOUND | User doesn’t exist in AD | 401 |
AD_UNREACHABLE | Cannot connect to Active Directory | 500 |
NO_TOKEN | No authentication token provided | 401 |
TOKEN_EXPIRED | Session has expired | 401 |
INVALID_TOKEN | Token is corrupted or invalid | 401 |
Simulation Mode
For development without Active Directory access, enable simulation mode:Security Best Practices
-
Service Account Security
- Use a dedicated service account with read-only AD permissions
- Store credentials in environment variables, never in code
- Rotate service account passwords regularly
-
JWT Secret Management
- Generate a strong random secret for production
- Never commit secrets to version control
- Use different secrets for dev/staging/prod
-
Session Timeouts
- Public mode: 20 minutes (shorter timeout for shared computers)
- Private mode: 240 minutes (longer for personal devices)
- See Session Modes for details
-
HTTPS in Production
- Always use HTTPS to protect credentials in transit
- Enable
secure: truecookie flag in production - Consider implementing certificate pinning
Configuration Reference
Authentication is configured through environment variables:Next Steps
- Learn about Session Modes and timeout behavior
- Explore the RemoteApp Catalog system
- Understand RDP File Generation