Add JWT middleware validation failure log (#760)

We will log the middleware log now, but in the next
releases we should provide a generic error that can be
parsed by the dashboard.
This commit is contained in:
Maycon Santos 2023-03-23 18:26:41 +01:00 committed by GitHub
parent e6292e3124
commit a27fe4326c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,12 +4,14 @@ import (
"context" "context"
"errors" "errors"
"fmt" "fmt"
"github.com/golang-jwt/jwt"
"github.com/netbirdio/netbird/management/server/http/util"
"github.com/netbirdio/netbird/management/server/status"
"log"
"net/http" "net/http"
"strings" "strings"
"github.com/golang-jwt/jwt"
log "github.com/sirupsen/logrus"
"github.com/netbirdio/netbird/management/server/http/util"
"github.com/netbirdio/netbird/management/server/status"
) )
// A function called whenever an error is encountered // A function called whenever an error is encountered
@ -114,6 +116,9 @@ func (m *JWTMiddleware) Handler(h http.Handler) http.Handler {
// If there was an error, do not continue. // If there was an error, do not continue.
if err != nil { if err != nil {
log.Errorf("received an error while validating the JWT token: %s. "+
"Review your IDP configuration and ensure that "+
"settings are in sync between dashboard and management", err)
return return
} }