Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

HTTPUpdateServer Allow external POSTS (CORS)#6824

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
d-a-v merged 8 commits intoesp8266:masterfromhookedupjoe:master
Jun 27, 2022

Conversation

@hookedupjoe
Copy link
Contributor

@hookedupjoehookedupjoe commentedNov 22, 2019
edited by d-a-v
Loading

This update is to allow the ESP8266HTTPUpdateServer to receive a cross cors POST update from an external domain. This is needed for web based apps / mobile apps to flash using a standard AJAX post from an external device.

Code Used (in case anyone else wants to use Ajax to POST a flash update)
Note: Using XHR direct for blob, less code then jQuery, then jQuery for standard post. Just console the reply to keep it simple for reuse.

functiondoFlashUpdate(theFilePath, thePostURL){  var dfd = jQuery.Deferred();try {    var oReq =newXMLHttpRequest();    oReq.open("GET", theFilePath +"?open&time=" +newDate().getTime(),true);    oReq.responseType ="blob";    oReq.onload =function(oEvent) {      var blob = oReq.response;      var fd =newFormData();      fd.append('firmware', blob);      $.ajax({          type:'POST',          url: thePostURL,          timeout:20000,          data: fd,          processData:false,          contentType:false      }).fail(function(data) {//--- or fail depending on how you want to work it, but I read the reply for failure / success          dfd.resolve("Timedout.  Check network connection and try again.");      }).done(function(data) {          dfd.resolve(data);      });    };    oReq.send();     }catch(ex) {    dfd.resolve(false);  }return dfd.promise();}

Security Notes:

  • Even without CORS headers set, anyone can update remotely using CURL or a program like PostMan. For that reason, allowing cross domain access in this way not going to open up security options for a real hacker that wouldn't be using a web browser to hack your device.

  • If desired, this can be added as an optional feature, but due to the above note - didn't see a need as it doesn't really do anything. Using real security is the only way to really secure your system from hacker update (along with physical security of course).

    (open for comment / feedback on that assertion).

Copy link
Collaborator

@devytedevyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Codewise this looks ok to me. Need confirmation from 3rd party to merge.

@d-a-vd-a-v added this to the3.1 milestoneJul 11, 2021
@d-a-vd-a-v merged commit678a477 intoesp8266:masterJun 27, 2022
hasenradball pushed a commit to hasenradball/Arduino that referenced this pull requestNov 18, 2024
* HTTPUpdateServer Allow external POSTS (CORS)* Format Updates - POST HTTPUpdateServerCo-authored-by: Joseph Francis <joefran@us.ibm.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@devytedevytedevyte approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@hookedupjoe@devyte@d-a-v@joefran@earlephilhower

[8]ページ先頭

©2009-2025 Movatter.jp