coupergateway / couper

Couper is a lightweight API gateway designed to support developers in building and operating API-driven Web projects
https://couper.io
MIT License
84 stars 15 forks source link

Split `jwt_token_invalid` error type: separate error type for semantic token errors #795

Open johakoch opened 7 months ago

johakoch commented 7 months ago

Currently, there are three specific jwt error types:

As the jwt_token_invalid currently covers both syntactic and semantic invalidity, it's impossible to do separate error handling for semantic errors (like missing claims or unexpected claim values) on the one hand, and syntactic errors (like broken tokens, invalid signature) on the other.

The new error type should cover the following cases:

johakoch commented 6 months ago

Additionally, the jwt lib throws jwt.ErrTokenNotValidYet if a token is used before nbf. Currently we treat this as jwt_token_invalid, too. In terms of how a client should react in this case, it's only "try again later, with the same token". However this may be a rare case...