From 26437a03b0dc429e179ef0461e83ecb1b1474017 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Tue, 12 Nov 2024 14:09:47 +0800 Subject: [PATCH] Disable Oauth check if oauth disabled (#32368) (#32480) Partially backport Disable Oauth check if oauth disabled #32368 --- services/auth/oauth2.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/services/auth/oauth2.go b/services/auth/oauth2.go index 46d8510143..861effd0b0 100644 --- a/services/auth/oauth2.go +++ b/services/auth/oauth2.go @@ -27,6 +27,9 @@ var ( // CheckOAuthAccessToken returns uid of user from oauth token func CheckOAuthAccessToken(ctx context.Context, accessToken string) int64 { + if !setting.OAuth2.Enabled { + return 0 + } // JWT tokens require a "." if !strings.Contains(accessToken, ".") { return 0