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

Update README.md and remove dead code #63

Merged
merged 3 commits into from
Mar 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ A Ruby implementation of [JSON Web Token draft 06](http://self-issued.info/docs/

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

JWT.decode("someJWTstring", "secret")
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)
JWT.decode('someJWTstring', nil, false)

`encode` also allows for different signing algorithms as well as customer headers.

Expand All @@ -40,21 +40,21 @@ The JWT spec supports several algorithms for cryptographic signing. This library

Change the algorithm with by setting it in encode:

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

**Plaintext**

We also support unsigned plaintext JWTs as introduced by draft 03 by explicitly specifying `nil` as the key and algorithm:

jwt = JWT.encode({"some" => "payload"}, nil, nil)
jwt = JWT.encode({'some' => 'payload'}, nil, nil)
JWT.decode(jwt, nil, nil)

## Support for reserved claim names
JSON Web Token defines some reserved claim names and defines how they should be
used. JWT supports these reserved claim names:

- "exp" (Expiration Time) Claim
- "nbf" (Not Before Time) Claim
- 'exp' (Expiration Time) Claim
- 'nbf' (Not Before Time) Claim

### Expiration Time Claim

Expand All @@ -70,15 +70,15 @@ From [draft 01 of the JWT spec](http://self-issued.info/docs/draft-jones-json-we

You pass the expiration time as a UTC UNIX timestamp (an int). For example:

JWT.encode({"exp": 1371720939}, "secret")
JWT.encode({'exp': 1371720939}, 'secret')

JWT.encode({"exp": Time.now.to_i()}, "secret")
JWT.encode({'exp': Time.now.to_i()}, 'secret')

Expiration time is automatically verified in `JWT.decode()` and raises
`JWT::ExpiredSignature` if the expiration time is in the past:

begin
JWT.decode("JWT_STRING", "secret")
JWT.decode('JWT_STRING', 'secret')
rescue JWT::ExpiredSignature
# Signature has expired
end
Expand Down Expand Up @@ -113,15 +113,15 @@ From [draft-ietf-oauth-json-web-token-32](http://self-issued.info/docs/draft-iet

You pass the not before time as a UTC UNIX timestamp (an int). For example:

JWT.encode({"nbf": 1371720939}, "secret")
JWT.encode({'nbf': 1371720939}, 'secret')

JWT.encode({"nbf": Time.now.to_i()}, "secret")
JWT.encode({'nbf': Time.now.to_i()}, 'secret')

Not before time is automatically verified in `JWT.decode()` and raises
`JWT::ImmatureSignature` if the not before time is in the future:

begin
JWT.decode("JWT_STRING", "secret")
JWT.decode('JWT_STRING', 'secret')
rescue JWT::ImmatureSignature
# Signature is immature
end
Expand Down
3 changes: 0 additions & 3 deletions spec/helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
require 'rspec'
require "#{File.dirname(__FILE__)}/../lib/jwt.rb"

RSpec.configure do |c|
end