-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Digest Authentication in Webserver Library #3053
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
a4020cc
Add Digest Auth
9d7397a
Check for Opaque and Nonce
e8c35d9
Remove Serial Debug and fix Indentation
b2bf0f2
Merge remote-tracking branch 'MainESP/master' into DigestAuth
28f572b
Added example sketch with documentation,Fixed indentation and Defaults
d7fda10
Merge branch 'master' into DigestAuth
12e0d10
Merge branch 'master' into DigestAuth
Lan-Hekary 7338ec5
Merge branch 'master' into DigestAuth
Lan-Hekary 858977b
Merge branch 'master' into DigestAuth
Lan-Hekary dd839af
Merge branch 'Master' into DigestAuth
4f6de29
Merge branch 'master' into DigestAuth
Lan-Hekary 1ffc141
Merge branch 'master' into DigestAuth
igrr 36940cd
Merge branch 'master' into DigestAuth
Lan-Hekary f91b58c
Merge branch 'master' into DigestAuth
Lan-Hekary 91d9cc1
Digest Authentication minor changes + new padded 32 digit random func…
Lan-Hekary e0a9538
Merge branch 'master' into DigestAuth
Lan-Hekary 2ea36fb
update license to public domain
Lan-Hekary 282babb
Merge branch 'master' into DigestAuth
Lan-Hekary 0b945f8
Merge branch 'master' into DigestAuth
Lan-Hekary 35b7c0a
renaming functions
Lan-Hekary File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ tools/sdk/lwip/src/build | |
tools/sdk/lwip/src/liblwip_src.a | ||
|
||
*.pyc | ||
*.gch |
57 changes: 57 additions & 0 deletions
57
libraries/ESP8266WebServer/examples/HttpAdvancedAuth/HttpAdvancedAuth.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
HTTP Advanced Authentication example | ||
Created Mar 16, 2017 by Ahmed El-Sharnoby. | ||
This example code is in the public domain. | ||
*/ | ||
|
||
#include <ESP8266WiFi.h> | ||
#include <ESP8266mDNS.h> | ||
#include <ArduinoOTA.h> | ||
#include <ESP8266WebServer.h> | ||
|
||
const char* ssid = "........"; | ||
const char* password = "........"; | ||
|
||
ESP8266WebServer server(80); | ||
|
||
const char* www_username = "admin"; | ||
const char* www_password = "esp8266"; | ||
// allows you to set the realm of authentication Default:"Login Required" | ||
const char* www_realm = "Custom Auth Realm"; | ||
// the Content of the HTML response in case of Unautherized Access Default:empty | ||
String authFailResponse = "Authentication Failed"; | ||
|
||
void setup() { | ||
Serial.begin(115200); | ||
WiFi.mode(WIFI_STA); | ||
WiFi.begin(ssid, password); | ||
if(WiFi.waitForConnectResult() != WL_CONNECTED) { | ||
Serial.println("WiFi Connect Failed! Rebooting..."); | ||
delay(1000); | ||
ESP.restart(); | ||
} | ||
ArduinoOTA.begin(); | ||
|
||
server.on("/", [](){ | ||
if(!server.authenticate(www_username, www_password)) | ||
//Basic Auth Method with Custom realm and Failure Response | ||
//return server.requestAuthentication(BASIC_AUTH, www_realm, authFailResponse); | ||
//Digest Auth Method with realm="Login Required" and empty Failure Response | ||
//return server.requestAuthentication(DIGEST_AUTH); | ||
//Digest Auth Method with Custom realm and empty Failure Response | ||
//return server.requestAuthentication(DIGEST_AUTH, www_realm); | ||
//Digest Auth Method with Custom realm and Failure Response | ||
return server.requestAuthentication(DIGEST_AUTH, www_realm, authFailResponse); | ||
server.send(200, "text/plain", "Login OK"); | ||
}); | ||
server.begin(); | ||
|
||
Serial.print("Open http://"); | ||
Serial.print(WiFi.localIP()); | ||
Serial.println("/ in your browser to see it working"); | ||
} | ||
|
||
void loop() { | ||
ArduinoOTA.handle(); | ||
server.handleClient(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a public domain / CC0 license at the top of the sketch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I copied this sketch from the HttpBasicAuth folder and it does not have a license ..
I am not sure of what should I put here ..
can you give an Example ??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. https://github.com/esp8266/Arduino/blob/master/libraries/esp8266/examples/Blink/Blink.ino#L1-L4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, i mean public domain license, as in Blink example. It has been mentioned before that using LGPL license on examples is too restrictive. We already have a few such examples, and it would be better to migrate all the examples to CC0/public domain license.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry I just copied the license from the next sketch in the folder .
fixed it now