Skip to content

Commit 396900e

Browse files
author
Michael Davis
authored
Merge pull request #17 from mpdavis/refactor-jwk
JWK Refactor
2 parents 9975866 + ca8efcf commit 396900e

File tree

15 files changed

+545
-387
lines changed

15 files changed

+545
-387
lines changed

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Contents
2323

2424
jws/index
2525
jwt/index
26+
jwk/index
2627

2728

2829
APIs
@@ -33,6 +34,7 @@ APIs
3334

3435
jws/api
3536
jwt/api
37+
jwk/api
3638

3739

3840
Principles

docs/jwk/api.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
JWK API
3+
^^^^^^^
4+
5+
.. automodule:: jose.jwk
6+
:members:

docs/jwk/index.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
JSON Web Key
2+
==============
3+
4+
JSON Web Keys (JWK) are a JSON data structure representing a cryptographic key.
5+
6+
Examples
7+
^^^^^^^^
8+
9+
Verifying token signatures
10+
--------------------------
11+
12+
.. code:: python
13+
14+
>>> from jose import jwk
15+
>>>
16+
>>> token = "eyJhbGciOiJIUzI1NiIsImtpZCI6IjAxOGMwYWU1LTRkOWItNDcxYi1iZmQ2LWVlZjMxNGJjNzAzNyJ9.SXTigJlzIGEgZGFuZ2Vyb3VzIGJ1c2luZXNzLCBGcm9kbywgZ29pbmcgb3V0IHlvdXIgZG9vci4gWW91IHN0ZXAgb250byB0aGUgcm9hZCwgYW5kIGlmIHlvdSBkb24ndCBrZWVwIHlvdXIgZmVldCwgdGhlcmXigJlzIG5vIGtub3dpbmcgd2hlcmUgeW91IG1pZ2h0IGJlIHN3ZXB0IG9mZiB0by4.s0h6KThzkfBBBkLspW1h84VsJZFTsPPqMDA7g1Md7p0"
17+
>>> hmac_key = {
18+
"kty": "oct",
19+
"kid": "018c0ae5-4d9b-471b-bfd6-eef314bc7037",
20+
"use": "sig",
21+
"alg": "HS256",
22+
"k": "hJtXIZ2uSN5kbQfbtTNWbpdmhkV8FJG-Onbc6mxCcYg"
23+
}
24+
>>>
25+
>>> key = jwk.construct(key_data)
26+
>>>
27+
>>> key.verify(token)

0 commit comments

Comments
 (0)