Skip to content

Commit 3ae5eef

Browse files
committed
Updated documentation to match the latest version of the JWT specification (draft 32)
1 parent a4c5236 commit 3ae5eef

File tree

1 file changed

+37
-17
lines changed

1 file changed

+37
-17
lines changed

README.md

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
[![pypi-version-image]][pypi]
55
[![coveralls-status-image]][coveralls]
66

7-
A Python implementation of [JSON Web Token draft 01][jwt-draft-01] originally written by [@progrium][progrium].
7+
A Python implementation of [JSON Web Token draft 32][jwt-spec].
8+
Original implementation was written by [@progrium][progrium].
89

910
## Installing
1011

@@ -94,10 +95,10 @@ You can run tests from the project root after cloning with:
9495
$ python tests/test_jwt.py
9596
```
9697

97-
## Support of reserved claim names
98+
## Support of registered claim names
9899

99-
JSON Web Token defines some reserved claim names and defines how they should be
100-
used. PyJWT supports these reserved claim names:
100+
JSON Web Token defines some registered claim names and defines how they should be
101+
used. PyJWT supports these registered claim names:
101102

102103
- "exp" (Expiration Time) Claim
103104
- "nbf" (Not Before Time) Claim
@@ -106,15 +107,15 @@ used. PyJWT supports these reserved claim names:
106107

107108
### Expiration Time Claim
108109

109-
From [draft 01 of the JWT spec][reserved-claimname]:
110+
From [the JWT spec][jwt-spec-reg-claims]:
110111

111-
> The exp (expiration time) claim identifies the expiration time on or after
112-
> which the JWT MUST NOT be accepted for processing. The processing of the exp
113-
> claim requires that the current date/time MUST be before the expiration
114-
> date/time listed in the exp claim. Implementers MAY provide for some small
115-
> leeway, usually no more than a few minutes, to account for clock skew. Its
116-
> value MUST be a number containing an IntDate value. Use of this claim is
117-
> OPTIONAL.
112+
> The "exp" (expiration time) claim identifies the expiration time on
113+
> or after which the JWT MUST NOT be accepted for processing. The
114+
> processing of the "exp" claim requires that the current date/time
115+
> MUST be before the expiration date/time listed in the "exp" claim.
116+
> Implementers MAY provide for some small leeway, usually no more than
117+
> a few minutes, to account for clock skew. Its value MUST be a number
118+
> containing a NumericDate value. Use of this claim is OPTIONAL.
118119
119120
You can pass the expiration time as a UTC UNIX timestamp (an int) or as a
120121
datetime, which will be converted into an int. For example:
@@ -174,7 +175,13 @@ jwt.decode(jwt_payload, 'secret', leeway=datetime.timedelta(seconds=10))
174175

175176
### Not Before Time Claim
176177

177-
> The nbf (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. The processing of the nbf claim requires that the current date/time MUST be after or equal to the not-before date/time listed in the nbf claim. Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew. Its value MUST be a number containing a NumericDate value. Use of this claim is OPTIONAL.
178+
> The "nbf" (not before) claim identifies the time before which the JWT
179+
> MUST NOT be accepted for processing. The processing of the "nbf"
180+
> claim requires that the current date/time MUST be after or equal to
181+
> the not-before date/time listed in the "nbf" claim. Implementers MAY
182+
> provide for some small leeway, usually no more than a few minutes, to
183+
> account for clock skew. Its value MUST be a number containing a
184+
> NumericDate value. Use of this claim is OPTIONAL.
178185
179186
The `nbf` claim works similarly to the `exp` claim above.
180187

@@ -186,7 +193,10 @@ jwt.encode({'nbf': datetime.utcnow()}, 'secret')
186193

187194
### Issuer Claim
188195

189-
> The iss (issuer) claim identifies the principal that issued the JWT. The processing of this claim is generally application specific. The iss value is a case-sensitive string containing a StringOrURI value. Use of this claim is OPTIONAL.
196+
> The "iss" (issuer) claim identifies the principal that issued the
197+
> JWT. The processing of this claim is generally application specific.
198+
> The "iss" value is a case-sensitive string containing a StringOrURI
199+
> value. Use of this claim is OPTIONAL.
190200
191201
```python
192202
import jwt
@@ -206,7 +216,17 @@ If the issuer claim is incorrect, `jwt.InvalidIssuerError` will be raised.
206216

207217
### Audience Claim
208218

209-
> The aud (audience) claim identifies the recipients that the JWT is intended for. Each principal intended to process the JWT MUST identify itself with a value in the audience claim. If the principal processing the claim does not identify itself with a value in the aud claim when this claim is present, then the JWT MUST be rejected. In the general case, the aud value is an array of case-sensitive strings, each containing a StringOrURI value. In the special case when the JWT has one audience, the aud value MAY be a single case-sensitive string containing a StringOrURI value. The interpretation of audience values is generally application specific. Use of this claim is OPTIONAL.
219+
> The "aud" (audience) claim identifies the recipients that the JWT is
220+
> intended for. Each principal intended to process the JWT MUST
221+
> identify itself with a value in the audience claim. If the principal
222+
> processing the claim does not identify itself with a value in the
223+
> "aud" claim when this claim is present, then the JWT MUST be
224+
> rejected. In the general case, the "aud" value is an array of case-
225+
> sensitive strings, each containing a StringOrURI value. In the
226+
> special case when the JWT has one audience, the "aud" value MAY be a
227+
> single case-sensitive string containing a StringOrURI value. The
228+
> interpretation of audience values is generally application specific.
229+
> Use of this claim is OPTIONAL.
210230
211231
```python
212232
import jwt
@@ -234,6 +254,6 @@ MIT
234254
[pypi]: https://pypi.python.org/pypi/pyjwt
235255
[coveralls-status-image]: https://coveralls.io/repos/jpadilla/pyjwt/badge.svg?branch=master
236256
[coveralls]: https://coveralls.io/r/jpadilla/pyjwt?branch=master
237-
[jwt-draft-01]: http://self-issued.info/docs/draft-jones-json-web-token-01.html
257+
[jwt-spec]: https://tools.ietf.org/html/draft-ietf-oauth-json-web-token-32
258+
[jwt-spec-reg-claims]: http://self-issued.info/docs/draft-jones-json-web-token-01.html#ReservedClaimName
238259
[progrium]: https://github.com/progrium
239-
[reserved-claimname]: http://self-issued.info/docs/draft-jones-json-web-token-01.html#ReservedClaimName

0 commit comments

Comments
 (0)