From f9c34fc34802dc71cd2a80769270305573aa2cc9 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Sun, 14 Nov 2021 10:49:36 +0100 Subject: [PATCH] auth: fix nil reference in auth method check --- auth/middleware.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/auth/middleware.go b/auth/middleware.go index d157ec3f816ba5bf3b4d021bdaf1bed4a560fb05..9bf442cf0ee3f4a22c7d60215c23b5ca7aa09a99 100644 --- a/auth/middleware.go +++ b/auth/middleware.go @@ -302,10 +302,14 @@ func internalAuth(internalNet []*net.IPNet, payload []byte, var auth *AuthContext if internalAuth.OAuthClientUUID != "" { auth, err = authForOAuthClient(r.Context(), internalAuth.OAuthClientUUID) - auth.AuthMethod = AUTH_INTERNAL + if err == nil { + auth.AuthMethod = AUTH_INTERNAL + } } else if internalAuth.Name != "" { auth, err = authForUsername(r.Context(), internalAuth.Name) - auth.AuthMethod = AUTH_INTERNAL + if err == nil { + auth.AuthMethod = AUTH_INTERNAL + } } else { // Using anonymous internal auth. This is only used in one specific // situation: registering for a new account.