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

Needs to support asymmetric key signatures over shared secrets #46

Closed
Demuxx opened this issue Oct 29, 2014 · 6 comments
Closed

Needs to support asymmetric key signatures over shared secrets #46

Demuxx opened this issue Oct 29, 2014 · 6 comments
Assignees
Milestone

Comments

@Demuxx
Copy link

Demuxx commented Oct 29, 2014

Currently, you are using a shared secret to validate the signature of the JWT messages. This entirely defeats the purpose of signing the message and would only be suitable if you were encrypting and not signing the message. The idea behind signing a message is that only the originator can generate the signature and that signature can be validated but not forged. In your implementation any node that needs to validate a signature must in turn be able to forge new ones, because it must know the shared secret.

Therefore, ruby-jwt should allow for the use of asymmetric key based signature generation and checking as outlined in the ruby stdlib OpenSSL documentation here: http://ruby-doc.org/stdlib-2.0/libdoc/openssl/rdoc/OpenSSL.html#module-OpenSSL-label-Signatures. This will allow JWT consumers to verify requests without the ability to forge new ones.

@toshe
Copy link

toshe commented Nov 2, 2014

the library already does support RSA key signing. use the source, luke!

require 'openssl'
some_private_key = OpenSSL::PKey::RSA.new File.read('path/to/my/private/and/secure.pem'), 'password_for_my_private_key'
rsa_signed_token = JWT.encode(
        {"exp" => Time.now.to_i+3600,
         "name" => "some_name"},
        some_private_key, "RS512")

You can then use the public key to verify the signatures.

And if you need to generate an RSA key pair the OpenSSL library has a very neat documentation:
http://ruby-doc.org/stdlib-2.0/libdoc/openssl/rdoc/OpenSSL.html

@Demuxx
Copy link
Author

Demuxx commented Nov 4, 2014

Great, thanks for the information!

@Demuxx Demuxx closed this as completed Nov 4, 2014
@kurtisnelson
Copy link

This should get put in the README, I had to google to find this.

@toshe
Copy link

toshe commented Apr 1, 2015

contributing is not a crime, you know ;)

@excpt
Copy link
Member

excpt commented Apr 2, 2015

@kurtisnelson Thanks for bringing this up again. :)

The README / documentation really needs some updates. Working on it this weekend.

@excpt excpt reopened this Apr 2, 2015
@excpt excpt added this to the Version 1.4.2 milestone Apr 2, 2015
@excpt excpt self-assigned this Apr 2, 2015
@excpt excpt modified the milestones: Version 1.5.0, Version 1.4.2 Apr 17, 2015
@excpt excpt closed this as completed in e993d2c May 9, 2015
@excpt
Copy link
Member

excpt commented May 10, 2015

@prandium I improved the documentation and added a better example.

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

No branches or pull requests

4 participants