2023-06-28 16:26:16 +02:00
|
|
|
== How to fix it in python-jwt
|
|
|
|
|
|
|
|
=== Code examples
|
|
|
|
|
|
|
|
include::../../common/fix/code-rationale-decode.adoc[]
|
|
|
|
|
|
|
|
==== Noncompliant code example
|
|
|
|
|
2023-08-21 15:22:49 +02:00
|
|
|
[source,python,diff-id=11,diff-type=noncompliant]
|
2023-06-28 16:26:16 +02:00
|
|
|
----
|
|
|
|
import python_jwt as jwt
|
|
|
|
|
|
|
|
jwt.process_jwt(token) # Noncompliant
|
|
|
|
----
|
|
|
|
|
|
|
|
==== Compliant solution
|
|
|
|
|
2023-08-21 15:22:49 +02:00
|
|
|
[source,python,diff-id=11,diff-type=compliant]
|
2023-06-28 16:26:16 +02:00
|
|
|
----
|
|
|
|
import python_jwt as jwt
|
|
|
|
|
|
|
|
jwt.process_jwt(token)
|
|
|
|
jwt.verify_jwt(token, key, ['HS256'])
|
|
|
|
----
|
|
|
|
|
|
|
|
=== How does this work?
|
|
|
|
|
|
|
|
include::../../common/fix/decode.adoc[]
|
|
|
|
|
|
|
|
=== Going the extra mile
|
|
|
|
|
|
|
|
include::../../common/extra-mile/key-storage.adoc[]
|
|
|
|
|
|
|
|
include::../../common/extra-mile/key-rotation.adoc[]
|
|
|
|
|