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

the library doesn't check token signature #33

Open
DmitryDD opened this issue Sep 10, 2020 · 0 comments
Open

the library doesn't check token signature #33

DmitryDD opened this issue Sep 10, 2020 · 0 comments

Comments

@DmitryDD
Copy link

I've just quickly read the code and found that there is no access token's signature verification.

https://github.com/imagov/keycloak/blob/master/lib/keycloak.rb#L326

JWT.decode refresh_token, @public_key, false, { :algorithm => 'RS256' }

as you can see the third argument needs to be set as true to check the signature
https://github.com/jwt/ruby-jwt/blob/master/lib/jwt/decode.rb#L11-L31

here is a quick solution

public_key = "-----BEGIN PUBLIC KEY-----\n" +
 @public_key.scan(/.{1,64}/).join("\n") +
 "\n-----END PUBLIC KEY-----\n"

JWT.decode(token, OpenSSL::PKey::RSA.new(public_key), true, algorithm: 'RS256')

Hopefully, this would help someone
Cheers

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