Skip to content

Commit cda1d5e

Browse files
committed
Added sample notification JWT signature verification code to /api/index.html.
- Legacy-Id: 16207
1 parent f1ab5a7 commit cda1d5e

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

ietf/templates/api/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,24 @@ <h3 id="signing-keys" class="anchor-target">Signing Keys</h3>
322322
<p>or alternatively:</p>
323323

324324
<pre>{{key.export_to_pem}}</pre>
325+
326+
<p>
327+
To verify a signature and get the verified data using Python with the
328+
<a href="https://jwcrypto.readthedocs.io/en/latest/">jwcrypto</a> module,
329+
you could do:
330+
<pre>
331+
from jwcrypto import jwk, jws
332+
333+
# ... receive json web signed data as 'data', used below ...
334+
335+
key = jwk.JWK()
336+
key.import_from_pem(API_PUBLIC_KEY_PEM) # the key above
337+
jwstoken = jws.JWS()
338+
jwstoken.deserialize(data)
339+
jwstoken.verify(key)
340+
payload = jwstoken.payload
341+
</pre>
342+
</p>
325343
</div>
326344

327345
</div>

0 commit comments

Comments
 (0)