-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
hCaptcha Support #12594
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
Merged
Merged
hCaptcha Support #12594
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
85e49dd
Initial work on hCaptcha
jolheiser 39bb157
Use module
jolheiser 25f21ff
Merge branch 'master' of github.com:go-gitea/gitea into hcaptcha
jolheiser 8f50b3c
Format
jolheiser b36fa3e
At least return and debug log a captcha error
jolheiser 8b9254f
Merge branch 'master' of github.com:go-gitea/gitea into hcaptcha
jolheiser 2a1877b
Pass context to hCaptcha
jolheiser 46f7592
Add context to recaptcha
jolheiser 41c0ad4
fix lint
zeripath 7a52ab7
Merge remote-tracking branch 'origin/master' into hcaptcha
zeripath 1fb2a2e
Merge remote-tracking branch 'origin/master' into hcaptcha
zeripath 715c8f0
Merge branch 'master' of github.com:go-gitea/gitea into hcaptcha
jolheiser 8ed5d8e
Finish hcaptcha
jolheiser 8b3e095
Update example config
jolheiser d60cdf7
Apply error fix for recaptcha
jolheiser b1ad889
Change recaptcha ChallengeTS to string
jolheiser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2020 The Gitea Authors. All rights reserved. | ||
// Use of this source code is governed by a MIT-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package hcaptcha | ||
|
||
import ( | ||
"context" | ||
|
||
"code.gitea.io/gitea/modules/setting" | ||
|
||
"go.jolheiser.com/hcaptcha" | ||
) | ||
|
||
// Verify calls hCaptcha API to verify token | ||
func Verify(ctx context.Context, response string) (bool, error) { | ||
client, err := hcaptcha.New(setting.Service.HcaptchaSecret, hcaptcha.WithContext(ctx)) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
resp, err := client.Verify(response, hcaptcha.PostOptions{ | ||
Sitekey: setting.Service.HcaptchaSitekey, | ||
}) | ||
if err != nil { | ||
return false, err | ||
} | ||
|
||
var respErr error | ||
if len(resp.ErrorCodes) > 0 { | ||
respErr = resp.ErrorCodes[0] | ||
} | ||
return resp.Success, respErr | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ const ( | |
const ( | ||
ImageCaptcha = "image" | ||
ReCaptcha = "recaptcha" | ||
HCaptcha = "hcaptcha" | ||
) | ||
|
||
// settings | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.