Sha256: 6de0fa5a9c2f5a3d5658a17626812a0ecb60163aa1d0ba6c0321b6c034c83b8e

Contents?: true

Size: 1.8 KB

Versions: 7

Compression:

Stored size: 1.8 KB

Contents

= JSON::JWT

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

{<img src="https://secure.travis-ci.org/nov/json-jwt.png" />}[http://travis-ci.org/nov/json-jwt]

== Installation

  gem install json-jwt

== Resources

* View Source on GitHub (https://github.com/nov/json-jwt)
* Report Issues on GitHub (https://github.com/nov/json-jwt/issues)

== Examples

=== Encoding

  require 'json/jwt'

  claim = {
    iss: 'nov',
    exp: 1.week.from_now,
    nbf: Time.now
  }

  # No signature, no encryption
  jwt = JSON::JWT.new(claim).to_s

  # With signiture, no encryption
  jws = JSON::JWT.new(claim).sign(key, algorithm) # algorithm is optional. default HS256
  jws.to_s # => header.payload.signature

  # With signature & encryption
  jwe = jws.encrypt(key, algorithm, encryption_method) # algorithm & encryption_method are optional. default RSA1_5 & A128CBC+HS256
  jws.to_s # => header.master_key.iv.cipher_text.integrity_value

For details about <code>key</code> and <code>algorithm</code>, see
{JWS Spec}[https://github.com/nov/json-jwt/blob/master/spec/json/jws_spec.rb] and
{Sign Key Fixture Generator}[https://github.com/nov/json-jwt/blob/master/spec/helpers/sign_key_fixture_helper.rb].

=== Decoding

  jwt_string = "jwt_header.jwt_claims.jwt_signature"

  JSON::JWT.decode(jwt_string, key)

== 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.

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
json-jwt-0.5.6 README.rdoc
json-jwt-0.5.5 README.rdoc
json-jwt-0.5.4 README.rdoc
json-jwt-0.5.3 README.rdoc
json-jwt-0.5.2 README.rdoc
json-jwt-0.5.1 README.rdoc
json-jwt-0.5.0 README.rdoc