How it works
Client connects and provides credentials
When a client connects to your Red5 Pro application, it supplies
username, password, and an optional token as connection parameters. Red5 Pro verifies that the required parameters are present; missing parameters result in an immediate rejection.Client requests to publish or subscribe
Authentication is not triggered on connection alone. It fires when the client attempts an actual stream action — publish or subscribe.
Red5 Pro calls your validation endpoint
The
RoundTripAuthValidator POSTs the client’s credentials, the stream name, the action type (publisher or subscriber), and the optional token to your configured validateCredentials endpoint.Your endpoint returns allow or deny
Your service evaluates the request and responds. An HTTP
200 with a valid JSON body allows the action; any other response causes Red5 Pro to reject it.Round-Trip Authentication triggers only when a client publishes or subscribes
— not on every connection. A client that connects but takes no stream action
is not sent to your endpoint.
Prerequisites
You need three components in place before configuring Round-Trip Authentication:simple-auth-plugin
The
red5pro-simple-auth-plugin JAR must be present on your Red5 Pro server (installed by default).Validator configuration
The
RoundTripAuthValidator bean configured in the application’s red5-web.xml.Your auth service
An HTTP service exposing
/validateCredentials and /invalidateCredentials endpoints that accept POST requests from Red5 Pro.Step 1 — Implement your authentication endpoints
Your service must expose two endpoints.Validate credentials — POST /validateCredentials
Red5 Pro calls this endpoint each time a client attempts to publish or subscribe.
Request body (sent by Red5 Pro):
| Field | Description |
|---|---|
username | The username the client provided |
password | The password the client provided |
token | Optional token the client provided (empty string if not supplied) |
type | publisher or subscriber |
streamId | The name of the stream being published or subscribed |
200 with a JSON body to allow the action. Return any non-200 status to deny it.
Invalidate credentials — POST /invalidateCredentials
Red5 Pro calls this endpoint when a publisher stops streaming.
Step 2 — Configure the application
Add theroundTripValidator and simpleAuthSecurity beans to your application’s context file. For the live application, that file is RED5_HOME/webapps/live/WEB-INF/red5-web.xml.
clientTokenRequired to true if you want Red5 Pro to reject connections that do not include a token parameter.
Step 3 — Set endpoint properties
Add the following section toRED5_HOME/webapps/live/WEB-INF/red5-web.properties. These values are substituted into red5-web.xml at runtime.
server.host with the IP address or hostname of your authentication service. If the service runs on the same instance as Red5 Pro, use the private IP address of that instance.
Validator bean properties reference
| Property | Type | Description |
|---|---|---|
protocol | String | HTTP protocol to use: http:// or https:// |
host | String | Hostname or IP address of your auth service |
port | String | Port your auth service listens on |
validateCredentialsEndPoint | String | URI path for the validation endpoint |
invalidateCredentialsEndPoint | String | URI path for the invalidation endpoint |
clientTokenRequired | Boolean | When true, Red5 Pro rejects connections that do not include a token parameter |
Step 4 — Connect clients with credentials
Clients passusername, password, and optionally token as connection parameters. The credentials are forwarded to your endpoint on each stream action — your service decides what they mean.
- WebRTC (HTML5 SDK)
- RTMP — FFmpeg
- RTSP — Android
- RTSP — iOS
Authentication is transparent to clients — they simply provide their
credentials as connection parameters. They do not need to know that Red5 Pro
is making a server-to-server call to validate them.
Passing custom parameters
If your authentication logic requires parameters beyondusername, password, and token, encode additional values inside the token field as a query string or JSON string.
/validateCredentials endpoint receives the raw token string and decodes it however your service expects.
Testing with the mock Node.js service
Red5 Pro provides a mock authentication backend built in Node.js to help you test your configuration before writing your own service.Download and install the mock service
Clone the repository onto the server where you want to run the service, then install Node.js:
Edit index.js
Open
index.js and update the two variables under BEGINNING OF CONFIGURATION:host— set to the private IP address of the server running Node.jsport— the port the service should listen on (default:3000); ensure this port is open in your firewall inbound rules
Verify the service is reachable
Open
http://<host>:<port> in a browser to access the built-in test forms. Use these forms to confirm the endpoints respond before configuring Red5 Pro.Use case patterns
Registered users (username/password)
Registered users (username/password)
Users hold accounts on your system. Pass
username and password directly; your endpoint looks them up in your user database and checks permissions.This is the simplest pattern and works out of the box with the RoundTripAuthValidator.One-to-many broadcast (publisher + anonymous subscribers)
One-to-many broadcast (publisher + anonymous subscribers)
The publisher authenticates with real credentials. Subscribers pass
username: 'anonymous' and password: 'anonymous' — your endpoint grants subscribe access to everyone or checks a signed token to implement session-based access.Session-based anonymous access
Session-based anonymous access
Issue short-lived signed tokens from your backend after users complete a checkout or registration flow. Pass the signed token in the
token field. Your endpoint decodes and validates the token without requiring a stored credential pair.Custom multi-parameter authentication
Custom multi-parameter authentication
Encode multiple values (session ID, expiry timestamp, signature) into the
token field as a query string or JSON. Your endpoint decodes the composite token and applies complex business rules.When to use Round-Trip Authentication
Good fits
- Integrating with an existing user management or session system
- One-to-many broadcasts requiring publisher/subscriber role separation
- Applications that need real-time validation (e.g., check if a subscription is still active at publish time)
- Complex or custom access control logic that cannot be expressed in JWT claims
- Anonymous or session-based access patterns
Poor fits
- High-throughput deployments where the per-stream HTTP round trip would create latency or become a bottleneck — consider JWT Authentication for local, low-latency validation
- Simple deployments with a fixed user list — use Simple Authentication instead
