From 41281fc80a588d1f5e46371392b39f55e4764a8f Mon Sep 17 00:00:00 2001 From: Rowan Bohde Date: Mon, 19 Aug 2024 12:58:53 -0500 Subject: [PATCH 1/3] add CfTurnstileSitekey context data to all captcha templates (#31874) In the OpenID flows, the "CfTurnstileSitekey" wasn't populated, which caused those flows to fail if using Turnstile as the Captcha implementation. This adds the missing context variables, allowing Turnstile to be used in the OpenID flows. (cherry picked from commit 0d24c9f383255605d68a92cc5f087c3f16a1d735) --- routers/web/auth/linkaccount.go | 3 +++ routers/web/auth/openid.go | 1 + 2 files changed, 4 insertions(+) diff --git a/routers/web/auth/linkaccount.go b/routers/web/auth/linkaccount.go index f744a57a43..9b0141c14e 100644 --- a/routers/web/auth/linkaccount.go +++ b/routers/web/auth/linkaccount.go @@ -40,6 +40,7 @@ func LinkAccount(ctx *context.Context) { ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL + ctx.Data["CfTurnstileSitekey"] = setting.Service.CfTurnstileSitekey ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration ctx.Data["AllowOnlyInternalRegistration"] = setting.Service.AllowOnlyInternalRegistration ctx.Data["ShowRegistrationButton"] = false @@ -128,6 +129,7 @@ func LinkAccountPostSignIn(ctx *context.Context) { ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL + ctx.Data["CfTurnstileSitekey"] = setting.Service.CfTurnstileSitekey ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration ctx.Data["ShowRegistrationButton"] = false @@ -215,6 +217,7 @@ func LinkAccountPostRegister(ctx *context.Context) { ctx.Data["HcaptchaSitekey"] = setting.Service.HcaptchaSitekey ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL + ctx.Data["CfTurnstileSitekey"] = setting.Service.CfTurnstileSitekey ctx.Data["DisableRegistration"] = setting.Service.DisableRegistration ctx.Data["ShowRegistrationButton"] = false diff --git a/routers/web/auth/openid.go b/routers/web/auth/openid.go index 2143b8096a..83268faacb 100644 --- a/routers/web/auth/openid.go +++ b/routers/web/auth/openid.go @@ -307,6 +307,7 @@ func RegisterOpenID(ctx *context.Context) { ctx.Data["RecaptchaURL"] = setting.Service.RecaptchaURL ctx.Data["McaptchaSitekey"] = setting.Service.McaptchaSitekey ctx.Data["McaptchaURL"] = setting.Service.McaptchaURL + ctx.Data["CfTurnstileSitekey"] = setting.Service.CfTurnstileSitekey ctx.Data["OpenID"] = oid userName, _ := ctx.Session.Get("openid_determined_username").(string) if userName != "" { From bd9edb6fedd22a8135a45e7811627f4958b974df Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 22 Aug 2024 05:05:48 +0800 Subject: [PATCH 2/3] Use correct function name (#31887) (cherry picked from commit 0299bb97f038685aee794a992fa4a9f5cf83652e) --- modules/migration/pullrequest.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/migration/pullrequest.go b/modules/migration/pullrequest.go index 4e7500f0d6..1435991bd2 100644 --- a/modules/migration/pullrequest.go +++ b/modules/migration/pullrequest.go @@ -45,7 +45,7 @@ func (p *PullRequest) GetContext() DownloaderContext { return p.Context } // IsForkPullRequest returns true if the pull request from a forked repository but not the same repository func (p *PullRequest) IsForkPullRequest() bool { - return p.Head.RepoPath() != p.Base.RepoPath() + return p.Head.RepoFullName() != p.Base.RepoFullName() } // GetGitRefName returns pull request relative path to head @@ -62,8 +62,8 @@ type PullRequestBranch struct { OwnerName string `yaml:"owner_name"` } -// RepoPath returns pull request repo path -func (p PullRequestBranch) RepoPath() string { +// RepoFullName returns pull request repo full name +func (p PullRequestBranch) RepoFullName() string { return fmt.Sprintf("%s/%s", p.OwnerName, p.RepoName) } From 930e718afeff3b79abbd9d14f68daea48e9877a3 Mon Sep 17 00:00:00 2001 From: Earl Warren Date: Sun, 25 Aug 2024 17:52:38 +0200 Subject: [PATCH 3/3] chore(release-notes): weekly cherry-pick week 2024-35-v8.0 --- release-notes/5112.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 release-notes/5112.md diff --git a/release-notes/5112.md b/release-notes/5112.md new file mode 100644 index 0000000000..76647d967e --- /dev/null +++ b/release-notes/5112.md @@ -0,0 +1 @@ +fix: [Add CfTurnstileSitekey context data to all captcha templates](https://codeberg.org/forgejo/forgejo/commit/bf07064e40472daa22063d0ac1fb3653008497eb).