Search code examples
videocoldfusionwowzawrench

Make video private to my site users - wowza + wrench


I have a ColdFusion application which is using Wowza Streaming Engine 4.1. I have done all the integration to record video or audio and playback by JW player. I am using VOD (video on demand) application of Wowza.

Now I want to make sure that users can only play their own videos. For this purpose I am using https://streamtoolbox.com/webservice-authentication-authorization

For this purpose, it doesn't need the database so I have added the following code in my application.xml file properties section:

<!-- Example Application.xml part from the Properties and modules element -->

    <Modules>
        <Module>
            <Name>base</Name>
            <Description>Base</Description>
            <Class>com.wowza.wms.module.ModuleCore</Class>
        </Module>
        <Module>
            <Name>logging</Name>
            <Description>Client Logging</Description>
            <Class>com.wowza.wms.module.ModuleClientLogging</Class>
        </Module>
        <Module>
            <Name>flvplayback</Name>
            <Description>FLVPlayback</Description>
            <Class>com.wowza.wms.module.ModuleFLVPlayback</Class>
        </Module> 
        <Module>
          <Name>Wrench module</Name>
          <Description>A module for user authentication and much more</Description>
          <Class>com.streamtoolbox.Wrench</Class>
        </Module>
    </Modules>
    <!-- Properties defined here will be added to the IApplication.getProperties() and IApplicationInstance.getProperties() collections -->
    <Properties>
    <!-- Example Application.xml part from the Properties element -->
        <Property>
          <Name>wrench.db.driver</Name>
          <Value></Value> <!-- Setting to nothing to go into no-database mode -->
        </Property>
        <Property>
          <Name>wrench.token.resolver.url</Name>
          <Value>http://example.com/auth-token.cfm</Value>
          <!--Value>http://streamtoolbox.com/streaming/auth-nok.php</Value-->
        </Property>
        <Property>
          <Name>wrench.connect.authorization.url</Name>
          <Value>http://example.com/auth-ok.cfm</Value>
          <!--Value>http://streamtoolbox.com/streaming/auth-nok.php</Value-->
        </Property>
    </Properties>

My auth-ok CFM files only contain the following code:

{"result": "allow"}

My auth-token CFM files only contain the following code:

{"username":"john"}

I have restarted the Wowza application and checked video, but videos are giving the following error:

Uncaught (in promise) DOMException: The play() request was interrupted by a call to pause()

I am logging text to a file, in ColdFusion, to see whether it is sending a request to the cfm file or not. But nothing is found. So it seems that I have any problem in the application.xml file which is not running properly.

Can anyone let me know that what I am doing wrong?


Solution

  • It seems to me that you haven't configured a token resolver webservice with wrench.token.resolver.url (or you could use database for that too), so basically what happens is that the connection comes in, Wrench does not have a defined way to figure out who belongs to the token, and then it won't call the authorization webservice, because that would require the username to be passed. You need to implement a simple webservice that returns the username for the token, in the below format (more details in the docs):

    {"username":"john"}