Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recaptcha doesn't work #7870

Closed
2 of 7 tasks
mzch opened this issue Aug 14, 2019 · 7 comments · Fixed by #9083
Closed
2 of 7 tasks

Recaptcha doesn't work #7870

mzch opened this issue Aug 14, 2019 · 7 comments · Fixed by #9083
Labels
Milestone

Comments

@mzch
Copy link
Contributor

mzch commented Aug 14, 2019

Description

Using ReCaptcha, gitea shows captcha_incorrect
...

Screenshots

FireShot_Capture_003

@Mikanoshi
Copy link

Mikanoshi commented Sep 16, 2019

Same on 1.9.2, FreeBSD 11.3, MySQL.

@stale
Copy link

stale bot commented Nov 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you for your contributions.

@stale stale bot added the issue/stale label Nov 15, 2019
@mzch
Copy link
Contributor Author

mzch commented Nov 15, 2019

This issue hasn't fixed in 1.10.0.

@stale stale bot removed the issue/stale label Nov 15, 2019
@zeripath
Copy link
Contributor

Ok, unfortunately the logs you provided didn't give us any helpful information. Which means that it's likely communicating correctly.

Ensure that you have a correct sitekey and secret, and that your URL to recaptcha is correct.

Does Google recaptcha give you any information about what is happening?

There's very little logging in the code - we could add some more. Are you able to build Gitea? If so I could point you in the direction of where to add logging statements.

@mzch
Copy link
Contributor Author

mzch commented Nov 16, 2019

I made sure of my settings and they are correct.
And yes, I can build Gitea from source code. Please instruct where and what code I should add.

@BaxAndrei
Copy link

BaxAndrei commented Nov 19, 2019

I have same problem with v1.10.0. It says RECAPTCHA is incorrect (always) event if correct.

So, I have modified the source code for Recaptcha by adding the following:

func Verify(response string) (bool, error) {
	println("0")
	println(util.URLJoin(setting.Service.RecaptchaURL, apiURL))
	resp, err := http.PostForm(util.URLJoin(setting.Service.RecaptchaURL, apiURL),
		url.Values{"secret": {setting.Service.RecaptchaSecret}, "response": {response}})
	if err != nil {
		println("1")
		return false, fmt.Errorf("Failed to send CAPTCHA response: %s", err)
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		println("2")
		return false, fmt.Errorf("Failed to read CAPTCHA response: %s", err)
	}
	var jsonResponse Response
	err = json.Unmarshal(body, &jsonResponse)
	if err != nil {
		return false, fmt.Errorf("Failed to parse CAPTCHA response: %s", err)
	}

	println("4")
	return jsonResponse.Success, nil
}

First appears in console 0, which means the function was executed, then appears 3.
I never get code 1 (answer could not be sent to google) or code 2 (answer could not be read)
So, the problem is with response code 3.

EDIT: I also added this line println(util.URLJoin(setting.Service.RecaptchaURL, apiURL)) and that is output: https://www.google.com/api/siteverify.

The problem is that /recaptcha/ is missing whether RECAPTCHA_URL is set or not. I guess because of the use of the util.URLJoin. Unfortunately I do not know how to fix the problem because I'm not familiar with GO, but I hope that what I have managed to find is helpful.

@mzch
Copy link
Contributor Author

mzch commented Nov 19, 2019

apiURL is incorrect. Its correct URL is /recaptcha/api/siteverify I made PR.

@lafriks lafriks added this to the 1.10.1 milestone Nov 19, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants