|
|
|
@ -77,9 +77,6 @@ var ( |
|
|
|
|
accJSONFlag = flag.String("account.json", "", "Key json file to fund user requests with") |
|
|
|
|
accPassFlag = flag.String("account.pass", "", "Decryption password to access faucet funds") |
|
|
|
|
|
|
|
|
|
githubUser = flag.String("github.user", "", "GitHub user to authenticate with for Gist access") |
|
|
|
|
githubToken = flag.String("github.token", "", "GitHub personal token to access Gists with") |
|
|
|
|
|
|
|
|
|
captchaToken = flag.String("captcha.token", "", "Recaptcha site key to authenticate client side") |
|
|
|
|
captchaSecret = flag.String("captcha.secret", "", "Recaptcha secret key to authenticate server side") |
|
|
|
|
|
|
|
|
@ -638,59 +635,6 @@ func sendSuccess(conn *websocket.Conn, msg string) error { |
|
|
|
|
return send(conn, map[string]string{"success": msg}, time.Second) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// authGitHub tries to authenticate a faucet request using GitHub gists, returning
|
|
|
|
|
// the username, avatar URL and Ethereum address to fund on success.
|
|
|
|
|
func authGitHub(url string) (string, string, common.Address, error) { |
|
|
|
|
// Retrieve the gist from the GitHub Gist APIs
|
|
|
|
|
parts := strings.Split(url, "/") |
|
|
|
|
req, _ := http.NewRequest("GET", "https://api.github.com/gists/"+parts[len(parts)-1], nil) |
|
|
|
|
if *githubUser != "" { |
|
|
|
|
req.SetBasicAuth(*githubUser, *githubToken) |
|
|
|
|
} |
|
|
|
|
res, err := http.DefaultClient.Do(req) |
|
|
|
|
if err != nil { |
|
|
|
|
return "", "", common.Address{}, err |
|
|
|
|
} |
|
|
|
|
var gist struct { |
|
|
|
|
Owner struct { |
|
|
|
|
Login string `json:"login"` |
|
|
|
|
} `json:"owner"` |
|
|
|
|
Files map[string]struct { |
|
|
|
|
Content string `json:"content"` |
|
|
|
|
} `json:"files"` |
|
|
|
|
} |
|
|
|
|
err = json.NewDecoder(res.Body).Decode(&gist) |
|
|
|
|
res.Body.Close() |
|
|
|
|
if err != nil { |
|
|
|
|
return "", "", common.Address{}, err |
|
|
|
|
} |
|
|
|
|
if gist.Owner.Login == "" { |
|
|
|
|
return "", "", common.Address{}, errors.New("Anonymous Gists not allowed") |
|
|
|
|
} |
|
|
|
|
// Iterate over all the files and look for Ethereum addresses
|
|
|
|
|
var address common.Address |
|
|
|
|
for _, file := range gist.Files { |
|
|
|
|
content := strings.TrimSpace(file.Content) |
|
|
|
|
if len(content) == 2+common.AddressLength*2 { |
|
|
|
|
address = common.HexToAddress(content) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if address == (common.Address{}) { |
|
|
|
|
return "", "", common.Address{}, errors.New("No Ethereum address found to fund") |
|
|
|
|
} |
|
|
|
|
// Validate the user's existence since the API is unhelpful here
|
|
|
|
|
if res, err = http.Head("https://github.com/" + gist.Owner.Login); err != nil { |
|
|
|
|
return "", "", common.Address{}, err |
|
|
|
|
} |
|
|
|
|
res.Body.Close() |
|
|
|
|
|
|
|
|
|
if res.StatusCode != 200 { |
|
|
|
|
return "", "", common.Address{}, errors.New("Invalid user... boom!") |
|
|
|
|
} |
|
|
|
|
// Everything passed validation, return the gathered infos
|
|
|
|
|
return gist.Owner.Login + "@github", fmt.Sprintf("https://github.com/%s.png?size=64", gist.Owner.Login), address, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// authTwitter tries to authenticate a faucet request using Twitter posts, returning
|
|
|
|
|
// the username, avatar URL and Ethereum address to fund on success.
|
|
|
|
|
func authTwitter(url string) (string, string, common.Address, error) { |
|
|
|
|