From d86433cce2b45184a73e2086ee2e84b5be259774 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 3 Oct 2024 08:34:56 -0700 Subject: [PATCH] Don't init singing keys if oauth2 provider disabled (#32177) Backport #32148 --- services/auth/source/oauth2/init.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/services/auth/source/oauth2/init.go b/services/auth/source/oauth2/init.go index 5c25681548..fba0f58fad 100644 --- a/services/auth/source/oauth2/init.go +++ b/services/auth/source/oauth2/init.go @@ -30,10 +30,14 @@ const ProviderHeaderKey = "gitea-oauth2-provider" // Init initializes the oauth source func Init(ctx context.Context) error { - if err := InitSigningKey(); err != nil { - return err + // this is for oauth2 provider + if setting.OAuth2.Enabled { + if err := InitSigningKey(); err != nil { + return err + } } + // others for oauth2 clients // Lock our mutex gothRWMutex.Lock()