-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Add support mCaptcha as captcha provider #20458
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
Changes from 6 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
d56af8e
Add config stuff
46be033
Load mCaptcha on register page
62ea258
Code-style
75d079d
Implement backend verification
614ad0b
Add copyright text
df5f337
Merge branch 'main' into add-mcaptcha
5015c38
Don't use hardcoded instance
890c583
Merge branch 'main' into add-mcaptcha
46fd68f
Merge branch 'main' into add-mcaptcha
3c84682
Merge branch 'main' into add-mcaptcha
d7c5033
Nit pick
747c47b
Merge branch 'main' into add-mcaptcha
773f07e
Merge branch 'main' into add-mcaptcha
6543 06c6c95
Apply suggestions from code review
6543 9ed76bb
Merge branch 'main' into add-mcaptcha
6543 668a701
Merge branch 'master' into add-mcaptcha
6543 4c52706
fix lint
6543 08790c5
Merge branch 'main' into add-mcaptcha
0789b33
Hack mobile CSS together
d29138b
Merge branch 'main' into add-mcaptcha
6543 c866103
Update mCaptcha-glue
9208741
Merge branch 'main' into add-mcaptcha
f4e417b
Use `<span>` instead of `<label>`
4ea9eb4
Merge branch 'main' into add-mcaptcha
eccc205
Merge branch 'main' into add-mcaptcha
db8a806
Merge branch 'main' into add-mcaptcha
5f219f2
Merge branch 'main' into add-mcaptcha
559cf0d
Fix incorrect formatting
24d059b
Merge branch 'main' into add-mcaptcha
540ae07
Fix borked package-lock.json
3b1c008
Merge branch 'main' into add-mcaptcha
6543 a1d9503
Merge branch 'main' into add-mcaptcha
6543 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2022 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 mcaptcha | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"code.gitea.io/gitea/modules/setting" | ||
|
||
"codeberg.org/gusted/mcaptcha" | ||
) | ||
|
||
func Verify(ctx context.Context, token string) (bool, error) { | ||
valid, err := mcaptcha.Verify(ctx, &mcaptcha.VerifyOpts{ | ||
InstanceURL: setting.Service.McaptchaURL, | ||
Sitekey: setting.Service.McaptchaSitekey, | ||
Secret: setting.Service.McaptchaSecret, | ||
Token: token, | ||
}) | ||
if err != nil { | ||
return false, fmt.Errorf("wasn't able to verify mCaptcha: %v", err) | ||
} | ||
return valid, nil | ||
} |
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.
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
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,17 @@ | ||
export async function initMcaptcha() { | ||
const siteKeyEl = document.querySelector('.m-captcha'); | ||
if (!siteKeyEl) { | ||
return; | ||
} | ||
|
||
const {default: mCaptcha} = await import(/* webpackChunkName: "mcaptcha-vanilla-glue" */'@mcaptcha/vanilla-glue'); | ||
mCaptcha.INPUT_NAME = 'm-captcha-response'; | ||
const siteKey = siteKeyEl.getAttribute('data-sitekey'); | ||
|
||
mCaptcha.default({ | ||
siteKey: { | ||
instanceUrl: new URL('http://localhost:7000'), | ||
Gusted marked this conversation as resolved.
Show resolved
Hide resolved
|
||
key: siteKey, | ||
} | ||
}); | ||
} |
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
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.