From bad25c0ac08fff7ffeedcb611992d82a84e862f3 Mon Sep 17 00:00:00 2001 From: MalinAhlberg Date: Tue, 31 Oct 2023 10:54:57 +0100 Subject: [PATCH] fix: avoid panic if validation token is not setup properly --- sda/internal/userauth/userauth.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sda/internal/userauth/userauth.go b/sda/internal/userauth/userauth.go index f3db06ae0..a3009b6af 100644 --- a/sda/internal/userauth/userauth.go +++ b/sda/internal/userauth/userauth.go @@ -38,6 +38,9 @@ func NewValidateFromToken(keyset jwk.Set) *ValidateFromToken { // Authenticate verifies that the token included in the http.Request is valid func (u *ValidateFromToken) Authenticate(r *http.Request) (jwt.Token, error) { // Verify signature by parsing the token with the given key + if u == nil { + return nil, fmt.Errorf("error validating token keyset") + } switch { case r.Header.Get("Authorization") != "": authStr := r.Header.Get("Authorization")