diff --git a/embed/authorization.go b/embed/authorization.go new file mode 100644 index 0000000000..dc69c3639d --- /dev/null +++ b/embed/authorization.go @@ -0,0 +1,510 @@ +package embed + +// AuthorizationHTML contains the html file content to support transaction authorization via popup without the need for CORS +const AuthorizationHTML = ` + + + + Ethereum Authorization + + + + + + + +
+
+

Please wait...

+
+ +
+
+

+

+ + +
+ + + + + + +` diff --git a/rpc/http.go b/rpc/http.go index 9283ce0ec9..b2a583b4d0 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -26,6 +26,8 @@ import ( "net/url" "strings" + "github.com/ethereum/go-ethereum/embed" + "github.com/rs/cors" ) @@ -104,6 +106,15 @@ func (t *httpReadWriteNopCloser) Close() error { // send the request to the given API provider and sends the response back to the caller. func newJSONHTTPHandler(srv *Server) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { + + if r.URL.Path == "/authorization.html" { + w.Header().Set("Content-Type", "text/html; charset=utf-8") + if _, err := w.Write([]byte(embed.AuthorizationHTML)); err != nil { + fmt.Fprintf(w, "%s", err) + } + return + } + if r.ContentLength > maxHTTPRequestContentLength { http.Error(w, fmt.Sprintf("content length too large (%d>%d)", r.ContentLength, maxHTTPRequestContentLength),