Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only allow sending wifi credentials in AP mode #4

Open
arjhun opened this issue Dec 11, 2017 · 2 comments
Open

Only allow sending wifi credentials in AP mode #4

arjhun opened this issue Dec 11, 2017 · 2 comments

Comments

@arjhun
Copy link

arjhun commented Dec 11, 2017

Hi Ryan,

Thanks for this awesome library!!! After the initial connection is made I think it's safer if to not let users enter their credentials over http... is this something I need to implement myself (i'm doing this right now but feels hacky because i'm using your handleFileRead method)? I'm checking if AP mode is on before showing input fields. Do you have an idea of how best to go about this?

This is what i'm doing now:

server.on("/wifi.htm", handleApException);
server.on("/mqtt.htm", handleApException);

void handleApException(){
  if(WiFi.status() != WL_CONNECTED){
     server.handleFileRead(server.uri()); 
  }else{
    server.send(405, "text/html", "Only allowed in AP mode");
  }
}

Maybe you could handle this automatically by detecting a user specified flag in the file name or a comment in the first line of the file like for example:

wifi-apmode.htm
or

<!-- apmode -->
<html>
...
//encourage users to not acces this page while connected to wifi
persWM.onlyApMode(true);
//Optional: Custom flag to set default : "apmode" 
persWM.onlyApFlag("apmode");
// Optional: A file to redirect to so people can switch to 
// AP mode or get some information etc. 
//default: server.send(405, "text/html","Only allowed in AP mode");
persWM.onlyApFile("/apmode.htm");

Cheers,

Arjen

@arjhun arjhun changed the title Only alowe sending wifi credentials in AP mode Only allow sending wifi credentials in AP mode Dec 13, 2017
@r-downing
Copy link
Owner

Interesting idea, thanks! Should be simple enough to implement. I will think about it for a little bit and get back to you

@donnm
Copy link

donnm commented Apr 7, 2018

I submitted a pull request r-downing/SPIFFSReadServer#1 implementing HTTPS for SPIFFSReadServer that should solve this issue if security is the only concern. In this case just use SPIFFSReadServerSecure instead of SPIFFSReadServer. See the examples for ESP8266WebServerSecure for help with certificates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants