How it works
Client connects and provides credentials
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
Red5 Pro calls your validation endpoint
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
200 with a valid JSON body allows the action; any other response causes Red5 Pro to reject it.Red5 Pro calls your invalidation endpoint on disconnect
invalidateCredentials endpoint so your service can clean up session state.Prerequisites
You need three components in place before configuring Round-Trip Authentication:simple-auth-plugin
red5pro-simple-auth-plugin JAR must be present on your Red5 Pro server (installed by default).Validator configuration
RoundTripAuthValidator bean configured in the application’s red5-web.xml.Your auth service
/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):
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
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
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
Edit index.js
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
Start the service
Verify the service is reachable
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.Configure Red5 Pro to point at the mock service
server.host and server.port in red5-web.properties to match the mock service, then restart Red5 Pro.Use case patterns
Registered users (username/password)
Registered users (username/password)
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)
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
token field. Your endpoint decodes and validates the token without requiring a stored credential pair.Custom multi-parameter authentication
Custom multi-parameter authentication
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
