Skip to main content
Participating Frequently
October 12, 2009
Question

Publish stream for specific users

  • October 12, 2009
  • 1 reply
  • 2329 views

Hi:

I need to protect my FMS, so that only me (my Username, or IP if its not possible) can start a live stream.

I have been reading the pdf on plugin for developers, and i read that the authorization plugin can do this, but it is C++ and i dont know nothing about that, i can understand a little bit, but i do not know how to make the dll i want. Is there another way to do this, my idea is that the server requests a user and password when i want to stream.

Thanks

    This topic has been closed for replies.

    1 reply

    October 13, 2009

    Are you using FMIS or FMSS?

    Participating Frequently
    October 13, 2009

    Im using FMIS, what ould be the simples way to have authorization to publish? Not ith the FMLE plugin for authentication.

    Thanks

    October 13, 2009

    There are a couple of ways to do it.

    The simplest way would be to keep a list of usernames/passwords in an array in an .asc file, and then validate credentials in the application.onConnect or application.onPublish methods (whichever suits your needs best).

    You can pass the credentials from the client in two ways... as query string vars or as vars passed as arguments in the onConnect:

    nc.connect("rtmp://myfms.com/app?username=foo&password=bar");

    nc.connect("rtmp://myfms.com/app", "foo", "bar");

    In your application.onConnect, you'll grab these vars and store them for use when you validate the client. If you're using query vars, you'll inspect the client.uri property to extract them.

    In the method where you'd like to authenticate, you'll compare the supplied credentials to the valid credentials. Let's assume you're passing the credentials to FMS as arguments in your nc.connect method. On the server side, the code might look something like this (don't copy and paste this... it's a rough example):

    application.onAppStart = function(){

    application.validUsers = new Array();

    application.validUsers[0] = {username:foo, password:bar}

    application.validUsers[1] = {username:foo2, password:bar2}

    }

    application.onConnect = function(client, username, password){

    client.username = username;

    client.password = password;

    }

    application.onConnect = function(client, stream){

       var valid = false;

       for(var a=0;a<application.validUsers.length; a++){

          if(client.username == application.validUsers.username && client.password == application.validUsers.password){

             // Valid

            valid = true;

            break;

          }

       }

       if(!valid){

          // This user does not have permission to publish. Do something about it

         application.disconnect(client);

       }

    }

    This is just one way of doing it. You could also store your credentials in a database, and build a webservice for FMS to connect to for validation.