Skip to content

Commit dc778a4

Browse files
authored
Merge branch 'main' into org-oauth2
2 parents 6c4770d + 34f509e commit dc778a4

File tree

8 files changed

+42
-12
lines changed

8 files changed

+42
-12
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ steps:
573573
- name: test-e2e
574574
image: mcr.microsoft.com/playwright:v1.24.0-focal
575575
commands:
576-
- curl -sLO https://go.dev/dl/go1.18.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.18.linux-amd64.tar.gz
576+
- curl -sLO https://go.dev/dl/go1.19.linux-amd64.tar.gz && tar -C /usr/local -xzf go1.19.linux-amd64.tar.gz
577577
- groupadd --gid 1001 gitea && useradd -m --gid 1001 --uid 1001 gitea
578578
- apt-get -qq update && apt-get -qqy install build-essential
579579
- export TEST_PGSQL_SCHEMA=''

docs/content/doc/upgrade/from-gitea.en-us.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
date: "2021-09-02T16:00:00+08:00"
33
title: "Upgrade from an old Gitea"
4+
aliases:
5+
- /en-us/upgrade/
46
slug: "upgrade-from-gitea"
57
weight: 10
68
toc: false

docs/static/_redirects

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,7 @@ https://gitea-docs.netlify.com/* https://docs.gitea.io/:splat 302!
1010
/en-us/ci-cd/ /en-us/integrations/ 302!
1111
/en-us/third-party-tools/ /en-us/integrations/ 302!
1212
/en-us/make/ /en-us/hacking-on-gitea/ 302!
13+
/en-us/upgrade/ /en-us/upgrade-from-gitea/ 302!
14+
/fr-fr/upgrade/ /fr-fr/upgrade-from-gitea/ 302!
15+
/zh-cn/upgrade/ /zh-cn/upgrade-from-gitea/ 302!
16+
/zh-tw/upgrade/ /zh-tw/upgrade-from-gitea/ 302!

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ require (
3535
github.com/go-ap/jsonld v0.0.0-20220917142617-76bf51585778
3636
github.com/go-chi/chi/v5 v5.0.7
3737
github.com/go-chi/cors v1.2.1
38-
github.com/go-enry/go-enry/v2 v2.8.2
38+
github.com/go-enry/go-enry/v2 v2.8.3
3939
github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e
4040
github.com/go-git/go-billy/v5 v5.3.1
4141
github.com/go-git/go-git/v5 v5.4.3-0.20220529141257-bc1f419cebcf

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8=
485485
github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8=
486486
github.com/go-chi/cors v1.2.1 h1:xEC8UT3Rlp2QuWNEr4Fs/c2EAGVKBwy/1vHx3bppil4=
487487
github.com/go-chi/cors v1.2.1/go.mod h1:sSbTewc+6wYHBBCW7ytsFSn836hqM7JxpglAy2Vzc58=
488-
github.com/go-enry/go-enry/v2 v2.8.2 h1:uiGmC+3K8sVd/6DOe2AOJEOihJdqda83nPyJNtMR8RI=
489-
github.com/go-enry/go-enry/v2 v2.8.2/go.mod h1:GVzIiAytiS5uT/QiuakK7TF1u4xDab87Y8V5EJRpsIQ=
488+
github.com/go-enry/go-enry/v2 v2.8.3 h1:BwvNrN58JqBJhyyVdZSl5QD3xoxEEGYUrRyPh31FGhw=
489+
github.com/go-enry/go-enry/v2 v2.8.3/go.mod h1:GVzIiAytiS5uT/QiuakK7TF1u4xDab87Y8V5EJRpsIQ=
490490
github.com/go-enry/go-oniguruma v1.2.1 h1:k8aAMuJfMrqm/56SG2lV9Cfti6tC4x8673aHCcBk+eo=
491491
github.com/go-enry/go-oniguruma v1.2.1/go.mod h1:bWDhYP+S6xZQgiRL7wlTScFYBe023B6ilRZbCAD5Hf4=
492492
github.com/go-fed/httpsig v1.1.1-0.20201223112313-55836744818e h1:oRq/fiirun5HqlEWMLIcDmLpIELlG4iGbd0s8iqgPi8=

playwright.config.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,13 @@ export default {
6464
},
6565
},
6666

67-
{
68-
name: 'firefox',
69-
use: {
70-
...devices['Desktop Firefox'],
71-
},
72-
},
67+
// disabled because of https://github.com/go-gitea/gitea/issues/21355
68+
// {
69+
// name: 'firefox',
70+
// use: {
71+
// ...devices['Desktop Firefox'],
72+
// },
73+
// },
7374

7475
{
7576
name: 'webkit',

routers/web/auth/oauth.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,8 @@ func OIDCKeys(ctx *context.Context) {
588588
// AccessTokenOAuth manages all access token requests by the client
589589
func AccessTokenOAuth(ctx *context.Context) {
590590
form := *web.GetForm(ctx).(*forms.AccessTokenForm)
591-
if form.ClientID == "" {
591+
// if there is no ClientID or ClientSecret in the request body, fill these fields by the Authorization header and ensure the provided field matches the Authorization header
592+
if form.ClientID == "" || form.ClientSecret == "" {
592593
authHeader := ctx.Req.Header.Get("Authorization")
593594
authContent := strings.SplitN(authHeader, " ", 2)
594595
if len(authContent) == 2 && authContent[0] == "Basic" {
@@ -608,7 +609,21 @@ func AccessTokenOAuth(ctx *context.Context) {
608609
})
609610
return
610611
}
612+
if form.ClientID != "" && form.ClientID != pair[0] {
613+
handleAccessTokenError(ctx, AccessTokenError{
614+
ErrorCode: AccessTokenErrorCodeInvalidRequest,
615+
ErrorDescription: "client_id in request body inconsistent with Authorization header",
616+
})
617+
return
618+
}
611619
form.ClientID = pair[0]
620+
if form.ClientSecret != "" && form.ClientSecret != pair[1] {
621+
handleAccessTokenError(ctx, AccessTokenError{
622+
ErrorCode: AccessTokenErrorCodeInvalidRequest,
623+
ErrorDescription: "client_secret in request body inconsistent with Authorization header",
624+
})
625+
return
626+
}
612627
form.ClientSecret = pair[1]
613628
}
614629
}
@@ -686,9 +701,13 @@ func handleAuthorizationCode(ctx *context.Context, form forms.AccessTokenForm, s
686701
return
687702
}
688703
if !app.ValidateClientSecret([]byte(form.ClientSecret)) {
704+
errorDescription := "invalid client secret"
705+
if form.ClientSecret == "" {
706+
errorDescription = "invalid empty client secret"
707+
}
689708
handleAccessTokenError(ctx, AccessTokenError{
690709
ErrorCode: AccessTokenErrorCodeUnauthorizedClient,
691-
ErrorDescription: "invalid client secret",
710+
ErrorDescription: errorDescription,
692711
})
693712
return
694713
}

services/auth/session.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func (s *Session) Verify(req *http.Request, w http.ResponseWriter, store DataSto
3939

4040
// SessionUser returns the user object corresponding to the "uid" session variable.
4141
func SessionUser(sess SessionStore) *user_model.User {
42+
if sess == nil {
43+
return nil
44+
}
45+
4246
// Get user ID
4347
uid := sess.Get("uid")
4448
if uid == nil {

0 commit comments

Comments
 (0)