aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2019-05-08 22:14:54 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-05-08 22:14:54 +0800
commitab10c1557864566ef3d6ffa3dd8592d9a7c23bd1 (patch)
tree8bd9dcc165433ac2464540e4f60b51ded14d6fd4 /cmd
parent9454508b2327e40e9ce5359864131e57139b18a7 (diff)
downloadgo-tangerine-ab10c1557864566ef3d6ffa3dd8592d9a7c23bd1.tar
go-tangerine-ab10c1557864566ef3d6ffa3dd8592d9a7c23bd1.tar.gz
go-tangerine-ab10c1557864566ef3d6ffa3dd8592d9a7c23bd1.tar.bz2
go-tangerine-ab10c1557864566ef3d6ffa3dd8592d9a7c23bd1.tar.lz
go-tangerine-ab10c1557864566ef3d6ffa3dd8592d9a7c23bd1.tar.xz
go-tangerine-ab10c1557864566ef3d6ffa3dd8592d9a7c23bd1.tar.zst
go-tangerine-ab10c1557864566ef3d6ffa3dd8592d9a7c23bd1.zip
cmd/faucet: sunset Google+ authentication
Diffstat (limited to 'cmd')
-rw-r--r--cmd/faucet/faucet.go42
1 files changed, 6 insertions, 36 deletions
diff --git a/cmd/faucet/faucet.go b/cmd/faucet/faucet.go
index 92d0db990..08b23d46c 100644
--- a/cmd/faucet/faucet.go
+++ b/cmd/faucet/faucet.go
@@ -445,10 +445,14 @@ func (f *faucet) apiHandler(conn *websocket.Conn) {
return
}
continue
+ case strings.HasPrefix(msg.URL, "https://plus.google.com/"):
+ if err = sendError(conn, errors.New("Google+ authentication discontinued as the service was sunset")); err != nil {
+ log.Warn("Failed to send Google+ deprecation to client", "err", err)
+ return
+ }
+ continue
case strings.HasPrefix(msg.URL, "https://twitter.com/"):
username, avatar, address, err = authTwitter(msg.URL)
- case strings.HasPrefix(msg.URL, "https://plus.google.com/"):
- username, avatar, address, err = authGooglePlus(msg.URL)
case strings.HasPrefix(msg.URL, "https://www.facebook.com/"):
username, avatar, address, err = authFacebook(msg.URL)
case *noauthFlag:
@@ -704,40 +708,6 @@ func authTwitter(url string) (string, string, common.Address, error) {
return username + "@twitter", avatar, address, nil
}
-// authGooglePlus tries to authenticate a faucet request using GooglePlus posts,
-// returning the username, avatar URL and Ethereum address to fund on success.
-func authGooglePlus(url string) (string, string, common.Address, error) {
- // Ensure the user specified a meaningful URL, no fancy nonsense
- parts := strings.Split(url, "/")
- if len(parts) < 4 || parts[len(parts)-2] != "posts" {
- return "", "", common.Address{}, errors.New("Invalid Google+ post URL")
- }
- username := parts[len(parts)-3]
-
- // Google's API isn't really friendly with direct links. Still, we don't
- // want to do ask read permissions from users, so just load the public posts and
- // scrape it for the Ethereum address and profile URL.
- res, err := http.Get(url)
- if err != nil {
- return "", "", common.Address{}, err
- }
- defer res.Body.Close()
-
- body, err := ioutil.ReadAll(res.Body)
- if err != nil {
- return "", "", common.Address{}, err
- }
- address := common.HexToAddress(string(regexp.MustCompile("0x[0-9a-fA-F]{40}").Find(body)))
- if address == (common.Address{}) {
- return "", "", common.Address{}, errors.New("No Ethereum address found to fund")
- }
- var avatar string
- if parts = regexp.MustCompile("src=\"([^\"]+googleusercontent.com[^\"]+photo.jpg)\"").FindStringSubmatch(string(body)); len(parts) == 2 {
- avatar = parts[1]
- }
- return username + "@google+", avatar, address, nil
-}
-
// authFacebook tries to authenticate a faucet request using Facebook posts,
// returning the username, avatar URL and Ethereum address to fund on success.
func authFacebook(url string) (string, string, common.Address, error) {