aboutsummaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-11-12 13:33:35 -0800
committerGitHub <noreply@github.com>2024-11-12 21:33:35 +0000
commit840ad7eefe2b49ab453b9a89b153a264a8c9f8a2 (patch)
treebe325a516ed5f8e0d9847883d50cd2464d470bef /services
parent5bed7b9ec0d8df068ce7ff055590c1237dce5537 (diff)
downloadgitea-840ad7eefe2b49ab453b9a89b153a264a8c9f8a2.tar.gz
gitea-840ad7eefe2b49ab453b9a89b153a264a8c9f8a2.zip
Disable Oauth check if oauth disabled (#32368)
Fix #32367 --------- Co-authored-by: Giteabot <teabot@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'services')
-rw-r--r--services/auth/oauth2.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/services/auth/oauth2.go b/services/auth/oauth2.go
index 523998a634..d0aec085b1 100644
--- a/services/auth/oauth2.go
+++ b/services/auth/oauth2.go
@@ -27,10 +27,15 @@ var (
// CheckOAuthAccessToken returns uid of user from oauth token
func CheckOAuthAccessToken(ctx context.Context, accessToken string) int64 {
- // JWT tokens require a "."
+ if !setting.OAuth2.Enabled {
+ return 0
+ }
+
+ // JWT tokens require a ".", if the token isn't like that, return early
if !strings.Contains(accessToken, ".") {
return 0
}
+
token, err := oauth2_provider.ParseToken(accessToken, oauth2_provider.DefaultSigningKey)
if err != nil {
log.Trace("oauth2.ParseToken: %v", err)