From ce09f5593dd2282b204e13f778ee5b9aec98e9da Mon Sep 17 00:00:00 2001 From: wighawag Date: Tue, 10 May 2016 06:04:59 +0100 Subject: [PATCH 1/5] implement html authorization EIP --- embed/authorization.go | 399 +++++++++++++++++++++++++++++++++++++++++ rpc/http.go | 11 ++ 2 files changed, 410 insertions(+) create mode 100644 embed/authorization.go diff --git a/embed/authorization.go b/embed/authorization.go new file mode 100644 index 0000000000..d4fc0ef514 --- /dev/null +++ b/embed/authorization.go @@ -0,0 +1,399 @@ +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...

+
+ +
+
+

+

+ + +
+ + + + + + +` \ No newline at end of file diff --git a/rpc/http.go b/rpc/http.go index 9283ce0ec9..56d4790a99 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -25,6 +25,8 @@ import ( "net/http" "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), From 016d464043851ef2194d8a28cf765bfa6cd2c914 Mon Sep 17 00:00:00 2001 From: wighawag Date: Tue, 10 May 2016 06:07:50 +0100 Subject: [PATCH 2/5] gofmt --- embed/authorization.go | 2 +- rpc/http.go | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/embed/authorization.go b/embed/authorization.go index d4fc0ef514..692fa23b38 100644 --- a/embed/authorization.go +++ b/embed/authorization.go @@ -396,4 +396,4 @@ const AuthorizationHTML = ` -` \ No newline at end of file +` diff --git a/rpc/http.go b/rpc/http.go index 56d4790a99..b2a583b4d0 100644 --- a/rpc/http.go +++ b/rpc/http.go @@ -25,7 +25,7 @@ import ( "net/http" "net/url" "strings" - + "github.com/ethereum/go-ethereum/embed" "github.com/rs/cors" @@ -106,15 +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"{ + + 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 { + 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), From daf89024f59a1f944aa8ad2bf921840f2f6f2f5e Mon Sep 17 00:00:00 2001 From: wighawag Date: Tue, 10 May 2016 18:38:46 +0100 Subject: [PATCH 3/5] improvements --- embed/authorization.go | 64 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/embed/authorization.go b/embed/authorization.go index 692fa23b38..449221d2a7 100644 --- a/embed/authorization.go +++ b/embed/authorization.go @@ -127,13 +127,13 @@ const AuthorizationHTML = `

Please wait...

-
+

- - -
+ + +