]> source.dussan.org Git - gitea.git/commitdiff
Fix bug in reverse proxy (#16026)
authorzeripath <art27@cantab.net>
Mon, 31 May 2021 06:54:16 +0000 (07:54 +0100)
committerGitHub <noreply@github.com>
Mon, 31 May 2021 06:54:16 +0000 (02:54 -0400)
Unfortunately go panics you try to cast a nil interface{} as another primitive
therefore you need to check interfaces are not nil before casting.

Fix #16025

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
modules/auth/sso/reverseproxy.go

index f8d17a3cf5a7f988f6233d2e8187649e2e1ae772..3fffee0320d23156c8b3a0a5177b232969449f6a 100644 (file)
@@ -79,7 +79,7 @@ func (r *ReverseProxy) VerifyAuthData(req *http.Request, w http.ResponseWriter,
 
        // Make sure requests to API paths, attachment downloads, git and LFS do not create a new session
        if !middleware.IsAPIPath(req) && !isAttachmentDownload(req) && !isGitRawOrLFSPath(req) {
-               if sess.Get("uid").(int64) != user.ID {
+               if sess != nil && (sess.Get("uid") == nil || sess.Get("uid").(int64) != user.ID) {
                        handleSignIn(w, req, sess, user)
                }
        }