From e9bb401170e69f14b5a2ac4b0fbb8b9ddb1b6dd7 Mon Sep 17 00:00:00 2001 From: dreamer Date: Tue, 11 May 2021 20:44:42 +0200 Subject: [PATCH] add auth endpoint for on_publish --- code/app.lua | 4 ++++ code/handlers/authhandler.lua | 24 ++++++++++++++++++++++++ code/nginx.conf | 2 ++ 3 files changed, 30 insertions(+) create mode 100644 code/handlers/authhandler.lua diff --git a/code/app.lua b/code/app.lua index 42dc47c..b67c967 100644 --- a/code/app.lua +++ b/code/app.lua @@ -11,4 +11,8 @@ app:get("/", function(self) return handlers.Roothandler(self) end) +app:post("/auth", function(self) + return handlers.Authhandler(self) +end) + return app diff --git a/code/handlers/authhandler.lua b/code/handlers/authhandler.lua new file mode 100644 index 0000000..841df77 --- /dev/null +++ b/code/handlers/authhandler.lua @@ -0,0 +1,24 @@ +local autoload = require("lapis.util").autoload + + +local function Authhandler(self) + local name = self.params.name + local password = self.params.password + + print(name) + print(password) + + local endpoints = { + puik='something', + wstd='something', + buzz='something' + } + + if endpoints[name] == password then + return {status = 201} + else + return {status = 404} + end +end + +return Authhandler diff --git a/code/nginx.conf b/code/nginx.conf index d173c35..d0f9605 100644 --- a/code/nginx.conf +++ b/code/nginx.conf @@ -15,6 +15,8 @@ rtmp { application stream { live on; + on_publish http://localhost:${{PORT}}/auth; + #relays the incoming video to low quality streams on this server, audio-only version and to a different server exec ffmpeg -i rtmp://localhost:1935/stream/$name -c:a copy -c:v copy -f flv rtmp://localhost/hls/$name_hi;