JSON Web Token and its family (JSON Web Signature, JSON Web Encryption and JSON Web Key) in Ruby

Nov Matake 7d8544e13a Merge pull request #30 from kintner/kintner/jwe_spec пре 8 година
lib 42dce26442 alias_method_chain wasn't needed here at all пре 8 година
spec 0c4d0fd478 fill in alg=dir tests for JWE пре 8 година
.gitignore 9033983eee rm gemfile.lock from repo пре 11 година
.gitmodules 90f6947927 make submodule readonly пре 11 година
.rspec 8afa3a3104 first commit пре 13 година
.travis.yml 06b6670601 goodbye ruby 1.9.3 пре 8 година
Gemfile 80e765253f allow skipping verification when decoding пре 12 година
LICENSE 8afa3a3104 first commit пре 13 година
README.md eaf0532ce4 link пре 9 година
Rakefile 69e6dc8fb7 goodbye 1.8 пре 10 година
VERSION caaa29be43 v1.5.2 пре 8 година
json-jwt.gemspec c6121311c9 fix Elliptic Curve calculation пре 10 година

README.md

JSON::JWT

JSON Web Token and its family (JSON Web Signature, JSON Web Encryption and JSON Web Key) in Ruby

Build Status

Installation

gem install json-jwt

Resources

Examples

require 'json/jwt'

private_key = OpenSSL::PKey::RSA.new <<-PEM
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEAyBKIFSH8dP6bDkGBziB6RXTTfZVTaaNSWNtIzDmgRFi6FbLo
 :
-----END RSA PRIVATE KEY-----
PEM

public_key = OpenSSL::PKey::RSA.new <<-PEM
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyBKIFSH8dP6bDkGBziB6
 :
-----END PUBLIC KEY-----
PEM

# Sign & Encode
claim = {
  iss: 'nov',
  exp: 1.week.from_now,
  nbf: Time.now
}
jws = JSON::JWT.new(claim).sign(private_key, :RS256)
jws.to_s

# Decode & Verify
input = "jwt_header.jwt_claims.jwt_signature"
JSON::JWT.decode(input, public_key)

For more details, read Documentation Wiki.

Note on Patches/Pull Requests

  • Fork the project.
  • Make your feature addition or bug fix.
  • Add tests for it. This is important so I don't break it in a future version unintentionally.
  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright (c) 2011 nov matake. See LICENSE for details.