Urgent.News

What's breaking now, across hundreds of outlets.

Tech

How to decode a JWT in Python (and what decoding does not prove)

How to decode a JWT in Python (and what decoding does not prove) Read any token with the stdlib or PyJWT, then see exactly where decoding stops and verifying starts. TL;DR The stdlib decode is a split, a padding line, base64.urlsafe_b64decode and json.loads . The padding line is what most snippets omit. To inspect a token, call jwt.decode_complete(token, options={"verify_signature": False}) . To…

To decode a JWT in Python, you first split the token on the dots, restore the "=" padding that base64url dropped, and then parse the result as JSON. The most common way to do this involves using the stdlib and PyJWT libraries.

After splitting the token, Python's base64.urlsafe_b64decode is used to decode the payload segment, which then gets parsed with json.loads. The padding line is an important step, as many snippets omit it but it is crucial for the decoding to work. The header contains information about the algorithm and the claims, while the payload holds the issuer, subject, audience, role, timestamps, and a unique token ID. The signature segment, which is a raw base64url string, is not parsed as JSON.

One thing to note is that adding the appropriate "=" padding to the payload segment before decoding can prevent padding errors. A sample script provided in the source demonstrates how to decode a token, handle errors, and verify the contents of the decoded token, including checking the expected issuer and the audience.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

GL.iNet Router Malware: How to Check Yours (the Cloud Fix Doesn't Remove It)

GL.iNet says attackers used its cloud remote management service to install malware on "some GL.iNet routers and KVM devices." It also says the hole is closed.

  • GL.iNet routers exploited via cloud service to install malware
  • Update firmware resolves infection, but cloud fix alone insufficient
  • Check for "crond -i /tmp/.log" process, install firmware update

A matching SHA-256 checksum is useful only with a trustworthy reference

You download an installer and find a SHA-256 string next to the download button. Your local hash matches. What have you learned?

  • SHA-256 checksum confirms file bytes match, not publisher identity
  • Calculate checksum separately, not during download
  • Trustworthy reference required for publisher verification

A different perspective on text, information and knowledge

We now produce more text than anyone can read. Agent instructions, specifications, pipelines, models, requirements, notes, and more and more of it written by AI.

  • ADP framework developed to handle AI-generated text deluge
  • ADP transforms text files into structured formats for better comprehension
  • ADP maintains original text while providing additional views of hidden structure

The hour before a test run that nobody plans for

It's 10 minutes before you start testing the new checkout flow in UAT. You open the shared spreadsheet of test logins. The UAT row says checkout_user_02 . The note next to it says "maybe expired?".

  • At 10 minutes before testing, shared spreadsheet reveals UAT login issue
  • Two accounts offered, but one in use and another lacks saved card
  • Route Map for Jira organizes test data, assigns usability status

GitHub Enterprise Server's Pre-Receive Hook Boundary Broke Under a Crafted Download URL

GitHub Enterprise Server's Pre-Receive Hook Boundary Broke Under a Crafted Download URL GitHub Enterprise Server administrators already hold broad control over a repository appliance.

  • CVE-2026-112740 allows privilege escalation to git user on peer node
  • Exploitation through crafted download URL bypasses pre-receive sandbox
  • Affected versions prior to 3.23 require patching and mitigation steps

More from Monday 23 November →