logo

Đ•xternal middleware backend Authorization.










Client request channel by token.When re/streamr validate token the user is locked ip/chid and id/usrid.Token is destroed if user quit connection to .ts stream.Same is valid for HLS streams,but token will be destroed after 60 seconds.

Example Stalker/Ministra

In Nice re/streamer config page set :
Auth token : http://host/stalker_portal/server/api/chk_flussonic_tmp_link.php?token=


In Stalker/Ministra channel config set :
Set configuration value.





PHP Example [back-end][nice restreamer NR 192.168.1.2] :

Set in NR config http://back-end.ip/example_token.php?token=
Your back-end generates token and gives the client , example 12345678 .
1. [Client to NR] Client request channel id 1 - http://192.168.1.2:3000/1?token=12345678 or hls http://192.168.1.2:9000/1.m3u8?token=12345678
2. [NR to back-end - start the check ] NR request - http://back-end.ip/example_token.php?token=12345678
3. [back-end to NR] Your back-end response 200 OK - headers "X-Unique: true" ,"X-UserId: uid"
3. [back-end to NR] Your back-end response 403 Forbidden - headers "" ,""
4. [NR to Client] If 200 OK - start send video stream to client

<?php //code for your back-end , example_token.php
			
//$nr = '192.168.1.2'; // nice restreamer address //- check ip
//$ip = $_SERVER['REMOTE_ADDR'];//- check ip
//if (empty($_GET['token']) || $nr != $ip){ //- check ip

if (empty($_GET['token'])){	
    header($_SERVER["SERVER_PROTOCOL"]." 403 Forbidden");
    exit;
}

$uid = testToken($_GET['token']);

if (!$uid){
    header($_SERVER["SERVER_PROTOCOL"]." 403 Forbidden");
}else{
    header("X-Unique: true");
    header("X-UserId: ".$uid);
    header($_SERVER["SERVER_PROTOCOL"]." 200 OK");
}

function testToken($tkn) {
    $token = '12345678';
	if($tkn == $token){
		return 'User id';
	}else{
		return false;	
	};
}

?>