1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Secure a video stream with a unique key
This guide provides instructions for securing a video streaming with a unique key (hash).
This method offers the highest level of protection and allows, for example, restricting your broadcasts to a member area requiring authentication. Since the way to generate this code is specific to each site, it will be necessary to implement the required PHP functions and adapt your player integration code accordingly.
Restriction by Unique Key (Hash)
For this:
- Log in to the Infomaniak Manager (manager.infomaniak.com) from a web browser like Brave or Edge
- Click on the icon in the top right corner of the interface (or navigate through the left side menu, for example)
- Choose Video Streaming (Streaming universe)
- Click on the name of the relevant object in the displayed table
- Click on Settings in the left side menu
- Click on Restrictions in the left side menu
- In the Restriction by Unique Hash tab
Operation of Restrictions
This method requires retrieving information related to the configuration of your stream and the connecting user.
Firstly, it is necessary to define a password (a key) at the administrative console level. As soon as this key is added, connected viewers and those attempting to view your stream will be instantly blocked.
Here is the principle to follow to authorize access to your stream:
- Design your own authentication system (for example, a member area)
- Take the password configured above in our console
- Retrieve the IP addresses of users via
$_SERVER["REMOTE_ADDR"]
for example - Take the identifier of the stream to target
- Retrieve the current date and time (without minutes and seconds)
These elements will then be hashed by the code provided in the Manager to generate a unique token specific to each user, which will be transmitted to the stream at the time of loading. The streaming platform will then check the validity of the hash to authorize or reject the connection.
Important Remarks
- To ensure the security of access to the stream, the validity of each token is limited in time
- It is important to disable the cache on the pages that allow access to the stream; indeed, if the token generation is cached, other users will attempt to authenticate with someone else's hash, causing their rejection even if they have permission to consume the stream