-
Notifications
You must be signed in to change notification settings - Fork 5
Authentication
im-pingo edited this page Mar 26, 2026
·
2 revisions
English | 中文
LiveForge supports JWT token verification and HTTP callback authentication for both publish and subscribe actions.
auth:
enabled: false
publish:
mode: "none"
token:
secret: "${AUTH_JWT_SECRET}"
algorithm: HS256
callback:
url: ""
timeout: 3s
subscribe:
mode: "none"
token:
secret: "${AUTH_JWT_SECRET}"
algorithm: HS256
callback:
url: ""
timeout: 3sNote: Only
HS256is currently implemented as a JWT signing algorithm.
Each of publish and subscribe can be configured independently with one of these modes:
| Mode | Description |
|---|---|
none |
No authentication. All requests are allowed. |
token |
Verify a JWT token passed as a query parameter. Reject if invalid or expired. |
callback |
POST request details to an external HTTP endpoint. Allow if it returns HTTP 200. |
token+callback |
Try JWT verification first. If the token is valid, allow. If invalid, fall back to the callback. |
When mode is token or token+callback, the client must pass a JWT token as a token query parameter.
The token is passed as a URL query parameter named token:
rtmp://localhost:1935/live/stream1?token=eyJhbGciOi...
http://localhost:8080/live/stream1.flv?token=eyJhbGciOi...
| Field | Type | Required | Description |
|---|---|---|---|
sub |
string | No | Stream key the token is valid for. If set, must match the requested stream. |
action |
string | No |
"publish" or "subscribe". If set, must match the action being performed. |
exp |
int | No | Token expiry as a Unix timestamp. If set, the token is rejected after this time. |
import jwt, time
token = jwt.encode({
"sub": "live/stream1",
"action": "publish",
"exp": int(time.time()) + 3600
}, "your-secret-key", algorithm="HS256")
print(token)ffmpeg -re -i input.mp4 -c copy -f flv \
"rtmp://localhost:1935/live/stream1?token=eyJhbGciOi..."When mode is callback or token+callback, LiveForge sends a POST request to the configured URL with the following JSON body:
{
"stream_key": "live/stream1",
"protocol": "rtmp",
"remote_addr": "192.168.1.100:54321",
"token": "eyJhbGciOi...",
"action": "publish"
}- HTTP 200 response = request allowed
- Any other status = request rejected
The timeout field controls how long to wait for the callback response (default: 3 seconds).
- Token-only auth -- simple JWT-based access control without external services
- Callback-only auth -- delegate auth decisions to your backend (e.g., check subscription status)
- Token + callback -- fast-path JWT validation with callback fallback for complex authorization logic
- Separate publish/subscribe policies -- require tokens for publishers but allow open subscribe, or vice versa