Yaegi interpreter unexpected behavior #1548
Unanswered
talevy-runai
asked this question in
Q&A
Replies: 2 comments
-
I think you had the same issue, am i right? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Im experiencing the same here parts := strings.Split(bearerToken, " ")
if len(parts) != 2 || parts[0] != "Bearer" {
return Claims{}, errors.New("expected authorization header format: Bearer <token>")
}
var claims Claims
token, _, err := a.parser.ParseUnverified(parts[1], &claims)
if err != nil {
return Claims{}, fmt.Errorf("error parsing token: %w", err)
}
os.Stdout.WriteString(fmt.Sprintf("Token string: %s\n", parts[1]))
os.Stdout.WriteString(fmt.Sprintf("parsed claims [%v]", claims))
os.Stdout.WriteString(fmt.Sprintf("parsed token claims [%v]", token.Claims))
os.Stdout.WriteString(fmt.Sprintf("parsed token [%v]", token))
payloadBase64 := strings.Split(parts[1], ".")[1]
payloadJSON, err := base64.RawURLEncoding.DecodeString(payloadBase64)
if err != nil {
fmt.Printf("Error decoding payload: %v\n", err)
} else {
fmt.Printf("Decoded payload: %s\n", string(payloadJSON))
} when manually decoding the payload is there otherwise the claims are empty |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
I've written plugin for jwt validation,
I've used github.com/golang-jwt/jwt/v4
When I'm running Parse token, I get an empty map (only in yaegi test)
go test works fine,
I tried to debug this and I've found out the issue in the line 160
the decode from object return empty string, example object:
I think it doesn't work with the json:"email,omitempty" annotation.
any idea how to manage it?
I'm using yaegi latest
Beta Was this translation helpful? Give feedback.
All reactions