16669: Fix nil pointer dereference.
authorTom Clegg <tom@tomclegg.ca>
Wed, 16 Sep 2020 15:24:05 +0000 (11:24 -0400)
committerTom Clegg <tom@tomclegg.ca>
Wed, 21 Oct 2020 13:04:25 +0000 (09:04 -0400)
Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@tomclegg.ca>

lib/controller/localdb/login_oidc.go

index 2eb2121280081608c47c1b3db9f68f986944d7b4..20f22b1b3ec92656d1fe1af0f56b23d1424822ac 100644 (file)
@@ -341,7 +341,9 @@ type oidcTokenAuthorizer struct {
 }
 
 func (ta *oidcTokenAuthorizer) Middleware(w http.ResponseWriter, r *http.Request, next http.Handler) {
-       if authhdr := strings.Split(r.Header.Get("Authorization"), " "); len(authhdr) > 1 && (authhdr[0] == "OAuth2" || authhdr[0] == "Bearer") {
+       if ta.ctrl == nil {
+               // Not using a compatible (OIDC) login controller.
+       } else if authhdr := strings.Split(r.Header.Get("Authorization"), " "); len(authhdr) > 1 && (authhdr[0] == "OAuth2" || authhdr[0] == "Bearer") {
                err := ta.registerToken(r.Context(), authhdr[1])
                if err != nil {
                        http.Error(w, err.Error(), http.StatusInternalServerError)