Skip to content

failed to parse token #156

Description

@yossibalan-1

We are using IAS JWT validation to verify that our JWTs are valid.

We have seen that many customers receive an error like this:                                                                                                                                                  
                                                                                                                                                                                                                
{"error":"failed to parse token: failed to decode value for key email: error reading next value: json: cannot unmarshal array into Go value of type                                                           
string","file":"server.go:1008","func":"main.(*Server).handleLoginFormAuthentication","level":"warning","msg":"IAS JWT cannot be parsed","time":"2026-08-25T23:44:17.923Z"}                                     
I looked at the IAS attribute mapping, and it seems that the customers added two fields to the mapping: Corporate and Identity values.                                                                          
                                                                                                                                                                                                                
For example:                                                                                                                                                                                                    

This is the trace:

s.iasMiddleware.ParseAndValidateJWT(iasJwtToken)

vendor/cloud-security-client-go/auth/validator.go:22
NewToken(rawToken)

vendor/cloud-security-client-go/auth/token.go:40
jwt.ParseString(encodedToken, jwt.WithToken(openid.New()))

vendor/lestrrat-go/jwx/jwt/jwt.go:463
json.Unmarshal(payload, ctx.token) ← wraps error as "failed to parse token"

vendor/lestrrat-go/jwx/jwt/openid/token_gen.go:970
stdToken.UnmarshalJSON(buf) ← iterates over all claims

vendor/lestrrat-go/jwx/jwt/openid/token_gen.go:1036
json.AssignNextStringToken(&t.email, dec) ← fails: array ≠ string

vendor/lestrrat-go/jwx/internal/json/json.go:45
dec.Decode(&val) ← ROOT CAUSE: strict string decoding

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions