<?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 Pawan Pulami Magar on Medium]]></title>
        <description><![CDATA[Stories by Pawan Pulami Magar on Medium]]></description>
        <link>https://medium.com/@pulamigaurav8?source=rss-a125c2cb485d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*THNzHKCd6bhSt0_SkNACPg.png</url>
            <title>Stories by Pawan Pulami Magar on Medium</title>
            <link>https://medium.com/@pulamigaurav8?source=rss-a125c2cb485d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 24 May 2026 02:26:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pulamigaurav8/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[IP Address, NAT, and CIDR Notation Explained Simply]]></title>
            <link>https://medium.com/@pulamigaurav8/ip-addresses-nat-and-cidr-notation-explained-simply-cc6b3101ff27?source=rss-a125c2cb485d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc6b3101ff27</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[ip-address]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[cidr]]></category>
            <dc:creator><![CDATA[Pawan Pulami Magar]]></dc:creator>
            <pubDate>Sat, 20 Sep 2025 05:54:12 GMT</pubDate>
            <atom:updated>2025-09-20T14:37:40.972Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1euHz752SZH9n5XiKmx7fA.png" /></figure><p>An IP address is basically like the “street address” of a device on a network. Just as your home needs an address so people can find it, every device on the internet or a local network requires an IP address so data can reach it accurately. An IP address serves two main purposes:</p><ul><li>It tells the network who the device is.</li><li>It indicates the device&#39;s location, allowing data to locate it.</li></ul><p>An IPv4 address consists of 32 bits, divided into four sections called octets. Each octet contains 8 bits, which is why they are called “octets”. 32 bits allow for approximately 4,294,967,296 (2^³²) unique IP addresses.</p><p>IPv4 addresses are organized into octets ranging from 0 to 255 and are divided into classes (A through E) for different network sizes:</p><ul><li><strong>Class A</strong>: First bit is 0 (0–127) — Large networks with many hosts.</li><li><strong>Class B</strong>: First two bits are 10 (128–191) — Medium-sized networks.</li><li><strong>Class C</strong>: First three bits are 110 (192–223) — Small networks.</li><li><strong>Class D</strong>: First four bits are 1110 (224–239) — Multicast addresses.</li><li><strong>Class E</strong>: First four bits are 1111 (240–255) — Reserved for experimental use.</li></ul><p>The pool of available IPv4 addresses is running out, as the rapid growth of the number of users has led to more devices like smartphones, laptops, and smart gadgets needing their own IP addresses. The growing risk of IP address exhaustion led to the development of several solutions, including IPv6, which is a 128-bit system. It does help to address the problem of IPv4 exhaustion, which introduces a huge pool of IP addresses, but not so fast, although it does resolve the issue. Many devices and systems were originally designed with the IPv4 protocol in mind and are still in use today. Migrating all those systems to IPv6 is not so easy.</p><p>To slow down the exhaustion of IPv4, Network Address Translation (NAT) and Classless Inter-Domain Routing (CIDR) were introduced.</p><p><strong>Network Address Translation (NAT)</strong></p><p>NAT allows multiple devices on a private network to share a single public IP address, making more efficient use of the IPv4 limited address space. Inside a private network, every device has a private IP which is not accessible from the internet directly. The NAT device (using a router) has at least one public IP. When a device inside wants to send something out to the internet, the NAT device replaces the private source address with its own public IP. NAT also remembers which internal device made the request, so it can send any replies correctly.</p><p>NAT Diagram</p><pre><br>        [Internet]<br>            |<br>        [Public IP: 203.0.113.5]<br>            |<br>        +-----------------+<br>        |      Router     |  &lt;-- NAT device<br>        |  (performs NAT) |<br>        +-----------------+<br>        |       |       |<br>        |       |       |<br>[Laptop]  [Smartphone]  [Tablet]<br> 192.168.1.2 192.168.1.3 192.168.1.4<br> (Private IP) (Private IP) (Private IP)</pre><p><strong>Classless Inter-Domain Routing (CIDR)</strong></p><p>While NAT helps multiple devices share a single public IP, another solution called Classless Inter-Domain Routing (CIDR) was introduced to make better use of IPv4 addresses at the network level. Before the CIDR was created, the IPv4 addresses were divided into rigid classes such as A, B, and C.</p><ul><li>Class A (16.7 million addresses)</li><li>Class B (65000 addresses)</li><li>Class C (256 addresses)</li></ul><p>The issue with this is that most organizations don’t need such big chunks, which leads to wasted IP addresses. For example, a company with only a few hundred computers might receive a Class B block (65,000 addresses), which leaves tens of thousands of IP addresses unused. This led to a waste of IPv4 space.</p><p>CIDR solved this problem by allowing networks to be divided into blocks of different sizes using subnet masks like (/24), instead of being limited to just Class A, B, and C. This is called CIDR notation.</p><p>CIDR notation is a way to show an IP address together with its subnet mask in one simple format. Instead of writing the IP and the mask separately, CIDR combines them. <br>Example:</p><pre>192.168.1.0/24</pre><p>Here is the network address, 192.168.1.0, and /24 indicates the subnet mask (the first 24 bits are reserved for the network). This system enables organizations to obtain the exact number of IP addresses they need, and it helps ISPs manage routing more efficiently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CcBaNn1oLD8zZ8i2AIqb_g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc6b3101ff27" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How We Solved Authentication Issues Caused by Intelligent Tracking Prevention (ITP) in…]]></title>
            <link>https://medium.com/@pulamigaurav8/how-we-solved-authentication-issues-caused-by-intelligent-tracking-prevention-itp-in-04988d05cdc6?source=rss-a125c2cb485d------2</link>
            <guid isPermaLink="false">https://medium.com/p/04988d05cdc6</guid>
            <category><![CDATA[third-party-cookie]]></category>
            <category><![CDATA[sessions]]></category>
            <category><![CDATA[rails]]></category>
            <category><![CDATA[authentication]]></category>
            <category><![CDATA[iframe-embed]]></category>
            <dc:creator><![CDATA[Pawan Pulami Magar]]></dc:creator>
            <pubDate>Tue, 10 Jun 2025 16:33:19 GMT</pubDate>
            <atom:updated>2025-06-16T12:49:39.934Z</atom:updated>
            <content:encoded><![CDATA[<h3>How We Solved Authentication Issues Caused by Intelligent Tracking Prevention (ITP) in Iframe-Embedded Apps</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8yNzB4CW3njvLOoC" /><figcaption>Photo by <a href="https://unsplash.com/@brett_jordan?utm_source=medium&amp;utm_medium=referral">Brett Jordan</a> on <a href="https://unsplash.com?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Embedding our web app inside a client’s website using an iframe seemed straightforward at first. Everything worked perfectly except on Safari. Suddenly, users couldn’t log in when our app was loaded inside an iframe. The authentication process was broken, and we knew we had to dig deeper.</p><p>In this post, I’ll walk you through what we discovered about Apple’s Intelligent Tracking Prevention (ITP), why it interfered with our session-based authentication, and how we solved the problem so our app works reliably across all browsers including Safari.</p><h4>What is Intelligent Tracking Prevention (ITP), and Why Does It Matter?</h4><p>Apple introduced ITP to protect user privacy by blocking third-party tracking cookies. While this is great for users, it creates headaches for developers to resolve the issue in app that rely cookies for authentication — especially when our app is embedded as an iframe on a different domain.</p><p>In simple terms: Safari blocks cookies from domains it considers “third-party,” which means our session cookies inside the iframe were being blocked, breaking the login process.</p><h4>The Root Cause: Third-Party Cookies Blocked in Safari</h4><p>These were cause of the issue:</p><ul><li>Our client’s website was hosted on client-example.com</li><li>Our application was hosted on our-application.com</li><li>Safari treats our.application.com as a third-party domain inside the iframe on client-example.com</li><li>Because of ITP , Safari blocked the session cookies from our -application.com when loaded inside the iframe on client-example.com.</li></ul><p>After some digging , We found that Safari treats subdomins like client-example.com and sub.client-example.com as the same site. Cookies work fine between them because they share registered domain.</p><h4>What Could we Do? Exploring Our Options</h4><p>We explosed three possible solutions:</p><p><strong>1. Switch to JWT-Based Authentication</strong></p><p>Storing JWTs in local storage is possible, so the app wouldn’t rely on cookies and thus avoid ITP blocking. However, implementing this would require rewriting our frontend from server-rendered html.erb views to a Single Page Application (SPA). Given our timeline and resources, this was not feasible right away.</p><p><strong>2. Use a Subdomain with a CNAME DNS Record</strong></p><p>This was our breakthrough. By hosting our app on a subdomain of the client’s domain (e.g., sub.client-example.com ) via a CNAME record pointing to our servers, Safari considers the iframe first-party. This means cookies are allowed, and session authentication works as expected.</p><p><strong>3. Leverage Javascript Storage Access API</strong></p><p>Safari provides the Storage Access API, which lets embedded iframes request access to their cookies after user interaction. While useful, it requires users to perform an action (like clicking a button), which can disrupt the login flow and degrade user experience. However starting in 2018 , updates to the API removed the need for user prompts when an iframe request access, making the experience much smoother and less disruptive for users. <a href="https://webkit.org/blog/8124/introducing-storage-access-api/">(more details)</a></p><h4>Our Solution: Subdomain Integration via CNAME</h4><p>We worked with our client to set up a CNAME DNS record so our app was served from a subdomain of their domain. This simple DNS change made Safari treat our iframe as first-party, allowing session cookies to function normally.</p><p>On the Rails side, we configured our session store to allow cookies on the client’s domain:</p><pre>Rails.application.config.session_store :cookie_store,<br>  key: &#39;_your_app_session&#39;,<br>  same_site: :none,<br>  secure: true</pre><ul><li>Use Secure and SameSite=None for cross-origin cookies</li><li>Avoid SameSite=Lax or Strict, which block cross-site usage</li></ul><h4>Final Thoughts</h4><p>ITP is a win for user privacy but a challenge for cross-domain iframe authentication. Understanding how browsers classify domains and cookies is key to finding the right workaround.</p><p>If you’re facing similar issues, consider whether a subdomain setup is possible with your client. It’s often the simplest and most effective fix without a major rewrite.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=04988d05cdc6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>