WebThingsIO / gateway

WebThings Gateway - a self-hosted web application for monitoring and controlling a building over the web
http://webthings.io/gateway
Mozilla Public License 2.0
2.62k stars 339 forks source link

Allow gateway to be logged into while back in hotspot mode? #2353

Open flatsiedatsie opened 4 years ago

flatsiedatsie commented 4 years ago

Last weekend I was frantically trying to enable an add-on (voco) somehow at a location (TV studio) where the gateway couldn't succesfully connect to the WiFi. I wanted to demo the local voice control, but in the end had to let it go.

The gateway had been prepared before, and already had an account on it, and had SSH enabled.

I noticed that when my laptop was connected to the gateway while in hotspot mode, I could SSH into it, and could also access the samba share I had made on it. This was great, since it allowed me to salvage some work-in-progress files from it.

I also noticed that I could reach the gateway's login page while in hotspot mode. If memory serves, I just had to visit 192.168.2.1/login, and the login page was actually there.

I got very excited, since a gateway that would work in stand-alone mode would simplify demonstrations tremendously. However, I could not login. It seems as if the existing user accounts were somehow inaccessible when the gateway was in that mode?

The questions that it raised with me were:

To be clear, I'm not proposing that the Raspberry Pi act as a full fledged router. I'm just proposing that it would be great if it was possible to log-in while it is in hotspot mode.

I think I have proposed a similar idea before, but I can't find the issue now. What really made me want to bring this up again was the feeling that it was so close to working.

mrstegeman commented 4 years ago

The login page you were seeing at /login was almost definitely cached. We don't even bring up those routes while in Wi-Fi setup mode.

flatsiedatsie commented 4 years ago

Ah I see. But:

flatsiedatsie commented 4 years ago

*cough

eode commented 4 years ago

Related: It would be nice if the gateway could function as an actual routing / wifi gateway.

mrstegeman commented 4 years ago

@eode That's what the OpenWrt build for the Turris Omnia was for: https://iot.mozilla.org/gateway/

We had some internal OpenWrt builds for the Raspberry Pi as well, it just didn't make much sense as a router.

flatsiedatsie commented 4 years ago

Would it technically be possible to allow logins while in hotspot mode? Is this something that would require relatively small changes, or is that just my projection?

What would be required to 'unlock' the login in this mode? Are there a theoretical set of SSH commands that could get it to that state?

Would it be interesting to made these changes to the gateway?

mrstegeman commented 4 years ago

Possible, sure. "It's just software." You'd have to modify the whole server setup process in the gateway, and the captive portal would not be as reliable.

flatsiedatsie commented 4 years ago

Do you have any hints as to which files I'd need to modify to "bring up those routes" during the captive portal phase?

mrstegeman commented 4 years ago

If you want the captive portal to stay running, you'll need to look here:

For general routing, see here:

flatsiedatsie commented 4 years ago

Thanks for the links! really interesting to look deeply under the hood.

If you want the captive portal to stay running

I don't really want the captive portal to say running. I want to bring up all the routes while the gateway in captive portal mode.

Or are you saying that this would be much easier to get working?

Still, I'd prefer that routes were available while in captive portal mode, as this would avoid the necessity to connect to a wifi network. It would just be its own wifi network. This would be great for exhibits and workshops, where connecting to the local wifi is often hit-and-miss.

flatsiedatsie commented 4 years ago

This functionality would also be great in a pinch. Imagine if someone's router suddenly dies or is hacked. Currently they'd have no way to access the Gateway. But if it would revert to access point mode and they could connect to that, then hey could then still have basic control over their home while they buy a new router.