illuspas / Node-Media-Server

A Node.js implementation of RTMP/HTTP-FLV/WS-FLV/HLS/DASH/MP4 Media Server
https://www.npmjs.com/package/node-media-server
MIT License
5.98k stars 1.52k forks source link

Can we auth stream from Publisher? #129

Open channchetra opened 6 years ago

channchetra commented 6 years ago

I'm using this server but I want to allow only publisher who has auth can public streaming to server

TheAntinormal commented 5 years ago

Yes you can do it with the auth feature ;)

Tell me if you need help understanding how it works !

channchetra commented 5 years ago

Yes you can do it with the auth feature ;)

Tell me if you need help understanding how it works !

@SAMYEL06 Yes really need that please help

androidneha commented 5 years ago

Yes. I need help with similar thing. The auth config key seems to be working for play but not for publish. It's authorized anyways.

NickGrant89 commented 5 years ago

I need some help with too please.

phucps89 commented 3 years ago

Yes. I need help with similar thing. The auth config key seems to be working for play but not for publish. It's authorized anyways.

I has the same issue. Need more help too please :(

akaco commented 3 years ago

Hi All,

You need Use MD5 hash function first see this package

https://www.npmjs.com/package/node-media-server

in server side config

for example : if secret: 'nodemedia2021MYkey' <====

const config = { rtmp: { port: 1935, chunk_size: 60000, gop_cache: true, ping: 30, ping_timeout: 60 }, http: { port: 8000, allow_origin: '*' }, auth: { play: true, publish: true, secret: 'nodemedia2021MYkey' } } for call or publish you need calculate timestamp and hash value base on that

function toTimestamp(strDate){ var datum = Date.parse(strDate); return datum/1000; }

toTimestamp('08/13/2021 23:31:30')
then You get ===> 1628861490

The combination HashValue is:

stream = /live/stream Timestamp = 1628861490 secret = 'nodemedia2021MYkey'

HashValue = md5("/live/stream-1628861490-nodemedia2021MYkey”) HashValue = 80c1d1ad2e0c2ab63eebb50eed64201a

now you can call

rtmp://192.168.0.10/live/stream?sign=1628861490-80c1d1ad2e0c2ab63eebb50eed64201a