JWT Authentication
Accept externally-signed JWT tokens for secure authentication, enabling single sign-on, proxy authentication, and iframe embedding scenarios.
requires v1.3.x or newer
Basic Configuration
Configuration Options
| Option | Default | Description |
|---|---|---|
enabled | false | Enable JWT external authentication |
secret | required | Shared secret for verifying JWT signatures |
algorithm | HS256 | JWT signing algorithm (HS256, HS384, HS512, RS256, RS384, RS512, ES256, ES384, ES512) |
header | X-JWT-Assertion | HTTP header name to check for JWT token |
userIdentifier | sub | JWT claim field to use as username |
groupsClaim | groups | JWT claim field containing user groups |
adminGroup | "" | Group name that grants admin privileges |
userGroups | [] | List of allowed groups (empty = allow all) |
logoutRedirectUrl | "" | URL to redirect after logout |
How It Works
- External authentication service generates a JWT token with user identity
- Token is passed to FileBrowser via HTTP header or query parameter
- FileBrowser verifies the token signature using the shared secret
- If valid, FileBrowser extracts username and creates the user if needed
- A FileBrowser session token is generated for subsequent requests
Token Delivery
HTTP Header (Recommended)
Pass the JWT token in the configured header:
Query Parameter
The query parameter is hardcoded to jwt:
| |
Security Note: Query parameter authentication exposes tokens in URLs, which may appear in logs and browser history. Always use HTTPS and prefer header-based authentication for sensitive deployments.
JWT Token Requirements
Required Claims
Your JWT token must contain:
sub(or configureduserIdentifier) - The usernameexp- Expiration timestamp (Unix timestamp)- Valid signature using the configured secret and algorithm
Optional Claims
email- User’s email addressname- User’s full namegroups- Array of group names for authorizationiat- Issued at timestampnbf- Not before timestamp
Example JWT Payload
Generating JWT Tokens
Node.js
Python
Go
| |
Group-Based Authorization
Admin Group
Automatically grant admin privileges to users in a specific group:
Users with "groups": ["admin"] in their JWT token will have admin access.
User Group Restrictions
Restrict access to specific groups only:
Only users with JWT tokens containing these groups can log in.
Advanced Configuration
Custom Username Field
Use a different JWT claim for username:
JWT token payload:
Custom Header Name
Use a different HTTP header:
Then use:
| |
Different Signing Algorithm
Use RS256 (RSA) or ES256 (ECDSA) instead of HS256:
Note: For asymmetric algorithms (RS256, RS384, RS512, ES256, ES384, ES512), the secret field should contain the public key used to verify signatures.
Integration Examples
NGINX Reverse Proxy
Generate JWT tokens from authenticated users:
Iframe Embedding
Embed FileBrowser with user identity:
Windows NTLM Proxy
Example Express.js proxy with NTLM authentication:
| |
Security Best Practices
Security Checklist:
✅ Always use HTTPS in production
✅ Use strong secrets (minimum 32 characters, random)
✅ Set short expiration times (1-2 hours recommended)
✅ Rotate secrets regularly
✅ Use header authentication instead of query params when possible
✅ Monitor failed authentication attempts
✅ Store secrets in environment variables, not config files
Environment Variable Best Practice
| |
Then reference in config:
Troubleshooting
“JWT authentication failed: invalid token”
Causes:
- Secret doesn’t match between token issuer and FileBrowser
- Token is expired (
expclaim in the past) - Token signature is invalid
- Wrong signing algorithm
Solution: Verify the secret matches exactly and token is not expired.
“JWT token missing required claim: sub”
Cause: Token doesn’t include the username field.
Solution: Add "sub": "username" to your JWT payload, or configure userIdentifier to match your token structure.
“JWT authentication failed - no user found”
This error no longer occurs as users are automatically created on first login.
“user is not in allowed groups”
Cause: User’s groups don’t match userGroups restriction.
Solution:
- Verify JWT token includes the
groupsclaim - Ensure group names match exactly (case-sensitive)
- Check
groupsClaimconfiguration
Comparison with Other Auth Methods
| Feature | JWT Auth | Proxy Auth | OIDC | Password |
|---|---|---|---|---|
| External Identity | ✅ | ✅ | ✅ | ❌ |
| Cryptographic Verification | ✅ | ❌ | ✅ | ✅ |
| Group Support | ✅ | ✅ | ✅ | ❌ |
| Iframe Embedding | ✅ | ⚠️ | ❌ | ❌ |
| No External Service | ✅ | ✅ | ❌ | ✅ |
When to use JWT Auth:
- Need cryptographic verification (more secure than proxy auth)
- Want iframe embedding support
- Have existing JWT infrastructure
- Need simple external identity integration
- Can’t use OIDC (too complex/unavailable)
Testing Your Setup
1. Generate Test Token
Using jwt.io:
- Select algorithm:
HS256 - Set payload:
{"sub": "testuser", "exp": 9999999999} - Enter your secret
- Copy the generated token
2. Test Authentication
Expected: HTTP 200 OK with file listing
3. Verify Logs
Check FileBrowser logs for: