Skip to content

Commit 46aa739

Browse files
committed
Remove the remoteip parameter for Turnstile
1 parent f178ef4 commit 46aa739

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

modules/context/captcha.go

+1-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package context
55

66
import (
77
"fmt"
8-
"net"
98
"sync"
109

1110
"code.gitea.io/gitea/modules/base"
@@ -78,12 +77,7 @@ func VerifyCaptcha(ctx *Context, tpl base.TplName, form interface{}) {
7877
case setting.MCaptcha:
7978
valid, err = mcaptcha.Verify(ctx, ctx.Req.Form.Get(mCaptchaResponseField))
8079
case setting.CfTurnstile:
81-
var ip string
82-
ip, _, err = net.SplitHostPort(ctx.RemoteAddr())
83-
if err != nil {
84-
break
85-
}
86-
valid, err = turnstile.Verify(ctx, ctx.Req.Form.Get(cfTurnstileResponseField), ip)
80+
valid, err = turnstile.Verify(ctx, ctx.Req.Form.Get(cfTurnstileResponseField))
8781
default:
8882
ctx.ServerError("Unknown Captcha Type", fmt.Errorf("Unknown Captcha Type: %s", setting.Service.CaptchaType))
8983
return

modules/turnstile/turnstile.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,11 @@ type Response struct {
2626
}
2727

2828
// Verify calls Cloudflare Turnstile API to verify token
29-
func Verify(ctx context.Context, response, ip string) (bool, error) {
29+
func Verify(ctx context.Context, response string) (bool, error) {
3030
// Cloudflare turnstile official access instruction address: https://developers.cloudflare.com/turnstile/get-started/server-side-validation/
3131
post := url.Values{
3232
"secret": {setting.Service.CfTurnstileSecret},
3333
"response": {response},
34-
"remoteip": {ip},
3534
}
3635
// Basically a copy of http.PostForm, but with a context
3736
req, err := http.NewRequestWithContext(ctx, http.MethodPost,

0 commit comments

Comments
 (0)