<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Kevin</title>
    <description>The latest articles on DEV Community by Kevin (@icryinbed).</description>
    <link>https://dev.to/icryinbed</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3655609%2Fd922664c-e9e7-4024-b732-cd01430bcc3e.jpg</url>
      <title>DEV Community: Kevin</title>
      <link>https://dev.to/icryinbed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/icryinbed"/>
    <language>en</language>
    <item>
      <title>JWT: the theory before the code</title>
      <dc:creator>Kevin</dc:creator>
      <pubDate>Wed, 03 Jun 2026 01:03:58 +0000</pubDate>
      <link>https://dev.to/icryinbed/jwt-the-theory-before-the-code-1p4o</link>
      <guid>https://dev.to/icryinbed/jwt-the-theory-before-the-code-1p4o</guid>
      <description>&lt;h2&gt;
  
  
  What is a JWT?
&lt;/h2&gt;

&lt;p&gt;JWT stands for JSON Web Token. It's a way to pass information between two parties in a compact, self-contained format. The key idea is that the token itself carries the data  the server doesn't need to store anything to validate it.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three parts
&lt;/h2&gt;

&lt;p&gt;A JWT looks like this:&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzuehev4vi4t561r0gyg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjzuehev4vi4t561r0gyg.png" alt=" " width="799" height="280"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Three base64 encoded strings joined by dots.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Header&lt;/strong&gt; contains the token type and the signing algorithm (usually HS256 or RS256).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Payload&lt;/strong&gt; is the actual data, called "claims". Things like user id, role, expiration time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Signature&lt;/strong&gt; is created by combining the header, payload, and a secret key. This is what makes the token trustworthy.&lt;/p&gt;

&lt;h2&gt;
  
  
  How trust works
&lt;/h2&gt;

&lt;p&gt;When your server receives a JWT, it doesn't look up the user in a database to verify the request. Instead, it recalculates the signature using the secret key and checks if it matches the one in the token.&lt;/p&gt;

&lt;p&gt;If someone tampers with the payload, the signature won't match. That's the whole point.&lt;/p&gt;

&lt;h2&gt;
  
  
  Claims
&lt;/h2&gt;

&lt;p&gt;The payload is made of claims, statements about the user or the session. There are registered ones like &lt;code&gt;sub&lt;/code&gt; (subject, usually the user id), &lt;code&gt;exp&lt;/code&gt; (expiration timestamp), and &lt;code&gt;iat&lt;/code&gt; (issued at). You can also add your own custom claims like &lt;code&gt;role&lt;/code&gt; or &lt;code&gt;plan&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What JWT is not
&lt;/h2&gt;

&lt;p&gt;JWT is not encryption. The payload is encoded, not encrypted. Anyone can decode it and read the contents. Never put sensitive data like passwords in a JWT.&lt;/p&gt;

&lt;p&gt;What it does guarantee is integrity: you can trust that the data hasn't been modified since it was signed.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
