Skip to content

Commit

Permalink
Merge pull request #4 from Interhyp/patch-of-johannes
Browse files Browse the repository at this point in the history
add validationError errors to error message
  • Loading branch information
tstollin authored Dec 5, 2024
2 parents f1ec80b + 8db9e27 commit 6112032
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 6112032

Please sign in to comment.