Retrofit for renamed file, display configurable realm

This commit is contained in:
Marcos Kirsch 2015-07-19 13:33:47 -05:00
parent 122926f9f6
commit 0bd5e20c62

View File

@ -13,17 +13,17 @@ function basicAuth.authenticate(header)
if not credentials_enc then
return nil
end
local credentials = dofile("b64.lc").decode(credentials_enc)
local credentials = dofile("httpserver-b64decode.lc")(credentials_enc)
local user, pwd = credentials:match("^(.*):(.*)$")
if user ~= conf.auth.user or pwd ~= conf.auth.password then
return nil
end
print("httpserver-basicauth: User " .. user .. " authenticated.")
print("httpserver-basicauth: User \"" .. user .. "\" authenticated.")
return user
end
function basicAuth.authErrorHeader()
return "WWW-Authenticate: Basic realm=\"nodemcu-httpserver\""
return "WWW-Authenticate: Basic realm=\"" .. conf.auth.realm .. "\""
end
return basicAuth