Skip to content

Commit 4271dc7

Browse files
committed
Merge remote-tracking branch 'origin/main' into rmgopls
* origin/main: Fix actions lint (#36029) Fix oauth2 session gob register (#36017)
2 parents fd21692 + 66707bc commit 4271dc7

File tree

12 files changed

+26
-72
lines changed

12 files changed

+26
-72
lines changed

.github/workflows/pull-e2e-tests.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/[email protected]
3939
XGO_PACKAGE ?= src.techknowlogick.com/xgo@latest
4040
GO_LICENSES_PACKAGE ?= github.com/google/go-licenses@v1
4141
GOVULNCHECK_PACKAGE ?= golang.org/x/vuln/cmd/govulncheck@v1
42-
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1
42+
ACTIONLINT_PACKAGE ?= github.com/rhysd/actionlint/cmd/actionlint@v1.7.9
4343

4444
DOCKER_IMAGE ?= gitea/gitea
4545
DOCKER_TAG ?= latest

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ require (
1717
gitea.com/go-chi/binding v0.0.0-20240430071103-39a851e106ed
1818
gitea.com/go-chi/cache v0.2.1
1919
gitea.com/go-chi/captcha v0.0.0-20240315150714-fb487f629098
20-
gitea.com/go-chi/session v0.0.0-20250926004215-636cadd82e15
20+
gitea.com/go-chi/session v0.0.0-20251124165456-68e0254e989e
2121
gitea.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96
2222
gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4
2323
github.com/42wim/httpsig v1.2.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ gitea.com/go-chi/cache v0.2.1 h1:bfAPkvXlbcZxPCpcmDVCWoHgiBSBmZN/QosnZvEC0+g=
4141
gitea.com/go-chi/cache v0.2.1/go.mod h1:Qic0HZ8hOHW62ETGbonpwz8WYypj9NieU9659wFUJ8Q=
4242
gitea.com/go-chi/captcha v0.0.0-20240315150714-fb487f629098 h1:p2ki+WK0cIeNQuqjR98IP2KZQKRzJJiV7aTeMAFwaWo=
4343
gitea.com/go-chi/captcha v0.0.0-20240315150714-fb487f629098/go.mod h1:LjzIOHlRemuUyO7WR12fmm18VZIlCAaOt9L3yKw40pk=
44-
gitea.com/go-chi/session v0.0.0-20250926004215-636cadd82e15 h1:qFYmz05u/s9664o7+XEgrlHXSPQ4uHO8/ccZGUb1uxA=
45-
gitea.com/go-chi/session v0.0.0-20250926004215-636cadd82e15/go.mod h1:0iEpFKnwO5dG0aF98O4eq6FMsAiXkNBaDIlUOlq4BtM=
44+
gitea.com/go-chi/session v0.0.0-20251124165456-68e0254e989e h1:4bugwPyGMLvblEm3pZ8fZProSPVxE4l0UXF2Kv6IJoY=
45+
gitea.com/go-chi/session v0.0.0-20251124165456-68e0254e989e/go.mod h1:KDvcfMUoXfATPHs2mbMoXFTXT45/FAFAS39waz9tPk0=
4646
gitea.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96 h1:+wWBi6Qfruqu7xJgjOIrKVQGiLUZdpKYCZewJ4clqhw=
4747
gitea.com/lunny/dingtalk_webhook v0.0.0-20171025031554-e3534c89ef96/go.mod h1:VyMQP6ue6MKHM8UsOXfNfuMKD0oSAWZdXVcpHIN2yaY=
4848
gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4 h1:IFT+hup2xejHqdhS7keYWioqfmxdnfblFDTGoOwcZ+o=

modules/auth/webauthn/webauthn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ var WebAuthn *webauthn.WebAuthn
2222

2323
// Init initializes the WebAuthn instance from the config.
2424
func Init() {
25-
gob.Register(&webauthn.SessionData{})
25+
gob.Register(&webauthn.SessionData{}) // TODO: CHI-SESSION-GOB-REGISTER.
2626

2727
appURL, _ := protocol.FullyQualifiedOrigin(setting.AppURL)
2828

routers/common/middleware.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package common
55

66
import (
77
"fmt"
8+
"log"
89
"net/http"
910
"strings"
1011

@@ -107,7 +108,11 @@ func ForwardedHeadersHandler(limit int, trustedProxies []string) func(h http.Han
107108
return proxy.ForwardedHeaders(opt)
108109
}
109110

110-
func Sessioner() (func(next http.Handler) http.Handler, error) {
111+
func MustInitSessioner() func(next http.Handler) http.Handler {
112+
// TODO: CHI-SESSION-GOB-REGISTER: chi-session has a design problem: it calls gob.Register for "Set"
113+
// But if the server restarts, then the first "Get" will fail to decode the previously stored session data because the structs are not registered yet.
114+
// So each package should make sure their structs are registered correctly during startup for session storage.
115+
111116
middleware, err := session.Sessioner(session.Options{
112117
Provider: setting.SessionConfig.Provider,
113118
ProviderConfig: setting.SessionConfig.ProviderConfig,
@@ -120,8 +125,7 @@ func Sessioner() (func(next http.Handler) http.Handler, error) {
120125
Domain: setting.SessionConfig.Domain,
121126
})
122127
if err != nil {
123-
return nil, fmt.Errorf("failed to create session middleware: %w", err)
128+
log.Fatalf("common.Sessioner failed: %v", err)
124129
}
125-
126-
return middleware, nil
130+
return middleware
127131
}

routers/install/install.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func getSupportedDbTypeNames() (dbTypeNames []map[string]string) {
5555
return dbTypeNames
5656
}
5757

58-
// Contexter prepare for rendering installation page
59-
func Contexter() func(next http.Handler) http.Handler {
58+
// installContexter prepare for rendering installation page
59+
func installContexter() func(next http.Handler) http.Handler {
6060
rnd := templates.HTMLRenderer()
6161
dbTypeNames := getSupportedDbTypeNames()
6262
envConfigKeys := setting.CollectEnvConfigKeys()

routers/install/routes.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"html"
99
"net/http"
1010

11-
"code.gitea.io/gitea/modules/log"
1211
"code.gitea.io/gitea/modules/public"
1312
"code.gitea.io/gitea/modules/setting"
1413
"code.gitea.io/gitea/modules/web"
@@ -25,11 +24,8 @@ func Routes() *web.Router {
2524
base.Methods("GET, HEAD", "/assets/*", public.FileHandlerFunc())
2625

2726
r := web.NewRouter()
28-
if sessionMid, err := common.Sessioner(); err == nil && sessionMid != nil {
29-
r.Use(sessionMid, Contexter())
30-
} else {
31-
log.Fatal("common.Sessioner failed: %v", err)
32-
}
27+
r.Use(common.MustInitSessioner(), installContexter())
28+
3329
r.Get("/", Install) // it must be on the root, because the "install.js" use the window.location to replace the "localhost" AppURL
3430
r.Post("/", web.Bind(forms.InstallForm{}), SubmitInstall)
3531
r.Get("/post-install", InstallDone)

routers/web/auth/oauth.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,11 @@ type LinkAccountData struct {
277277
GothUser goth.User
278278
}
279279

280+
func init() {
281+
gob.Register(LinkAccountData{}) // TODO: CHI-SESSION-GOB-REGISTER
282+
}
283+
280284
func oauth2GetLinkAccountData(ctx *context.Context) *LinkAccountData {
281-
gob.Register(LinkAccountData{})
282285
v, ok := ctx.Session.Get("linkAccountData").(LinkAccountData)
283286
if !ok {
284287
return nil
@@ -287,7 +290,6 @@ func oauth2GetLinkAccountData(ctx *context.Context) *LinkAccountData {
287290
}
288291

289292
func Oauth2SetLinkAccountData(ctx *context.Context, linkAccountData LinkAccountData) error {
290-
gob.Register(LinkAccountData{})
291293
return updateSession(ctx, nil, map[string]any{
292294
"linkAccountData": linkAccountData,
293295
})

routers/web/web.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,7 @@ func Routes() *web.Router {
267267
routes.Get("/ssh_info", misc.SSHInfo)
268268
routes.Get("/api/healthz", healthcheck.Check)
269269

270-
if sessionMid, err := common.Sessioner(); err == nil && sessionMid != nil {
271-
mid = append(mid, sessionMid, context.Contexter())
272-
} else {
273-
log.Fatal("common.Sessioner failed: %v", err)
274-
}
270+
mid = append(mid, common.MustInitSessioner(), context.Contexter())
275271

276272
// Get user from session if logged in.
277273
mid = append(mid, webAuth(buildAuthGroup()))

0 commit comments

Comments
 (0)