Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CaseClauseError raised by JOSE.JWT.peek_protected/1 with malformed token #146

Open
exlee opened this issue Oct 4, 2023 · 0 comments
Open

Comments

@exlee
Copy link

exlee commented Oct 4, 2023

I stumbled upon following condition when malformed token was provided (extra "e" at the beginning).

Output is for 1.11.2 however outcome is the same for 1.11.6.

iex(1)> jwt_token = "eeyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
iex(2)> JOSE.JWT.peek_protected(jwt_string)
** (CaseClauseError) no case clause matching: "9"
    (jose 1.11.2) src/base/jose_base64url.erl:222: :jose_base64url.decode!/2
    (jose 1.11.2) src/jwt/jose_jwt.erl:162: :jose_jwt.peek_protected/1
    (jose 1.11.2) lib/jose/jwt.ex:191: JOSE.JWT.peek_protected/1
    iex:2: (file)

Not sure if there's any validation that could be done before trying to peek, though.
My expectations for such scenarios would be an :error return or more descriptive throw (e.g. UndecodableTokenError).

Seems to be similar to #22

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant