Skip to content

Latest commit

 

History

History
45 lines (25 loc) · 1.16 KB

README.md

File metadata and controls

45 lines (25 loc) · 1.16 KB

mruby-jwt Build Status

A mruby implementation of JSON Web Token draft 06.

Install by mrbgems

  • add conf.gem line to build_config.rb
MRuby::Build.new do |conf|

    # ... (snip) ...

    conf.gem :git => 'https://github.com/ainoya/mruby-jwt.git'
end

Usage

JWT.encode({"some" => "payload"}, "secret")

Note the resulting JWT will not be encrypted, but verifiable with a secret key.

JWT.decode("someJWTstring", "secret")

If the secret is wrong, it will raise a JWT::DecodeError telling you as such. You can still get at the payload by setting the verify argument to false.

JWT.decode("someJWTstring", nil, false)

Caveats

  • encryption only supports SHA256 algorithm
  • this module is written in only mruby; not c implementation yet.

License

Under the MIT License:

  • see LICENSE file

Reference

  • progrium/ruby-jwt
    • mruby-jwt is the modified version from progium/ruby-jwt for working in mruby environment.