idk-man / auth.lua
UnschooledGamer's picture
Update auth.lua
acdabf4 verified
raw
history blame contribute delete
475 Bytes
local json = require("json")
local config = require('../utils/config')
return function(req, res, go)
local pass = req.headers["authorization"]
p('[addon - auth]', req.path)
-- Just for Hugging Face
if req.path == '/' then
res.code = 200
return
end
if pass ~= config.server.password then
res.body = json.encode({ error = "Authorization failed" })
res.code = 401
res.headers["Content-Type"] = "application/json"
return
end
go()
end