Skip to content

Commit 3e74010

Browse files
committed
fix
1 parent da0b2cb commit 3e74010

File tree

2 files changed

+4
-26
lines changed

2 files changed

+4
-26
lines changed

services/auth/oauth2.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@ var (
2727

2828
// CheckOAuthAccessToken returns uid of user from oauth token
2929
func CheckOAuthAccessToken(ctx context.Context, accessToken string) int64 {
30-
// JWT tokens require a "."
31-
if !strings.Contains(accessToken, ".") {
30+
if !setting.OAuth2.Enabled {
3231
return 0
3332
}
34-
if !setting.OAuth2.Enabled {
33+
34+
// JWT tokens require a ".", if the token isn't like that, return early
35+
if !strings.Contains(accessToken, ".") {
3536
return 0
3637
}
3738

tests/integration/oauth_test.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import (
77
"bytes"
88
"io"
99
"net/http"
10-
"net/url"
1110
"testing"
1211

13-
auth_model "code.gitea.io/gitea/models/auth"
1412
"code.gitea.io/gitea/modules/json"
1513
"code.gitea.io/gitea/modules/setting"
1614
oauth2_provider "code.gitea.io/gitea/services/oauth2_provider"
@@ -479,24 +477,3 @@ func TestOAuthIntrospection(t *testing.T) {
479477
resp = MakeRequest(t, req, http.StatusUnauthorized)
480478
assert.Contains(t, resp.Body.String(), "no valid authorization")
481479
}
482-
483-
func TestGitOpWithOAuthDisabled(t *testing.T) {
484-
defer tests.PrepareTestEnv(t)()
485-
486-
setting.OAuth2.Enabled = false
487-
defer func() {
488-
setting.OAuth2.Enabled = true
489-
}()
490-
491-
onGiteaRun(t, func(t *testing.T, u *url.URL) {
492-
httpContext := NewAPITestContext(t, "user2", "repo1", auth_model.AccessTokenScopeWriteRepository)
493-
494-
u.Path = httpContext.GitPath()
495-
dstPath := t.TempDir()
496-
497-
u.Path = httpContext.GitPath()
498-
u.User = url.UserPassword("user2", userPassword)
499-
500-
t.Run("Clone", doGitClone(dstPath, u))
501-
})
502-
}

0 commit comments

Comments
 (0)