-
Notifications
You must be signed in to change notification settings - Fork 68
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
HS256 signature fails validation using python-jose #128
Comments
I found the error in my example and usage, and there's no issue with I had not realized that the JWK's " >>> k = base64url_encode(b'secret').decode()
# k = 'c2VjcmV0'
>>> hmac_key = {'alg':'HS256', 'kty':'oct', 'k':k}
>>> key = jwk.construct(hmac_key)
>>> key.verify(message.encode(), decoded_sig)
True In my actual use case, I used https://github.com/latchset/jose to create a JWKS, and then created the JWT using $ jose jwk gen -s -i '{"alg":"HS256"}'
{"keys":[{"alg":"HS256","k":"iX0BTw7_BWJ1C5dwR0yGmNDG-GTf44AsUaq4QttnbxU","key_ops":["sign","verify"],"kty":"oct"}]} This means I'd have to decode the base64-encoded random bytes to use as $ jwt encode --iss self --sub foo --exp "+1Y" \
--secret "$(base64 -d <<< "iX0BTw7_BWJ1C5dwR0yGmNDG-GTf44AsUaq4QttnbxU")"
thread 'main' panicked at 'unexpected invalid UTF-8 code point', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/clap-2.33.3/src/args/arg_matches.rs:118:40
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace |
Closing in favor of generic JWKS support in #129 |
Summary
I'm using
jwt-cli
to generate a JWT using the default HS256 algorithm, but the token is failing validation using the python-jose module. I'm not sure whether it's the way I'm using the--secret
parameter, or the relationship between the--secret
value and the JWK's "k
" value, or a bug in either code base.Steps to reproduce
In Python REPL using
python-jose
following the JWK example:Expected behavior
JWT produced by
jwt-cli
can be validated bypython-jose
.Environment & version
OS: macOS 10.15.7
jwt-cli
:4.0.0
The text was updated successfully, but these errors were encountered: