OpenWrt Forum Archive

Topic: Modifying Openwrt html Auth for multiUser support

The content of this topic has been archived on 6 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

Dear Openwrt developers,

I want to try modifying the existing Single User implementation of LUCI to Multiuser.

I actually traced the authentication mechanism of the Login screen of LUCI. But I am stuck at this function which does the validation and cannot move ahead.

this the function:
function authenticator.htmlauth(validator, accs, default)
        local user = luci.http.formvalue("luci_username")
        local pass = luci.http.formvalue("luci_password")

        if user and validator(user, pass) then
                return user
        end

        require("luci.i18n")
        require("luci.template")
        context.path = {}
        luci.template.render("sysauth", {duser=default, fuser=user})
        return false

end

In this the "pass" value is being pulled from the FORM with testbox "luci_password"
Then it calls "VALIDATOR(user,pass)

I am guessing the "root" user is hardcoded in this validator function.

How can I tweak this code to get MultiUser support for LUCI login.

@gadernayan I'm trying to create a debug file in the below function in /usr/lib/lua/luci/dispatcher.lua

function authenticator.htmlauth(validator, accs, default)

Added below code to test if this function is getting hit.

local luci_auth_debug = io.open("/luci_auth_debug.txt", "w")
luci_auth_debug:write("Hello Luci")
luci_auth_debug:close()

But I couldn't see any new file luci_auth_debug.txt created in /. Any idea?

PS: I'm changing lua files in router directly and reloading the webpage

(Last edited by k.teza1 on 11 Sep 2015, 10:08)

Hi k.teza,

I traced to this function using GREP not programatically (since I did not know how to).
I will try to put the debug points as you have mentioned and see if this function is called in my box.

Thanks for paying attention to this post.

Hello everyone,

I tried putting trace prints in this function using print("Hello1") print("Hello2") and as k.teza has observed, in my case as well the function does not seem to get called.

So now the question has changed slightly ----> How to trace the events that are executed when I LOGIN.

Some progress

I changed lua file during build and now I'm able to see my debug file. My guess would be that, some where lua files are getting compiled using luac and those are being used by interpreter and actual lua files are left alone. But changing files during build is not very convinient for debugging.

PS: Printing to screen might not be a good idea since cgi may redirect or supress the prints.

I have already implemented a full blown luci multi user system, it can be found and compiled from github. See this thread https://forum.openwrt.org/viewtopic.php?id=54593 there is instructions to build it there.

(Last edited by hostle19 on 17 Sep 2015, 19:25)

The discussion might have continued from here.