How to implement authentication by placing the srs3.0 token parameter after the streamID?
Ccrazyfish opened this issue · 8 comments
The 'token' parameter of srs3.0 is placed after the StreamID. In the TcURL of http_hook, this token is not present. It is only present in the TcUrl when placed after 'live'.
How can I retrieve the token in the 'json_req' of server.py for authentication?
Push stream rtmp://test.lsspush.test.com/live/steam001?key=123000000000&t=20000.
on_connect
json_req:
{u'ip': u'192.168.0.101, u'app': u'live', u'vhost': u'defaultVhost', u'pageUrl': u'', u'client_id': 108, u'tcUrl': u'rtmp://test.lsspush.test.com/live', u'action': u'on_connect'}
on_publish
json_req:
{u'stream': u'steam001', u'ip': u'116.62.38.168', u'app': u'live', u'vhost': u'defaultVhost', u'client_id': 108, u'tcUrl': u'rtmp://test.lsspush.test.com/live', u'action': u'on_publish'}
TRANS_BY_GPT3
2.0 branch have support this feature. You can look up changelog.
2.0branch tried it, got the streamID, but there are no parameters with key=** in the hook information.
Push stream address:
rtmp://172.16.162.16/live/stream000?key=123435
Hook information:
action: {u'ip': u'172.16.162.190', u'app': u'live', u'vhost': u'defaultVhost', u'pageUrl': u'',
u'client_id': 120, u'tcUrl': u'rtmp://172.16.162.16', u'action': u'on_connect'}
{u'stream': u'stream000', u'ip': u'172.16.162.190', u'app': u'live', u'vhost': u'defaultVhost',
u'client_id': 120, u'tcUrl': u'rtmp://172.16.162.16', u'action': u'on_publish'}
TRANS_BY_GPT3
Just add a field to the code of 'hook', I modified the source code myself. Winlin has completed 99% of it, so you just need to make the remaining changes yourself. Alternatively, you can create an issue and ask him to fix it.
TRANS_BY_GPT3
SRS2:
{"action":"on_publish","client_id":107,"ip":"127.0.0.1","vhost":"__defaultVhost__",
"app":"live","tcUrl":"rtmp://127.0.0.1:1935/live","stream":"livestream","param":"?userid=123456&token=ueieww"}
{"action":"on_play","client_id":107,"ip":"127.0.0.1","vhost":"__defaultVhost__",
"app":"live","stream":"livestream","param":"?userid=123456&token=ueieww","pageUrl":""}
Support params in on_publish
, on_unpublish
, on_play
, on_stop
, on_dvr
, on_hls
and on_hls_notify
.
SRS3:
{"action":"on_play","client_id":106,"ip":"::ffff:127.0.0.1","vhost":"__defaultVhost__",
"app":"live","pageUrl":"","stream":"livestream","param":"userid=123456&token=ueieww"}
{"action":"on_publish","client_id":108,"ip":"::ffff:127.0.0.1","vhost":"__defaultVhost__",
"app":"live","tcUrl":"rtmp://127.0.0.1:1935/live","stream":"livestream","param":"userid=123456&token=ueieww"}
Support params in on_publish
, on_unpublish
, on_play
, on_stop
, on_dvr
, on_hls
and on_hls_notify
.
In addition, the JSON data structure received by the proxy here is also somewhat different from the description in the http-hooks of full.conf. Do we need to adjust it ourselves in the source code to match the desired data structure?
TRANS_BY_GPT3