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

Password protected server #80

Closed
mungle opened this issue Nov 3, 2020 · 2 comments
Closed

Password protected server #80

mungle opened this issue Nov 3, 2020 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@mungle
Copy link

mungle commented Nov 3, 2020

I was trying to password protect the web stream following this link:
https://microcontrollerslab.com/esp32-password-protected-web-server-in-arduino-ide/
but I'm not really able to find the piece of code where to implement this.

Any help, suggestions, alternatives? Thank you!

@easytarget
Copy link
Owner

easytarget commented Nov 8, 2020

Hi, thanks for the question.
I struggled to understand the example there for a bit; it works, I tried it out on a spare development board. The secret is returning the 401 Unauthorized followed by WWW-Authenticate in response to the first connection attempt (lines 76/77), this triggers the authentication prompt when needed.

Anyway.. the short answer is to strongly emphasise that this cam server has no secure wifi connection, so any serious snooper will be able to trivially sniff your connections and bypass any protections you may establish. Until SSL is implemented ( #54 ) the best you are doing is guarding against unsophisticated casual access.

The longer answer is that you can modify the stream and capture handlers in app_httpd.cpp with the same authentication test and response. When the handler is called you initially test the request headers and send the appropriate 401 response if they lack authentication. This would protect the images but leave the control pages unprotected.
To protect the whole server you would need to do this to /every/ handler for all the various pages. At which point it is better to look at some of the more complex solutions with a separate login page and cookies used to authenticate after login.

@easytarget easytarget added the duplicate This issue or pull request already exists label Nov 19, 2020
@easytarget
Copy link
Owner

No followup, covered by #54 . closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants