Skip to main content
JWT Authentication lets you control who can publish and subscribe to your Red5 Pro streams using JSON Web Tokens (JWTs). Your backend issues a signed token for each authenticated user; the client passes that token when connecting to Red5 Pro, which validates it locally using a shared secret — with no external calls during the stream. This approach scales naturally and integrates with any existing identity provider or authentication service.

How it works

1

User authenticates with your backend

Your application handles user login however you prefer — password, OAuth, SSO, or any other mechanism.
2

Your backend issues a signed JWT

After validating the user, your backend generates a JWT signed with the shared secret and returns it to the client over HTTPS.
3

Client passes the token to Red5 Pro

When the client connects to publish or subscribe, it includes the JWT as a connection parameter.
4

Red5 Pro validates the token locally

Red5 Pro verifies the cryptographic signature, checks expiration, and evaluates any role, transport, or room claims — all without contacting your backend.
Because validation is local, JWT Authentication adds no latency to stream operations. It is ideal for scaled and distributed deployments.

Prerequisites

Before configuring JWT Authentication, you need:
  • The red5pro-simple-auth-plugin installed on your Red5 Pro server (present by default)
  • A JWT-issuing service or identity provider
  • A shared secret key of at least 32 bytes, used by both your issuing service and Red5 Pro

Step 1 — Configure the application

Add the jwtAuthenticator 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. These beans are already present in the file but commented out — uncomment and adjust them.

Step 2 — Set properties

Add the following section to RED5_HOME/webapps/live/WEB-INF/red5-web.properties. The property values are substituted into red5-web.xml at runtime.
Replace jwt.secret with a cryptographically random value of at least 32 bytes. This secret must match the secret your token-issuing service uses to sign JWTs. Never commit it to version control.

Configuration properties reference

Core (simpleAuthSecurity bean) Authenticator (jwtAuthenticator bean)

Step 3 — Generate tokens in your backend

Your backend service signs JWTs with the shared secret using the HS256 algorithm. Never generate tokens on the client side or embed the secret in client code.

Token examples for common scenarios

Issue this to a broadcaster who should only be able to publish, not subscribe.
Issue this to a viewer who should only be able to subscribe, not publish.
Restrict the token to a specific room within the application scope.
Use a 60-second expiry for highly sensitive access scenarios.
Set jwt.ttl.minutes=2 on the server to tolerate up to 60 seconds of clock drift while still rejecting overly generous tokens.

JWT claims reference

Standard claims

Red5 Pro-specific claims

For the stream path live/room1/stream1, the room name is room1. If you set red5-room, clients cannot access application-level streams that have no room prefix.
Role matching is case-sensitive. Use red5-publisher and red5-subscriber in lowercase. If your identity provider adds its own roles to the token (e.g., admin, editor), include the Red5 Pro roles alongside them:

Step 4 — Pass the token from your client

Clients send the JWT as the token parameter in their connection configuration. Set username and password to any non-empty value (conventionally "jwt").
Pass the complete JWT string — header.payload.signature — without a Bearer prefix in the token parameter.

Security best practices

The shared secret is the foundation of JWT security. Anyone who possesses it can mint valid tokens.
  • Store it in a secrets manager (HashiCorp Vault, AWS Secrets Manager, etc.)
  • Never commit it to version control
  • Use environment variables or files with restricted permissions
  • Rotate the secret on a regular schedule, coordinating the rotation between Red5 Pro and your issuing service
Generate a strong secret:
Short-lived tokens limit the impact of token theft.
  • Standard interactive sessions: 15–60 minutes
  • High-security or near-one-time access: 60 seconds
  • Configure jwt.ttl.minutes slightly higher than your token TTL to tolerate clock drift between servers
  • Send tokens from your backend to clients over HTTPS only
  • Use RTMPS, RTSPS, or WebRTC (encrypted by default) for the streaming connection
  • Never log or expose token strings in debug output or error messages
Set jwt.issuer on the server to prevent tokens issued by other services from being accepted by Red5 Pro.

When to use JWT Authentication

Good fits

  • Production deployments with many users
  • Microservices or API-gateway architectures that already issue JWTs
  • Single Sign-On integrations (Auth0, Okta, AWS Cognito, Azure AD)
  • Multi-tenant systems using room or issuer claims for isolation
  • Applications requiring per-user role control (publisher vs. subscriber)
  • Scenarios needing low-latency, stateless authentication

Poor fits

  • Simple deployments with a small, fixed set of users — use Simple Authentication instead
  • Situations with no JWT-issuing service available
  • When you need real-time validation against live user state — use Round-Trip Authentication instead