You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Authentication for Red5 webapps may be accomplished with the following examples below, these are the most simple examples and are not intended for public production use. Change roles, users, and passwords before using this on your site. For production, consider realms backed by a database (JDBCRealm) or LDAP (JNDIRealm). MemoryRealm stores cleartext passwords and is best suited for testing or internal use.
Add a realm to Red5's embedded Tomcat server
We're using the MemoryRealm realm provided by Tomcat, due to its ease-of-use and defaults. In embedded Red5, Tomcat’s UserDatabaseRealm requires a JNDI-bound UserDatabase resource, which isn’t available out-of-the-box. MemoryRealm avoids that dependency and directly reads conf/tomcat-users.xml. To get started, place this property within the tomcat.server bean in your conf/jee-container.xml:
Go here to learn more about other realms straight from Tomcat.
Configure credentials
This covers the MemoryRealm to match our example herein. The MemoryRealm is a simple demonstration implementation of the Tomcat Realm interface. It is not designed for production use. At startup time, MemoryRealm loads information about all users, and their corresponding roles, from an XML document (by default, this document is loaded from conf/tomcat-users.xml. Changes to the data in this file are not recognized until Red5 is restarted.
User File Format
The users file (by default, conf/tomcat-users.xml must be an XML document, with a root element <tomcat-users>. Nested inside the root element will be a <user> element for each valid user, consisting of the following attributes:
name - Username this user must log on with.
password - Password this user must log on with (in clear text if the digest attribute was not set on the <Realm> element, or digested appropriately as described here otherwise).
roles - Comma-delimited list of the role names associated with this user.
Note: You must restart Red5 after editing tomcat-users.xml. MemoryRealm only loads the file at startup.
Adding Security to Web Applications
After the JEE part is configured, one must add security to any webapps where required or they will continue with default openness. The example below is for a webapp named webrtcexamples located in webapps/webrtcexamples on a Red5 Pro Server. Normally this webapp is not loaded as a JEE application and exists as a vanilla website on the server; here we will add the WEB-INF subdirectory and a webapp descriptor file, our full path would then be webapps/webrtcexamples/WEB-INF/web.xml; here are the files contents:
login-config - the authentication method to be used; BASIC will cause a browser pop-up expecting credentials. Since this isn't using more complicated realms like JNDI, the ExampleRealm is merely a place holder.
security-role - a role specified in the conf/tomcat-users.xml file
security-constraint - triggers the authentication enforcement, the url-pattern denotes the path being protected with the example /* implying the entire site under webrtcexamples
Note: BASIC auth is the browser popup, and if one wants custom login pages they can switch to FORM; additional details are outside this scope.
The final constraint is standard for protecting webapp private information.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters