JSON Web Key (JWK)ΒΆ
Important
We are splitting the jose
module into a separated package. You may be
interested in joserfc.
A JSON Web Key (JWK) is a JavaScript Object Notation (JSON) data structure that represents a cryptographic key. An example would help a lot:
{
"kty": "EC",
"crv": "P-256",
"x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
"y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0",
"kid": "iss-a"
}
This is an Elliptic Curve Public Key represented by JSON data structure.
JsonWebKey.import_key()
will convert PEM, JSON, bytes into these keys:
Algorithms for kty
(Key Type) is defined by RFC7518: JSON Web Algorithms.
Import a key with:
from authlib.jose import JsonWebKey
key_data = read_file('public.pem')
key = JsonWebKey.import_key(key_data, {'kty': 'RSA'})
key.as_dict()
key.as_json()
You may pass extra parameters into import_key
method, available parameters can
be found on RFC7517 Section 4.