diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2024-11-12 13:33:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-12 21:33:35 +0000 |
commit | 840ad7eefe2b49ab453b9a89b153a264a8c9f8a2 (patch) | |
tree | be325a516ed5f8e0d9847883d50cd2464d470bef /services | |
parent | 5bed7b9ec0d8df068ce7ff055590c1237dce5537 (diff) | |
download | gitea-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.go | 7 |
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) |