From cda1d5eb327cca4556e0a6a0d1f1e0332b9abdd0 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Tue, 14 May 2019 13:06:18 +0000 Subject: [PATCH] Added sample notification JWT signature verification code to /api/index.html. - Legacy-Id: 16207 --- ietf/templates/api/index.html | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ietf/templates/api/index.html b/ietf/templates/api/index.html index 17aedb6c4..3afee7b69 100644 --- a/ietf/templates/api/index.html +++ b/ietf/templates/api/index.html @@ -322,6 +322,24 @@

or alternatively:

{{key.export_to_pem}}
+ +

+ To verify a signature and get the verified data using Python with the + jwcrypto module, + you could do: +

+from jwcrypto import jwk, jws
+
+# ... receive json web signed data as 'data', used below ...
+
+key = jwk.JWK()
+key.import_from_pem(API_PUBLIC_KEY_PEM)   # the key above
+jwstoken = jws.JWS()
+jwstoken.deserialize(data)
+jwstoken.verify(key)
+payload = jwstoken.payload
+        
+