node-rtsp-rtmp-server icon indicating copy to clipboard operation
node-rtsp-rtmp-server copied to clipboard

Authenticate Streams

Open jazzy348 opened this issue 8 years ago • 3 comments

Hi,

Can node-rtsp-rtmp-server authenticate livestreams before allowing them? If so, how is this configured?

jazzy348 avatar Sep 30 '16 15:09 jazzy348

Authentication is not built-in, but it's possible. You need to implement setLivePathConsumer() method in server.coffee. Basically, create a unique URL for each authenticated session in your application code, then call callback null in setLivePathConsumer() if correct URL is requested.

iizukanao avatar Oct 02 '16 12:10 iizukanao

Hi @iizukanao, i need a feature to authenticate stream broadcaster. Lets imagine that we have url like rtsp://example.com/live/coolstream, any user can connect to it and watch the stream, but for the broadcast starting the broadcaster should use url like rtsp://example.com/live/coolstream?stream_key=xxxx. Please give me an advice where should I put some verification function for this parameter.

dr1v3 avatar Nov 25 '16 15:11 dr1v3

@dr1v3 You can do it by modifying setLivePathConsumer() in server.coffee like the following:

streamServer.setLivePathConsumer (uri, callback) ->
  uriInfo = url.parse uri, true
  if uriInfo.query.stream_key is 'xxxx'
    return callback null  # Accept access
  else
    return callback new Error 'Unauthorized'  # Deny access

The full version is here.

iizukanao avatar Dec 05 '16 12:12 iizukanao