Skip to content

Commit

Permalink
add validationError errors to error message
Browse files Browse the repository at this point in the history
  • Loading branch information
tstollin committed Nov 28, 2024
1 parent f1ec80b commit 8db9e27
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions web/middleware/security/jwtidtoken.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package security

import (
"crypto/rsa"
"errors"
"fmt"
"github.com/go-http-utils/headers"
"github.com/golang-jwt/jwt/v4"
"net/http"
Expand Down Expand Up @@ -54,6 +56,10 @@ func JwtIdTokenValidatorMiddleware(options JwtIdTokenValidatorMiddlewareOptions)
}
if err != nil {
errorMessage = err.Error()
var vErr *jwt.ValidationError
if errors.As(err, &vErr) {
errorMessage = fmt.Sprintf("%s: %d", errorMessage, vErr.Errors)
}
} else if !token.Valid {
errorMessage = "token parsed but invalid"
}
Expand Down

0 comments on commit 8db9e27

Please sign in to comment.