<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shivanshu Tyagi on Medium]]></title>
        <description><![CDATA[Stories by Shivanshu Tyagi on Medium]]></description>
        <link>https://medium.com/@spazewalker?source=rss-c7428e38c651------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*neeFDVdy3IrSK7D8TrOjOQ.jpeg</url>
            <title>Stories by Shivanshu Tyagi on Medium</title>
            <link>https://medium.com/@spazewalker?source=rss-c7428e38c651------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 08:11:44 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@spazewalker/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[I see no light]]></title>
            <link>https://spazewalker.medium.com/i-see-no-light-f60cd4b5bbf0?source=rss-c7428e38c651------2</link>
            <guid isPermaLink="false">https://medium.com/p/f60cd4b5bbf0</guid>
            <category><![CDATA[trees]]></category>
            <category><![CDATA[poem]]></category>
            <category><![CDATA[city-living]]></category>
            <category><![CDATA[environment]]></category>
            <category><![CDATA[birds]]></category>
            <dc:creator><![CDATA[Shivanshu Tyagi]]></dc:creator>
            <pubDate>Mon, 22 Feb 2021 18:56:02 GMT</pubDate>
            <atom:updated>2021-02-23T04:28:43.802Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6q6MGnTo5ml3WEWp2qbkSQ.jpeg" /><figcaption>Bird waking up at dawn in a city</figcaption></figure><p>I wake up at dawn; I see no light.</p><p>I wake up at dawn; I feel tired and lite.</p><p>I give my wings a flick and my face a wipe.</p><p>I see no one around; perhaps they’ve gone for a hike.</p><p>I flap my wings to fly without light.</p><p>Then I notice a giant structure like a dyke</p><p>I fly past the corner when I see a window by the pipe,</p><p>I land on the window, to take a peek inside,</p><p>There’s a mother on the other side,</p><p>She hurries to make breakfast as the child cries,</p><p>She makes some toasts with butter on both sides,</p><p>Stuffs it in the packet for the other child.</p><p>Child hurries as there’s no time,</p><p>Mother gets him ready as the doorbell chime.</p><p>She’s already late for work, but she’s grime.</p><p>She hurries again; there’s no time.</p><p>Seeing this scene, I think it’s fine.</p><p>The world changed; now it’s not mine.</p><p>There’s this building, but maybe it’s not benign.</p><p>There used to be a peaceful tree here, so divine.</p><p>Creatures lived to see its shine.</p><p>My mother said it vanished when she was nine,</p><p>I’ve seen no peace since that time.</p><p>I wake up at dawn; I see no light,</p><p>I only see people with their fake smiles.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f60cd4b5bbf0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tiny Tale of  JSON Web Tokens]]></title>
            <link>https://spazewalker.medium.com/tiny-tale-of-json-web-tokens-991274d16038?source=rss-c7428e38c651------2</link>
            <guid isPermaLink="false">https://medium.com/p/991274d16038</guid>
            <category><![CDATA[authorization]]></category>
            <category><![CDATA[json-web-token]]></category>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[secure-exchange]]></category>
            <dc:creator><![CDATA[Shivanshu Tyagi]]></dc:creator>
            <pubDate>Sat, 19 Dec 2020 16:48:18 GMT</pubDate>
            <atom:updated>2020-12-19T16:48:18.094Z</atom:updated>
            <content:encoded><![CDATA[<h3>Tiny Tale of JSON Web Tokens</h3><p>You probably logged in to medium to read this story, or maybe you checked your mail today. You log in to many sites, but do you wonder how a website knows it is you who it is? of course, you provide an id/password combination, but how does it store it to request data from the server?? How does it keep it safe from suspicious people?? How does a server verifies if a person holds the privileges to access the information they’re requesting? Enter the “JSON web tokens.” But what are JWTs??</p><h4>What are JWTs?</h4><p>It’s a mechanism to verify the owner of some JSON data. It’s an encoded string containing some cryptographically signed data. It’s an open standard(<a href="https://tools.ietf.org/html/rfc7519">RFC 7519</a>) btw.</p><p>A server can trust the data contained in a JWT because the source signs it. Noone in the middle can modify a JWT once it’s sent; it becomes invalid if it’s tempered with). JWTs can be signed either by <strong>RSA </strong>or by using a secret string(<strong>HMAC</strong>). You don’t need to understand much about these encryption algorithms to use a JWT.</p><p>While a JWT guarantees data ownership, it’s not encrypted; it’s just serialized. In fact, anyone can see the data contained in a JWT. That’s the reason JWTs should always be used with HTTPS(well, you should always use HTTPS 😛). wanna see how they’re generated or verified?? continue reading.</p><h4>When can JWT be used?</h4><p>JWT is a great technology for API authentication and authorization, and information-exchange. It’s <strong>NOT </strong>good for sessions.</p><ul><li><strong>API Authentication</strong>: This is a widespread and popular use case of JWTs. It’s so popular and widely used that Google uses JWTs to let users authenticate to their APIs. The idea behind this is simple: you get a secret token from the service when you set up the API. On the client-side, you create the token (there are many libraries for this). Sign it using the secret token and pass it as part of the API request, and the server will know it’s that specific client because the request is signed with its unique identifier.</li><li><strong>Authorization: </strong>This is the most widely used application of JWTs. Once a user logs in, a JWT token is issued to them. Every subsequent request from this point will include the token in the request header, which will allow a user to access the resources accessible with that token.</li><li><strong>Information-Exchange: </strong>This is not a widely used scenario, but if we want to send some data and check its integrity at the destination, i.e., check if someone has not edited it in between transmission, JWTs come in handy.</li><li><strong>Database-less authentication: </strong>JWTs can be used as an authentication mechanism that does not require a database. Since a server can be sure that the user is who they claim to be, that can be authenticated without a database.</li></ul><h4>How it’s generated?</h4><p>In short, It contains 3 parts joined by a period(“.”):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/153/1*b6lYNq_KoVz5XaRZDPqfFA.png" /><figcaption>Structure of a JWT</figcaption></figure><ul><li><strong>Header(First part): </strong>The header <em>typically</em> consists of two parts — the type of the token, which is JWT, and the signing algorithm being used.</li><li><strong>Payload(Second part): </strong>Payload contains the claims. Claims are statements about an entity (typically, the user) and additional data. This is the part where the server puts the data which identifies the user and several other things.</li><li><strong>Signature(Last part): </strong>This is the main part of a JWT. The above two strings are Base64URL encoded and then passed to a signing algorithm(as specified in the header) along with a secret.</li></ul><p>The output is three Base64URL strings separated by dots that can be easily passed in HTML and HTTP environments.</p><p>Want to check out how they’re encoded?? I’m adding an encrypted JWT, verify if it’s generated by me or not 😉.</p><p>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6InNvbWVyYW5kb21JRCIsIm5hbWUiOiJTaGl2YW5zaHUgVHlhZ2kiLCJhY2NvdW50LXR5cGUiOiJ1c2VyIiwic2VjcmV0KGRvIG5vdCBhZGQgeW91ciBzZWNyZXRzIGluIHRva2VucywgSSdtIGFkZGluZyBvbmUgc28gdGhhdCB5b3UgY2FuIHZlcmlmeSB0aGlzIHRva2VuKSI6ImJhYmFiYWJhYmFuYW5hIiwiR3JlYXQtSm9iIjoiQW5kIHRoYW5rcyBmb3IgcmVhZGluZyA8MyIsImlhdCI6MTUxNjIzOTAyMn0.Xb6qYmVRQ9aTrna2lcOI0oTcVluYHW9O-bkByB6jj3A</p><p>Head over to <a href="http://jwt.io/">jwt.io</a> to play around with JWTs on a debugger tool.</p><h4>How should JWTs be used?</h4><ul><li><strong>Set-up an expiring time: </strong>How can you invalidate a single token? Well, you can change the secret signing key, but that’s not good for other users who’ll have their token invalidated for no reason, right? One way to do it is to check the time at which the token was created. A token automatically stores this value in the “iat” property. Every time we check the token, we can compare its “iat” value with the server-side user property and reject it based on time. Another way to achieve this is by having a blacklist in your database cached in memory (or, even better, a whitelist). If a token needs to be used only once, maintain a database table that contains the already used tokens.</li><li><strong>Storing JWTs securely: </strong>A JWT needs to be stored safely inside the user’s browser. If we store it inside localStorage, it’s accessible by any script inside your page, which is bad as an attacker can easily extract the token by running a script on the page. We shouldn’t store it in local storage (or session storage). If any of the third-party scripts included in our page gets compromised, it can access all tokens. Hence, the JWT needs to be stored inside an httpOnly cookie, a special kind of cookie that’s only sent in HTTP requests to the server, and it’s never accessible (both for reading or writing) from JavaScript running in the browser.</li></ul><h4>When not to use JWTs</h4><ul><li><strong>Session tokens for regular web apps:</strong> Using JWTs for session tokens might appear like a good idea at first — Any user data can be stored at the client-side. The server can trust the client because the JWT is signed, and there is no need to call the database to retrieve the information already stored in the JWT. We should use a sessions table and use regular sessions as provided by the server-side framework of choice. Why? There is a cost involved in using JWTs — they are sent for every request to the server, and it’s always a high cost compared to server-side sessions. Also, while the security risks are minimized by sending JWTs using HTTPS, there is always the possibility that it’s intercepted. The data deciphered(It’s not encrypted, remember?), exposing the user’s data.</li></ul><h4>Conclusion</h4><p>JWT is a prevalent standard to verify the integrity of the data shared over HTTPS requests. But they should be used wisely as they can easily be misused if stored/used incorrectly.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=991274d16038" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>