<?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 Tanuj Sharma on Medium]]></title>
        <description><![CDATA[Stories by Tanuj Sharma on Medium]]></description>
        <link>https://medium.com/@tsharma2907?source=rss-f6e1363bca44------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*DFzCHZxhIHITBaaDMRD3iQ.jpeg</url>
            <title>Stories by Tanuj Sharma on Medium</title>
            <link>https://medium.com/@tsharma2907?source=rss-f6e1363bca44------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 10:45:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tsharma2907/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[Building an OTP Authentication System with Node.js, Express, Redis & Docker]]></title>
            <link>https://tsharma2907.medium.com/building-an-otp-authentication-system-with-node-js-express-redis-docker-c50c006a33d1?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/c50c006a33d1</guid>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Mon, 12 Oct 2026 17:45:07 GMT</pubDate>
            <atom:updated>2026-10-12T17:45:07.773Z</atom:updated>
            <content:encoded><![CDATA[<p>OTP-based authentication looks simple from the outside:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/554/1*kCbSNfX-v8C_MoGZfUhjWQ.jpeg" /></figure><blockquote><em>Enter your phone number → receive an OTP → enter the OTP → you’re verified.</em></blockquote><p>But behind those two input boxes, there is a small distributed system doing quite a bit of work.</p><p>We need to:</p><ul><li>Generate a secure OTP</li><li>Store it temporarily</li><li>Automatically expire it</li><li>Retrieve it when the user verifies</li><li>Delete it after successful verification</li><li>Prevent expired OTPs from being accepted</li></ul><p>For this tutorial, we’ll build a simple OTP service using:</p><ul><li><strong>Node.js</strong></li><li><strong>Express.js</strong></li><li><strong>Redis</strong></li><li><strong>ioredis</strong></li><li><strong>Docker</strong></li></ul><p>By the end, we’ll have three APIs:</p><pre>POST /otp<br>POST /otp/verify<br>GET  /otp/:phone/ttl</pre><p>And Redis will automatically delete OTPs after 30 seconds.</p><h3>1. Why Redis for OTPs?</h3><p>Before writing any code, let’s understand why Redis is a good fit.</p><p>An OTP is temporary data.</p><p>Suppose a user requests:</p><pre>Phone: +919876543210<br>OTP: 583921</pre><p>We don’t want this OTP sitting in our database forever.</p><p>We only need it for a short period:</p><pre>583921<br>   ↓<br>30 seconds<br>   ↓<br>EXPIRED</pre><p>Redis is an in-memory key-value store that supports <strong>TTL (Time To Live)</strong>.</p><p>We can store:</p><pre>otp:+919876543210 → 583921</pre><p>with an expiration time:</p><pre>TTL = 30 seconds</pre><p>After 30 seconds, Redis automatically removes the key.</p><p>This makes Redis particularly useful for:</p><ul><li>OTPs</li><li>Sessions</li><li>Temporary tokens</li><li>Password reset tokens</li><li>Rate limiting</li><li>Caching</li><li>Verification codes</li></ul><h3>2. Installing Docker</h3><p>The easiest way to run Redis locally without installing Redis directly on your operating system is Docker.</p><p>Download and install Docker Desktop from the official Docker website.</p><p>After installation, verify that Docker is working:</p><pre>docker --version</pre><p>You should get something similar to:</p><pre>Docker version 27.x.x</pre><p>Also verify:</p><pre>docker ps</pre><p>If Docker is running, you’ll see the list of running containers.</p><h3>3. Running Redis with Docker</h3><p>Instead of installing Redis directly on our machine, let’s run it inside a Docker container.</p><p>Run:</p><pre>docker run --name redis-otp -p 6379:6379 -d redis</pre><p>Let’s break this command down.</p><h3>docker run</h3><p>Creates and starts a new container.</p><h3>--name redis-otp</h3><p>Gives our container a readable name:</p><pre>redis-otp</pre><h3>-p 6379:6379</h3><p>This maps:</p><pre>Your machine:6379<br>        ↓<br>Container:6379</pre><p>Redis normally listens on port 6379.</p><h3>-d</h3><p>Runs the container in detached mode.</p><p>In other words, Redis runs in the background.</p><h3>redis</h3><p>This tells Docker to use the official Redis image.</p><h3>4. Checking Whether Redis Is Running</h3><p>Run:</p><pre>docker ps</pre><p>You should see something similar to:</p><pre>CONTAINER ID   IMAGE   PORTS<br>xxxxxxxx       redis   0.0.0.0:6379-&gt;6379/tcp</pre><p>Our Redis server is now available at:</p><pre>127.0.0.1:6379</pre><p>We can also connect directly to Redis inside the container:</p><pre>docker exec -it redis-otp redis-cli</pre><p>You’ll enter the Redis CLI.</p><p>Try:</p><pre>PING</pre><p>Redis should respond:</p><pre>PONG</pre><p>Congratulations — Redis is alive.</p><h3>5. Creating the Node.js Project</h3><p>Now let’s create our application.</p><pre>mkdir otp-service<br>cd otp-service</pre><p>Initialize a Node project:</p><pre>npm init -y</pre><p>This creates:</p><pre>package.json</pre><p>Now install Express and ioredis:</p><pre>npm install express ioredis</pre><p>We need two packages.</p><h3>Express</h3><p>Express will handle our HTTP APIs.</p><h3>ioredis</h3><p>ioredis is a Node.js Redis client that allows our application to communicate with Redis.</p><h3>6. Enable ES Modules</h3><p>Our code uses:</p><pre>import express from &quot;express&quot;;</pre><p>instead of:</p><pre>const express = require(&quot;express&quot;);</pre><p>Therefore, add this to package.json:</p><pre>{<br>  &quot;type&quot;: &quot;module&quot;<br>}</pre><p>For example:</p><pre>{<br>  &quot;name&quot;: &quot;otp-service&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;type&quot;: &quot;module&quot;,<br>  &quot;main&quot;: &quot;server.js&quot;,<br>  &quot;scripts&quot;: {<br>    &quot;start&quot;: &quot;node server.js&quot;<br>  },<br>  &quot;dependencies&quot;: {<br>    &quot;express&quot;: &quot;...&quot;,<br>    &quot;ioredis&quot;: &quot;...&quot;<br>  }<br>}</pre><h3>7. Creating the Express Server</h3><p>Create a file:</p><pre>server.js</pre><p>Start with:</p><pre>import express from &quot;express&quot;;</pre><pre>const app = express();</pre><pre>app.use(express.json());</pre><p>Let’s understand what’s happening.</p><h3>Import Express</h3><pre>import express from &quot;express&quot;;</pre><p>We’re importing the Express framework.</p><h3>Creating the application</h3><pre>const app = express();</pre><p>This creates our Express application.</p><h3>Parsing JSON</h3><pre>app.use(express.json());</pre><p>Our APIs will receive JSON requests such as:</p><pre>{<br>  &quot;phone&quot;: &quot;9876543210&quot;<br>}</pre><p>Without express.json(), Express won&#39;t automatically parse this request body.</p><h3>8. Connecting Node.js to Redis</h3><p>Now we need to connect our application to Redis.</p><pre>import Redis from &quot;ioredis&quot;;</pre><pre>const redis = new Redis(<br>  process.env.REDIS_URL || &quot;redis://127.0.0.1:6379&quot;<br>);</pre><p>There are two important concepts here.</p><h3>ioredis</h3><pre>import Redis from &quot;ioredis&quot;;</pre><p>This imports the Redis client.</p><p>Then:</p><pre>const redis = new Redis(...);</pre><p>creates a Redis connection.</p><h3>9. Why Use process.env.REDIS_URL?</h3><p>This part is important:</p><pre>process.env.REDIS_URL || &quot;redis://127.0.0.1:6379&quot;</pre><p>It means:</p><blockquote><em>If a </em><em>REDIS_URL environment variable exists, use it. Otherwise, connect to local Redis.</em></blockquote><p>During local development:</p><pre>redis://127.0.0.1:6379</pre><p>might be enough.</p><p>But when deploying to production, Redis might be somewhere else:</p><pre>redis://username:password@redis-server:6379</pre><p>Using an environment variable means we don’t have to change our code.</p><h3>10. Designing Our Redis Key</h3><p>Now we need to decide how we’re going to store OTPs.</p><p>We’ll create keys like:</p><pre>otp:9876543210</pre><p>For that, we’ll create a helper function:</p><pre>function otpKey(phone) {<br>  return `otp:${phone}`;<br>}</pre><p>So:</p><pre>otpKey(&quot;9876543210&quot;);</pre><p>returns:</p><pre>otp:9876543210</pre><p>This is called a <strong>key-naming convention</strong>.</p><p>It becomes especially useful when Redis contains thousands or millions of keys.</p><p>For example:</p><pre>otp:9876543210<br>otp:9123456789<br>otp:9988776655</pre><p>All OTP-related keys start with:</p><pre>otp:</pre><h3>11. Generating the OTP</h3><p>Now comes the actual OTP generation.</p><pre>const otp = Math.floor(<br>  100000 + Math.random() * 900000<br>).toString();</pre><p>Let’s break this down.</p><p>We want a six-digit number.</p><p>The minimum should be:</p><pre>100000</pre><p>The maximum should be:</p><pre>999999</pre><p>So:</p><pre>Math.random()</pre><p>generates a random number between:</p><pre>0</pre><p>and:</p><pre>1</pre><p>Then:</p><pre>Math.random() * 900000</pre><p>gives a number between approximately:</p><pre>0</pre><p>and:</p><pre>899999</pre><p>Adding 100000 gives us:</p><pre>100000 → 999999</pre><p>Finally:</p><pre>Math.floor(...)</pre><p>removes the decimal part.</p><p>And:</p><pre>.toString()</pre><p>converts the number into a string.</p><p>So we end up with something like:</p><pre>583921</pre><h3>12. Storing the OTP in Redis</h3><p>Now we have our OTP.</p><p>But generating it isn’t enough.</p><p>We need to store it somewhere temporarily.</p><p>That’s where Redis comes in.</p><pre>await redis.set(<br>  otpKey(phone),<br>  otp,<br>  &quot;EX&quot;,<br>  30<br>);</pre><p>This single line is doing a lot.</p><p>Conceptually, we’re telling Redis:</p><pre>SET otp:9876543210 583921<br>EXPIRE after 30 seconds</pre><p>The Redis command is:</p><pre>SET key value EX seconds</pre><p>Therefore:</p><pre>redis.set(<br>  &quot;otp:9876543210&quot;,<br>  &quot;583921&quot;,<br>  &quot;EX&quot;,<br>  30<br>);</pre><p>means:</p><pre>Key:<br>otp:9876543210</pre><pre>Value:<br>583921</pre><pre>Expiration:<br>30 seconds</pre><h3>13. Why TTL Is Important</h3><p>Without expiration, the OTP could remain in Redis indefinitely.</p><p>That’s bad.</p><p>Imagine:</p><pre>User requests OTP<br>        ↓<br>OTP stored<br>        ↓<br>User never verifies<br>        ↓<br>OTP remains forever</pre><p>With TTL:</p><pre>User requests OTP<br>        ↓<br>OTP stored<br>        ↓<br>TTL = 30 seconds<br>        ↓<br>30 seconds pass<br>        ↓<br>Redis automatically removes OTP</pre><p>We don’t need a separate cleanup job.</p><p>Redis handles the expiration.</p><h3>14. Creating the /otp Endpoint</h3><p>Now let’s put everything together.</p><pre>app.post(&quot;/otp&quot;, async (req, res) =&gt; {<br>  const { phone } = req.body;</pre><pre>  const otp = Math.floor(<br>    100000 + Math.random() * 900000<br>  ).toString();</pre><pre>  await redis.set(<br>    otpKey(phone),<br>    otp,<br>    &quot;EX&quot;,<br>    30<br>  );</pre><pre>  res.json({<br>    message: &quot;OTP Sent&quot;,<br>    otp<br>  });<br>});</pre><p>The endpoint is:</p><pre>POST /otp</pre><p>The client sends:</p><pre>{<br>  &quot;phone&quot;: &quot;9876543210&quot;<br>}</pre><p>Our server generates:</p><pre>583921</pre><p>Then Redis stores:</p><pre>otp:9876543210 → 583921</pre><p>with:</p><pre>TTL = 30 seconds</pre><h3>15. Why Are We Returning the OTP?</h3><p>You’ll notice something interesting:</p><pre>res.json({<br>  message: &quot;OTP Sent&quot;,<br>  otp<br>});</pre><p>We’re returning the OTP in the API response.</p><p>That’s useful for development and testing because we don’t have an SMS provider connected yet.</p><p>For example:</p><pre>{<br>  &quot;message&quot;: &quot;OTP Sent&quot;,<br>  &quot;otp&quot;: &quot;583921&quot;<br>}</pre><h3>But don’t do this in production.</h3><p>A real application would send the OTP through an SMS provider such as an SMS gateway.</p><p>The API response should instead look more like:</p><pre>{<br>  &quot;message&quot;: &quot;OTP sent successfully&quot;<br>}</pre><p>The actual OTP should never be returned to the client.</p><h3>16. Verifying the OTP</h3><p>Now we need another endpoint.</p><pre>POST /otp/verify</pre><p>The client sends:</p><pre>{<br>  &quot;phone&quot;: &quot;9876543210&quot;,<br>  &quot;otp&quot;: &quot;583921&quot;<br>}</pre><p>Our server retrieves the OTP from Redis.</p><pre>const savedOtp = await redis.get(<br>  otpKey(phone)<br>);</pre><p>If Redis contains:</p><pre>otp:9876543210 → 583921</pre><p>then:</p><pre>savedOtp</pre><p>will contain:</p><pre>583921</pre><h3>17. Handling Expired OTPs</h3><p>What happens if 30 seconds have passed?</p><p>Redis automatically deletes the key.</p><p>Therefore:</p><pre>const savedOtp = await redis.get(<br>  otpKey(phone)<br>);</pre><p>returns:</p><pre>null</pre><p>So we check:</p><pre>if (!savedOtp) {<br>  return res.status(400).json({<br>    message: &quot;OTP expired or not found&quot;<br>  });<br>}</pre><p>This handles both situations:</p><ul><li>OTP never existed</li><li>OTP existed but expired</li></ul><h3>18. Comparing the OTPs</h3><p>If the OTP exists, we compare it with the OTP provided by the user.</p><pre>if (savedOtp !== otp) {<br>  return res.status(400).json({<br>    message: &quot;Invalid OTP&quot;<br>  });<br>}</pre><p>For example:</p><p>Redis:</p><pre>583921</pre><p>User:</p><pre>583921</pre><p>Result:</p><pre>MATCH</pre><p>But if the user sends:</p><pre>123456</pre><p>then:</p><pre>583921 !== 123456</pre><p>and the request is rejected.</p><h3>19. Deleting the OTP After Successful Verification</h3><p>Suppose the OTP is correct.</p><p>We don’t want the same OTP to be usable again.</p><p>So we delete it:</p><pre>await redis.del(otpKey(phone));</pre><p>Now:</p><pre>otp:9876543210</pre><p>is gone.</p><p>This gives us another important security property:</p><blockquote><em>An OTP can only be used once.</em></blockquote><p>The complete flow becomes:</p><pre>Generate OTP<br>     ↓<br>Store in Redis<br>     ↓<br>TTL = 30 seconds<br>     ↓<br>User enters OTP<br>     ↓<br>Read OTP from Redis<br>     ↓<br>Compare<br>     ↓<br>Correct?<br> ┌───┴────┐<br>No       Yes<br>↓         ↓<br>Reject   Delete OTP<br>          ↓<br>        Verify</pre><h3>20. Checking OTP TTL</h3><p>We also created another endpoint:</p><pre>GET /otp/:phone/ttl</pre><p>The implementation is:</p><pre>app.get(&quot;/otp/:phone/ttl&quot;, async (req, res) =&gt; {<br>  const ttl = await redis.ttl(<br>    otpKey(req.params.phone)<br>  );</pre><pre>  res.json({ ttl });<br>});</pre><p>Suppose we request:</p><pre>GET /otp/9876543210/ttl</pre><p>Redis might return:</p><pre>{<br>  &quot;ttl&quot;: 23<br>}</pre><p>That means the OTP has approximately 23 seconds remaining.</p><h3>21. Understanding Redis TTL</h3><p>Redis has a built-in command:</p><pre>TTL key</pre><p>For example:</p><pre>TTL otp:9876543210</pre><p>could return:</p><pre>17</pre><p>Meaning:</p><pre>17 seconds remaining</pre><p>If the key doesn’t exist, Redis can return:</p><pre>-2</pre><p>And if the key exists but doesn’t have an expiration:</p><pre>-1</pre><p>In our application, OTP keys should always have an expiration.</p><h3>22. Complete Code</h3><p>Here’s the complete development version of our server:</p><pre>import express from &quot;express&quot;;<br>import Redis from &quot;ioredis&quot;;</pre><pre>const app = express();</pre><pre>app.use(express.json());</pre><pre>const redis = new Redis(<br>  process.env.REDIS_URL ||<br>    &quot;redis://127.0.0.1:6379&quot;<br>);</pre><pre>function otpKey(phone) {<br>  return `otp:${phone}`;<br>}</pre><pre>app.post(&quot;/otp&quot;, async (req, res) =&gt; {<br>  const { phone } = req.body;</pre><pre>  const otp = Math.floor(<br>    100000 + Math.random() * 900000<br>  ).toString();</pre><pre>  await redis.set(<br>    otpKey(phone),<br>    otp,<br>    &quot;EX&quot;,<br>    30<br>  );</pre><pre>  res.json({<br>    message: &quot;OTP Sent&quot;,<br>    otp<br>  });<br>});</pre><pre>app.post(&quot;/otp/verify&quot;, async (req, res) =&gt; {<br>  const { phone, otp } = req.body;</pre><pre>  const savedOtp = await redis.get(<br>    otpKey(phone)<br>  );</pre><pre>  if (!savedOtp) {<br>    return res.status(400).json({<br>      message: &quot;OTP expired or not found&quot;<br>    });<br>  }</pre><pre>  if (savedOtp !== otp) {<br>    return res.status(400).json({<br>      message: &quot;Invalid OTP&quot;<br>    });<br>  }</pre><pre>  await redis.del(otpKey(phone));</pre><pre>  res.json({<br>    message: &quot;OTP Verified successfully&quot;<br>  });<br>});</pre><pre>app.get(&quot;/otp/:phone/ttl&quot;, async (req, res) =&gt; {<br>  const ttl = await redis.ttl(<br>    otpKey(req.params.phone)<br>  );</pre><pre>  res.json({ ttl });<br>});</pre><pre>app.listen(3000, () =&gt; {<br>  console.log(<br>    &quot;Server running on port http://127.0.0.1:3000&quot;<br>  );<br>});</pre><h3>23. Starting the Application</h3><p>Make sure Redis is running:</p><pre>docker ps</pre><p>Then start Node:</p><pre>node server.js</pre><p>Or, if you added the npm script:</p><pre>npm start</pre><p>You should see:</p><pre>Server running on port http://127.0.0.1:3000</pre><p>Our architecture now looks like this:</p><pre>Client<br>               |<br>               | POST /otp<br>               ↓<br>        ┌───────────────┐<br>        │ Node + Express│<br>        └───────┬───────┘<br>                |<br>                | Generate OTP<br>                ↓<br>        ┌───────────────┐<br>        │     Redis     │<br>        │               │<br>        │ otp:9876 →    │<br>        │    583921     │<br>        │               │<br>        │ TTL = 30 sec  │<br>        └───────────────┘<br>                |<br>                ↓<br>             Client</pre><p>For verification:</p><pre>Client<br>  |<br>  | phone + OTP<br>  ↓<br>Express<br>  |<br>  | GET OTP<br>  ↓<br>Redis<br>  |<br>  | Compare<br>  ↓<br>Express<br>  |<br>  ├── Wrong → 400<br>  |<br>  └── Correct<br>        ↓<br>      DEL OTP<br>        ↓<br>      Success</pre><h3>24. Testing the API</h3><p>You can use Postman, RequestKit, Insomnia, Thunder Client, or curl.</p><h3>Request OTP</h3><pre>POST http://localhost:3000/otp</pre><p>Body:</p><pre>{<br>  &quot;phone&quot;: &quot;9876543210&quot;<br>}</pre><p>Response:</p><pre>{<br>  &quot;message&quot;: &quot;OTP Sent&quot;,<br>  &quot;otp&quot;: &quot;583921&quot;<br>}</pre><h3>Check TTL</h3><pre>GET http://localhost:3000/otp/9876543210/ttl</pre><p>Response:</p><pre>{<br>  &quot;ttl&quot;: 24<br>}</pre><p>Wait a few seconds and request it again:</p><pre>{<br>  &quot;ttl&quot;: 17<br>}</pre><p>Redis is automatically counting down.</p><h3>Verify OTP</h3><pre>POST http://localhost:3000/otp/verify</pre><p>Body:</p><pre>{<br>  &quot;phone&quot;: &quot;9876543210&quot;,<br>  &quot;otp&quot;: &quot;583921&quot;<br>}</pre><p>Response:</p><pre>{<br>  &quot;message&quot;: &quot;OTP Verified successfully&quot;<br>}</pre><p>Now try verifying the same OTP again.</p><p>You’ll get:</p><pre>{<br>  &quot;message&quot;: &quot;OTP expired or not found&quot;<br>}</pre><p>That’s because we deleted it after successful verification.</p><h3>25. What Happens Inside Redis?</h3><p>Let’s visualize the entire lifecycle.</p><p>Immediately after requesting an OTP:</p><pre>Redis</pre><pre>KEY                         VALUE<br>────────────────────────────────────<br>otp:9876543210              583921</pre><pre>TTL: 30</pre><p>After 10 seconds:</p><pre>KEY                         VALUE<br>────────────────────────────────────<br>otp:9876543210              583921</pre><pre>TTL: 20</pre><p>After 20 more seconds:</p><pre>KEY                         VALUE<br>────────────────────────────────────<br>(nothing)</pre><p>Redis automatically removed the key.</p><p>That’s one of the biggest reasons Redis is so convenient for temporary data.</p><h3>26. A Very Important Production Problem</h3><p>Our demo works, but there are several things we should improve before calling this a production-ready OTP service.</p><p>The biggest one is this:</p><pre>Math.random()</pre><p>is <strong>not appropriate for security-sensitive OTP generation</strong>.</p><p>For a real authentication system, Node.js provides a cryptographically secure random generator through the crypto module.</p><p>For example:</p><pre>import crypto from &quot;crypto&quot;;</pre><pre>const otp = crypto<br>  .randomInt(100000, 1000000)<br>  .toString();</pre><p>Now we’re using a cryptographically stronger source of randomness.</p><p>That’s what I would use in a real application.</p><h3>27. Don’t Store OTPs in Plain Text</h3><p>Our demo stores:</p><pre>otp:9876543210 → 583921</pre><p>This is easy to understand, but a production system can go one step further.</p><p>Instead of storing the OTP itself, we can store a hash:</p><pre>OTP<br> ↓<br>Hash<br> ↓<br>Redis</pre><p>Then during verification:</p><pre>User OTP<br> ↓<br>Hash<br> ↓<br>Compare with Redis</pre><p>This means someone who gains access to Redis doesn’t immediately see every active OTP.</p><p>For a production authentication system, this is a worthwhile security improvement.</p><h3>28. Add Rate Limiting</h3><p>There’s another major problem.</p><p>What’s stopping someone from doing this?</p><pre>POST /otp<br>POST /otp<br>POST /otp<br>POST /otp<br>POST /otp<br>...</pre><p>Thousands of times.</p><p>That’s why real OTP systems need rate limiting.</p><p>For example:</p><pre>Maximum 3 OTP requests<br>per phone number<br>within 10 minutes</pre><p>And potentially:</p><pre>Maximum 20 requests<br>per IP<br>per minute</pre><p>Redis is actually excellent for implementing this too.</p><p>That’s where the same technology becomes useful beyond simply storing the OTP.</p><h3>29. Never Expose the OTP in Production</h3><p>Our development API returns:</p><pre>{<br>  &quot;message&quot;: &quot;OTP Sent&quot;,<br>  &quot;otp&quot;: &quot;583921&quot;<br>}</pre><p>This should <strong>not</strong> happen in production.</p><p>Instead:</p><pre>{<br>  &quot;message&quot;: &quot;OTP sent successfully&quot;<br>}</pre><p>The OTP should be delivered through your SMS provider.</p><p>The architecture becomes:</p><pre>User<br>               |<br>               | Phone number<br>               ↓<br>        Node + Express<br>               |<br>        Generate OTP<br>               |<br>          ┌────┴─────┐<br>          ↓          ↓<br>       Redis      SMS Provider<br>          |          |<br>       Store       Send OTP<br>          |          |<br>          └────┬─────┘<br>               ↓<br>             User</pre><h3>30. Environment Variables</h3><p>In production, don’t hardcode things like:</p><pre>redis://username:password@server</pre><p>Instead:</p><pre>REDIS_URL=redis://...</pre><p>and access it with:</p><pre>process.env.REDIS_URL</pre><p>Similarly, SMS credentials should live in environment variables.</p><p>For example:</p><pre>REDIS_URL=...<br>SMS_API_KEY=...<br>SMS_API_SECRET=...</pre><p>Never commit secrets to GitHub.</p><h3>31. Why Docker Makes This Easier</h3><p>Without Docker, you’d need to install and configure Redis on your machine.</p><p>With Docker:</p><pre>docker run redis</pre><p>and you’re done.</p><p>Your architecture becomes:</p><pre>┌──────────────────────────────┐<br>│          Your PC             │<br>│                              │<br>│  ┌────────────────────────┐  │<br>│  │     Node.js App        │  │<br>│  │     Express            │  │<br>│  └───────────┬────────────┘  │<br>│              │               │<br>│              │ localhost:6379│<br>│              ↓               │<br>│  ┌────────────────────────┐  │<br>│  │    Docker Container    │  │<br>│  │                        │  │<br>│  │        Redis           │  │<br>│  └────────────────────────┘  │<br>│                              │<br>└──────────────────────────────┘</pre><p>This also makes it much easier to reproduce the same development environment on another machine.</p><h3>32. The Complete OTP Lifecycle</h3><p>At this point, we can summarize the entire system in seven steps.</p><h3>Step 1 — User requests OTP</h3><pre>POST /otp</pre><h3>Step 2 — Server generates a six-digit OTP</h3><pre>583921</pre><h3>Step 3 — OTP is stored in Redis</h3><pre>otp:9876543210 → 583921</pre><h3>Step 4 — Redis sets a TTL</h3><pre>30 seconds</pre><h3>Step 5 — OTP is delivered to the user</h3><p>In production, through an SMS provider.</p><h3>Step 6 — User submits OTP</h3><pre>POST /otp/verify</pre><h3>Step 7 — Server verifies and deletes it</h3><pre>Correct → DEL key → Verified</pre><p>If the TTL reaches zero first:</p><pre>OTP → automatically deleted → Expired</pre><h3>33. Final Architecture</h3><p>Our small application demonstrates an important backend pattern:</p><pre>┌─────────────┐<br>                    │    Client   │<br>                    └──────┬──────┘<br>                           │<br>                    POST /otp<br>                           │<br>                           ↓<br>                 ┌──────────────────┐<br>                 │  Express Server  │<br>                 └────────┬─────────┘<br>                          │<br>                   Generate OTP<br>                          │<br>                          ↓<br>                 ┌──────────────────┐<br>                 │      Redis       │<br>                 │                  │<br>                 │ otp:phone → OTP  │<br>                 │                  │<br>                 │ TTL = 30 seconds │<br>                 └────────┬─────────┘<br>                          │<br>                          │<br>                    OTP expires<br>                          │<br>                          ↓<br>                    Redis deletes<br>                     automatically<br></pre><pre>Verification:</pre><pre>Client<br>  │<br>  │ phone + OTP<br>  ↓<br>Express<br>  │<br>  │ GET<br>  ↓<br>Redis<br>  │<br>  ├── Doesn&#39;t exist → Expired<br>  │<br>  └── Exists<br>        │<br>        ↓<br>      Compare<br>        │<br>     ┌──┴──┐<br>     │     │<br>   Wrong  Correct<br>     │     │<br>   Reject  DEL<br>           │<br>           ↓<br>        Verified</pre><h3>Conclusion</h3><p>Building an OTP system is a great example of how a seemingly simple feature introduces several important backend concepts.</p><p>We used:</p><p><strong>Node.js + Express</strong> to build the API.</p><p><strong>Redis</strong> to store temporary OTP data.</p><p><strong>TTL</strong> to automatically expire OTPs.</p><p><strong>Docker</strong> to run Redis without installing it directly on our machine.</p><p>The most interesting part is that Redis isn’t just acting as a database here. We’re using it as a <strong>temporary state store</strong>.</p><p>The key idea is:</p><pre>Temporary data → Redis<br>Permanent data → Database</pre><p>An OTP doesn’t belong in your PostgreSQL/MySQL database forever. It has a short lifecycle, and Redis’s expiration mechanism maps almost perfectly to that requirement.</p><p>And once you understand this pattern, you can reuse the same idea for much more than OTPs:</p><pre>OTP<br>Session<br>Password Reset Token<br>Email Verification<br>Rate Limiting<br>Caching<br>Temporary Locks<br>API Throttling</pre><p>That’s where Redis starts getting really interesting.</p><p>The OTP itself is only the beginning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c50c006a33d1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I build a Redis-Powered Rate Limiter for Django and FastAPI]]></title>
            <link>https://tsharma2907.medium.com/i-build-a-redis-powered-rate-limiter-for-django-and-fastapi-35fd118bb276?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/35fd118bb276</guid>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[open-source-contribution]]></category>
            <category><![CDATA[system-design-concepts]]></category>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[open-source-software]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Sat, 10 Oct 2026 18:19:05 GMT</pubDate>
            <atom:updated>2026-10-10T18:19:05.350Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Protecting APIs shouldn’t mean reinventing the wheel.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*Mg_xW-OGGOedbTwic9vDbw.png" /></figure><p>Modern applications depend on APIs for almost everything, from user authentication and payment processing to real-time communication and AI-powered services. As these applications grow, so does the challenge of managing incoming traffic.</p><p>What happens when a single user sends thousands of requests to your API? What if a bot repeatedly attempts to log in? What if one tenant in your SaaS application consumes so many resources that other customers experience degraded performance?</p><p>These aren’t just hypothetical problems. They can lead to service disruptions, unnecessary infrastructure costs, and a poor user experience.</p><p>One of the most effective ways to address these challenges is <strong>rate limiting</strong>.</p><p>However, implementing rate limiting correctly across multiple application instances, frameworks, and user tiers introduces its own set of engineering challenges.</p><p>That’s where <strong>RateForge</strong> comes in.</p><p>RateForge is a Redis-backed rate-limiting library for Python applications, designed to integrate with Django and FastAPI while providing configurable request limits, distributed enforcement, health checks, and configurable behavior when Redis becomes unavailable.</p><p>The goal is simple: make API rate limiting easier to implement without sacrificing the flexibility developers need to build reliable applications.</p><p>Let’s explore the problem, the architecture, and the engineering decisions behind RateForge.</p><h3>1. The Problem: Why Do APIs Need Rate Limiting?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/552/1*fD6KxQoZfTlSkcAdvXGohw.png" /></figure><p>Imagine you’re building a SaaS platform with a REST API.</p><p>Your application has several endpoints:</p><ul><li>/api/auth/login for user authentication.</li><li>/api/users for retrieving user information.</li><li>/api/orders for creating orders.</li><li>/api/reports for generating reports.</li><li>/api/analytics for retrieving analytical data.</li></ul><p>Initially, everything works perfectly.</p><p>Your application has relatively few users, your database handles the workload, and your server responds quickly.</p><p>Then your application starts growing.</p><p>Some users begin making hundreds of requests per minute. A poorly configured frontend repeatedly calls the same endpoint. Bots start hammering your login endpoint. One customer runs an automated integration that consumes substantially more resources than everyone else.</p><p>Without rate limiting, your application has limited control over how frequently individual clients can access its resources.</p><h3>The consequences of unrestricted API traffic</h3><p><strong>1. Resource exhaustion</strong></p><p>Every request consumes some combination of CPU time, memory, database connections, network bandwidth, and application resources.</p><p>Excessive requests can overwhelm these resources and degrade performance.</p><p><strong>2. Brute-force attempts</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/678/1*E4zmoWAJSxKC30BXlxFeLQ.jpeg" /></figure><p>Authentication endpoints are particularly vulnerable to repeated login attempts. Rate limiting adds a layer of protection by restricting how frequently a client can attempt authentication.</p><p>It should complement, rather than replace, other security measures.</p><p><strong>3. Unfair resource consumption</strong></p><p>In a multi-tenant SaaS application, one customer shouldn’t automatically be able to consume resources at the expense of every other customer.</p><p>Rate limits help establish predictable usage boundaries.</p><p><strong>4. Unexpected infrastructure costs</strong></p><p>Some endpoints trigger expensive database queries, external API calls, or computationally intensive operations.</p><p>Restricting request frequency can help control the workload generated by these endpoints.</p><p><strong>5. Unreliable user experiences</strong></p><p>When traffic becomes excessive, legitimate users may experience slow responses or failed requests.</p><p>Rate limiting helps an application manage demand before it becomes an uncontrolled problem.</p><h3>The solution: Rate limiting</h3><p>Rate limiting defines how many requests a client can make within a specified period.</p><p>For example:</p><p>EndpointExample limitPurposeLogin5 requests per minuteReduce repeated authentication attemptsUser profile100 requests per minuteControl routine API consumptionReport generation10 requests per minuteProtect expensive operationsPublic API1,000 requests per hourEnforce an overall usage quota</p><p>These are illustrative policies, not universal recommendations. Appropriate limits depend on the application, its workload, and its users.</p><p>When a client exceeds its limit, the application can reject additional requests with HTTP 429 Too Many Requests.</p><p>The challenge is implementing this behavior consistently and efficiently.</p><h3>2. Why Not Just Build a Simple Rate Limiter?</h3><p>A basic rate limiter sounds straightforward.</p><p>Maintain a counter for each client, increment it whenever a request arrives, and reject requests when the counter exceeds a threshold.</p><p>For a small application running in a single process, this approach might be sufficient.</p><p>However, it introduces several problems as the application grows.</p><h3>Problem 1: In-memory counters aren’t shared</h3><p>Suppose your application runs on three server instances behind a load balancer.</p><p>Each instance maintains its own request counter.</p><p>A client sends requests to all three instances. Each server sees only a portion of the client’s total traffic.</p><p>If each server allows 100 requests per minute, the client might effectively make substantially more than 100 requests across the entire application.</p><p>The problem is that the counters aren’t shared.</p><h3>Problem 2: Concurrent requests create race conditions</h3><p>Imagine a client has made 99 requests against a limit of 100.</p><p>Two additional requests arrive simultaneously.</p><p>Both requests read the counter before either updates it. Both see 99 and conclude that another request is allowed.</p><p>The limit can be exceeded because the check-and-update operation isn’t atomic.</p><h3>Problem 3: Rate-limiting logic becomes duplicated</h3><p>Without a reusable component, developers may implement separate throttling logic for different endpoints or frameworks.</p><p>This creates maintenance overhead and increases the risk of inconsistent behavior.</p><h3>Problem 4: Failure handling becomes complicated</h3><p>What should happen if the rate-limiting storage becomes unavailable?</p><p>Should the application reject every request? Should it allow requests to continue? Should only sensitive endpoints fail?</p><p>The correct answer depends on the application’s risk profile.</p><p>A useful rate-limiting library should make these decisions configurable rather than leaving every developer to implement them independently.</p><p>These challenges shaped the design of RateForge.</p><h3>3. Introducing RateForge</h3><p>RateForge is a Python rate-limiting library built around Redis and designed for integration with Django and FastAPI.</p><p>Instead of requiring developers to implement request counters, storage coordination, rate-limit decisions, and framework integration from scratch, it provides reusable components for these responsibilities.</p><p>Its core capabilities include:</p><ul><li>Redis-backed rate limiting.</li><li>Sliding-window request tracking.</li><li>Django decorators and middleware.</li><li>FastAPI decorators and dependency injection.</li><li>Per-client and per-endpoint rate-limit policies.</li><li>Support for IP addresses, authenticated users, API keys, and custom identities.</li><li>Rate-limit response headers.</li><li>Configurable Redis failure behavior.</li><li>Health checks and deployment-oriented features.</li></ul><p>The library also provides a standalone interface for applications that need rate limiting without relying directly on its framework integrations.</p><h3>The design philosophy</h3><p>RateForge follows three practical principles.</p><p><strong>Keep integration simple.</strong></p><p>A developer should be able to protect an endpoint without rewriting its business logic.</p><p><strong>Keep enforcement centralized.</strong></p><p>Multiple application instances should be able to consult a shared rate-limiting backend instead of maintaining unrelated local counters.</p><p><strong>Make operational behavior configurable.</strong></p><p>Production applications need control over failure handling, health monitoring, and the way different clients are identified.</p><p>These principles make RateForge useful as a reusable component rather than a collection of endpoint-specific workarounds.</p><h3>4. Why Redis?</h3><p>Redis is a natural fit for distributed rate limiting because it provides fast data access, atomic operations, expiration mechanisms, and scripting capabilities.</p><p>RateForge uses Redis as its shared rate-limiting backend.</p><p>Consider an application running four instances:</p><ul><li>Application instance A</li><li>Application instance B</li><li>Application instance C</li><li>Application instance D</li></ul><p>All four instances communicate with the same Redis-backed rate-limiting system.</p><p>When a request arrives at any instance, the rate limiter evaluates the applicable policy against the shared state.</p><p>This allows the application to enforce limits across instances rather than treating each server as an isolated system.</p><h3>Benefits of using Redis</h3><p><strong>1. Shared state</strong></p><p>Request counts aren’t limited to the memory of a single application process.</p><p><strong>2. Fast operations</strong></p><p>Redis is designed for low-latency data access, making it suitable for operations that need to happen during request processing.</p><p>Actual latency depends on deployment topology, network conditions, Redis configuration, and workload.</p><p><strong>3. Atomic execution</strong></p><p>Redis supports Lua scripting, which can combine related operations into a single server-side execution.</p><p>This is useful when a rate-limiting decision requires reading state, evaluating a condition, and updating state without allowing competing requests to interfere with that sequence.</p><p><strong>4. Automatic expiration</strong></p><p>Time-based rate-limiting data shouldn’t remain in storage indefinitely.</p><p>Redis expiration mechanisms help remove temporary state when it is no longer needed.</p><p><strong>5. Distributed enforcement</strong></p><p>Multiple application workers can use the same Redis-backed state, making it easier to apply consistent request limits across a horizontally scaled deployment.</p><p>Redis doesn’t eliminate every distributed-systems challenge. Network failures, deployment configuration, storage availability, and consistency requirements still matter.</p><p>However, it provides a practical foundation for building distributed rate limiters.</p><h3>5. Understanding the Sliding-Window Algorithm</h3><p>One of the central concepts behind RateForge is sliding-window rate limiting.</p><p>To understand why it matters, consider a simpler alternative: the fixed-window algorithm.</p><h3>The problem with fixed windows</h3><p>Suppose an endpoint permits 100 requests per minute.</p><p>A fixed-window implementation divides time into discrete one-minute intervals.</p><p>For example:</p><ul><li>Window 1: 10:00:00–10:00:59</li><li>Window 2: 10:01:00–10:01:59</li></ul><p>The client can make 100 requests near the end of the first window and another 100 immediately after the second window begins.</p><p>As a result, the client could send nearly 200 requests within a short period around the boundary.</p><p>The configured limit is still being enforced per window, but traffic can arrive in an unexpectedly large burst.</p><h3>How a sliding window works</h3><p>A sliding window evaluates requests within a rolling period rather than relying exclusively on fixed calendar boundaries.</p><p>For a limit of 100 requests per minute, the system evaluates how many requests fall within the relevant 60-second interval.</p><p>As time advances, older requests leave the window and new requests enter it.</p><p>Conceptually:</p><pre>Maximum requests: 100<br>Time window:      60 seconds</pre><pre>Request timeline:</pre><pre>10:00:00  ───────────────────────── 10:01:00<br>          &lt;---- Rolling 60 seconds ----&gt;</pre><pre>Only requests within the applicable<br>rolling window contribute to the decision.</pre><p>The exact implementation depends on the sliding-window variant.</p><p>A sliding-window log can track individual request timestamps, while a sliding-window counter can estimate rolling traffic using adjacent time buckets.</p><p>These approaches have different memory and accuracy trade-offs.</p><h3>Why sliding windows are useful</h3><p>They can provide smoother enforcement around time boundaries and make request limits more representative of recent traffic.</p><p>This is especially useful for public APIs and multi-tenant applications where sudden bursts can affect shared resources.</p><p>The trade-off is that sliding-window implementations may require more sophisticated state management than a basic fixed-window counter.</p><p>RateForge brings this approach into a reusable Python library.</p><h3>6. How RateForge Fits Into an API Request</h3><p>A rate limiter is most useful when it integrates naturally with the request lifecycle.</p><p>A simplified RateForge request flow looks like this:</p><pre>Incoming API Request<br>                          |<br>                          v<br>                Django / FastAPI<br>                          |<br>                          v<br>                 RateForge Integration<br>                          |<br>                          v<br>                 Identify the Client<br>                          |<br>                          v<br>                 Evaluate the Policy<br>                          |<br>                          v<br>                    Redis Backend<br>                          |<br>                          v<br>                  Rate-Limit Decision<br>                     /          \<br>                    /            \<br>                Allowed         Rejected<br>                   |               |<br>                   v               v<br>             Execute View      HTTP 429<br>                   |               |<br>                   v               v<br>             Return Result    Retry Information</pre><p>This diagram describes the conceptual flow. The exact execution path depends on the framework integration and configuration.</p><h3>Step 1: Identify the client</h3><p>The system determines which identity the policy applies to.</p><p>Depending on the configuration, this might be:</p><ul><li>A client IP address.</li><li>An authenticated user.</li><li>An API key.</li><li>A custom identity, such as a tenant or organization ID.</li></ul><h3>Step 2: Determine the applicable policy</h3><p>The endpoint’s configuration defines how many requests are allowed and over what period.</p><p>For example:</p><pre>&quot;100/minute&quot;</pre><p>This represents a policy allowing up to 100 requests per minute.</p><h3>Step 3: Evaluate the rate limit</h3><p>RateForge evaluates the request against the applicable state maintained through Redis.</p><p>If the request is allowed, normal processing continues.</p><p>If the limit has been exceeded, the request is rejected.</p><h3>Step 4: Return the appropriate response</h3><p>An allowed request proceeds to the endpoint.</p><p>A rejected request receives an HTTP 429 response, potentially accompanied by rate-limit metadata and retry information.</p><p>The result is a reusable request-control layer that can operate without embedding rate-limiting logic directly into the application’s business functions.</p><h3>7. Integrating RateForge With Django</h3><p>Django remains a popular choice for building Python web applications, REST APIs, and SaaS platforms.</p><p>RateForge provides Django integration through decorators and middleware.</p><h3>Installation</h3><p>Install the package:</p><pre>pip install rateforge</pre><p>Configure the Redis connection:</p><pre>export RATEFORGE_REDIS_URL=&quot;redis://localhost:6379/0&quot;</pre><p>This example assumes Redis is available at the configured address.</p><h3>Example 1: Protect a Django view</h3><p>Consider a public endpoint that returns information about your application.</p><p>Without rate limiting, clients could repeatedly call the endpoint without a request-frequency restriction.</p><p>With RateForge, you can apply a limit using a decorator:</p><pre>from django.http import JsonResponse<br>from rateforge.django import rate_limit<br></pre><pre>@rate_limit(&quot;100/minute&quot;)<br>def public_api(request):<br>    return JsonResponse({<br>        &quot;message&quot;: &quot;Welcome to the API&quot;<br>    })</pre><p>The decorator applies a limit of 100 requests per minute using the integration’s default identity behavior.</p><p>This keeps the rate-limiting policy separate from the endpoint’s primary responsibility.</p><h3>Example 2: Apply a stricter limit to a sensitive endpoint</h3><p>Some operations are more expensive or sensitive than others.</p><p>For example, an endpoint that creates an order may require a stricter policy than an endpoint that retrieves public information.</p><pre>from django.http import JsonResponse<br>from rateforge.django import rate_limit<br></pre><pre>@rate_limit(&quot;10/minute&quot;, identity=&quot;user&quot;)<br>def create_order(request):<br>    return JsonResponse({<br>        &quot;message&quot;: &quot;Order endpoint&quot;<br>    })</pre><p>Here, the policy is configured to use user-based identity.</p><p>The application should ensure that the endpoint’s authentication requirements are enforced appropriately. Rate limiting isn’t a replacement for authentication or authorization.</p><h3>Example 3: Apply rate limiting through middleware</h3><p>Decorators are useful when individual endpoints require different policies.</p><p>Middleware can be a better fit when you want a default rate-limiting policy across a broader set of Django requests.</p><p>For example:</p><pre>MIDDLEWARE = [<br>    # Other Django middleware...<br>    &quot;rateforge.django.RateLimitMiddleware&quot;,<br>]</pre><p>You can then configure the default behavior:</p><pre>RATEFORGE_CONFIG = {<br>    &quot;default_rate&quot;: &quot;100/minute&quot;,<br>    &quot;identity&quot;: &quot;ip&quot;,<br>}</pre><p>The exact behavior depends on the library’s configuration and middleware implementation.</p><h3>Why this integration matters</h3><p>Developers shouldn’t need to modify every view to implement the mechanics of request counting.</p><p>By providing decorators and middleware, RateForge offers two familiar ways to integrate rate limiting into Django applications.</p><h3>8. Integrating RateForge With FastAPI</h3><p>FastAPI is widely used for building modern Python APIs, particularly services that benefit from asynchronous request handling and type-driven development.</p><p>RateForge provides integration through decorators and dependency injection.</p><h3>Example 1: Protect an endpoint with a decorator</h3><pre>from fastapi import FastAPI<br>from rateforge.fastapi import rate_limit</pre><pre>app = FastAPI()<br></pre><pre>@app.get(&quot;/users&quot;)<br>@rate_limit(&quot;100/minute&quot;)<br>async def get_users():<br>    return {<br>        &quot;users&quot;: []<br>    }</pre><p>This example applies a limit of 100 requests per minute to the endpoint.</p><p>The endpoint’s business logic remains focused on returning user data.</p><h3>Example 2: Use dependency injection</h3><p>FastAPI’s dependency system provides another way to apply shared behavior.</p><p>RateForge exposes a rate-limit dependency that can be registered on a route.</p><pre>from fastapi import Depends, FastAPI<br>from rateforge.fastapi import rate_limit_dependency</pre><pre>app = FastAPI()<br></pre><pre>@app.get(<br>    &quot;/premium&quot;,<br>    dependencies=[<br>        Depends(<br>            rate_limit_dependency(&quot;1000/hour&quot;)<br>        )<br>    ],<br>)<br>async def premium_endpoint():<br>    return {<br>        &quot;message&quot;: &quot;Premium API&quot;<br>    }</pre><p>This configures an example policy of 1,000 requests per hour.</p><p>Dependency injection can be useful when a policy needs to be applied declaratively without adding rate-limiting code to the endpoint function itself.</p><h3>Example 3: Apply a global policy</h3><p>A broader policy can be registered at the application level:</p><pre>from fastapi import FastAPI<br>from rateforge.fastapi import rate_limit_dependency</pre><pre>app = FastAPI()</pre><pre>app.add_dependency(<br>    rate_limit_dependency(&quot;100/minute&quot;)<br>)</pre><p>A global policy can provide a default level of protection, while individual routes may require more restrictive limits.</p><p>Before deploying global policies, verify how the framework integration combines them with endpoint-specific rules.</p><h3>Why supporting both frameworks matters</h3><p>Python applications don’t all use the same framework.</p><p>Some organizations use Django for their main application and FastAPI for specialized services.</p><p>Others use FastAPI exclusively.</p><p>By supporting both frameworks, RateForge provides a consistent approach to rate limiting across different Python application architectures.</p><h3>9. Rate Limiting by IP, User, API Key, or Tenant</h3><p>One request limit rarely makes sense for every client.</p><p>A public website, an authenticated user, and a premium API customer may all require different policies.</p><p>RateForge supports multiple identity strategies.</p><h3>IP-based rate limiting</h3><p>IP-based limiting groups requests by client IP address.</p><p>It can be useful for protecting public endpoints where users aren’t authenticated.</p><p>However, IP addresses aren’t always reliable representations of individual users.</p><p>Multiple legitimate users may share an address through NAT, while a client may use multiple addresses.</p><p>Applications behind reverse proxies must also configure trusted proxy handling carefully. Blindly trusting forwarded IP headers can allow clients to manipulate their apparent identity.</p><h3>User-based rate limiting</h3><p>User-based policies associate requests with authenticated application users.</p><p>For example:</p><pre>@rate_limit(&quot;10/minute&quot;, identity=&quot;user&quot;)</pre><p>This approach is useful when users have individual quotas.</p><p>It requires a valid authenticated identity to be available to the integration.</p><h3>API-key-based rate limiting</h3><p>External developers and services often access APIs using API keys.</p><p>An API-key policy allows request limits to be associated with those credentials.</p><p>This can be useful for integrations, partner APIs, and developer platforms.</p><p>API keys should be handled securely and should never be logged or exposed unnecessarily.</p><h3>Custom identity extraction</h3><p>Some applications need limits based on an organization, tenant, device, or another business-specific identifier.</p><p>RateForge supports custom identity extraction, allowing policies to be associated with application-specific identities.</p><p>For example, a multi-tenant SaaS platform might want to limit each organization independently rather than applying a single quota to all its users.</p><p>This makes the library adaptable to different application architectures.</p><h3>10. Rate Limiting for Multi-Tenant SaaS Applications</h3><p>Multi-tenancy introduces an important resource-management challenge.</p><p>Imagine a SaaS platform serving three organizations:</p><ul><li>Organization A has a basic subscription.</li><li>Organization B has a professional subscription.</li><li>Organization C has an enterprise subscription.</li></ul><p>Each organization uses the same API infrastructure, but their subscription plans may include different usage allowances.</p><p>A rate limiter can help enforce those boundaries.</p><p>For example:</p><p>SubscriptionIllustrative policyBasic100 requests per minuteProfessional500 requests per minuteEnterprise2,000 requests per minute</p><p>These values are examples rather than recommended defaults.</p><p>A production implementation would need to determine the correct policy for each organization and ensure the relevant subscription information is trusted and current.</p><p>The application could then associate requests with a tenant identity and apply the corresponding limit.</p><h3>Why tenant-aware limiting matters</h3><p><strong>Fairness:</strong> One organization is less likely to consume the entire shared request budget.</p><p><strong>Predictability:</strong> Customers can understand the usage boundaries associated with their plans.</p><p><strong>Cost control:</strong> Expensive operations can be restricted according to business rules.</p><p><strong>Scalability:</strong> A shared rate-limiting backend allows multiple application instances to enforce common policies.</p><p>RateForge provides identity and policy mechanisms that can support these use cases, although the application’s subscription-management and billing logic remain separate responsibilities.</p><h3>11. Handling Redis Failures: Fail-Open vs. Fail-Closed</h3><p>A rate limiter introduces a dependency into the API request path.</p><p>If Redis becomes unavailable, the application may no longer be able to evaluate rate limits normally.</p><p>This creates an important design decision.</p><p>Should the application allow requests to continue, or should it reject requests that cannot be checked?</p><p>Two common strategies address this problem.</p><h3>Fail-open</h3><p>In fail-open mode, the application allows requests to proceed when the rate-limiting backend is unavailable.</p><p>Advantages:</p><ul><li>Reduces the risk of rate-limiter outages blocking legitimate traffic.</li><li>Can improve availability for applications where rate limiting is a secondary protection.</li><li>Helps prevent a Redis outage from automatically becoming an application-wide outage.</li></ul><p>Disadvantages:</p><ul><li>Rate limits may not be enforced while Redis is unavailable.</li><li>Excessive traffic may reach the application or its downstream dependencies.</li><li>An outage may expose expensive endpoints to greater resource consumption.</li></ul><h3>Fail-closed</h3><p>In fail-closed mode, requests are rejected when the rate limiter cannot verify whether they are allowed.</p><p>Advantages:</p><ul><li>Preserves a stricter enforcement posture.</li><li>Can be appropriate when uncontrolled access creates significant security or financial risk.</li></ul><p>Disadvantages:</p><ul><li>A Redis outage can make otherwise healthy endpoints unavailable.</li><li>Legitimate users may be blocked because the application cannot evaluate the policy.</li></ul><h3>Which strategy is better?</h3><p>There isn’t one universally correct answer.</p><p>A public content endpoint may prioritize availability, while a sensitive operation may require stricter controls.</p><p>The appropriate policy depends on the endpoint, threat model, downstream costs, and business requirements.</p><p>RateForge supports configurable failure behavior, allowing developers to make this decision according to their application’s needs.</p><p>However, fail-open and fail-closed behavior should be tested explicitly. Developers should also consider connection timeouts, Redis health, monitoring, and what happens during partial failures.</p><h3>12. HTTP 429 Responses and Rate-Limit Headers</h3><p>Rejecting a request is only part of the rate-limiting experience.</p><p>Clients also need to understand what happened and when they can try again.</p><p>HTTP 429 Too Many Requests is the standard response status for indicating that a client has exceeded a request limit.</p><p>A response might conceptually look like this:</p><pre>HTTP/1.1 429 Too Many Requests<br>Content-Type: application/json<br>Retry-After: 30</pre><p>The response body could contain:</p><pre>{<br>  &quot;error&quot;: &quot;rate_limit_exceeded&quot;,<br>  &quot;message&quot;: &quot;Too many requests&quot;,<br>  &quot;retry_after&quot;: 30<br>}</pre><p>This is an illustrative response, not a guarantee of RateForge’s exact default response format.</p><h3>Why retry information matters</h3><p>Without retry information, a client may immediately repeat a rejected request, generating additional unnecessary traffic.</p><p>A retry interval allows clients to wait before trying again.</p><p>Rate-limit metadata can also help API consumers manage their request budgets more intelligently.</p><p>Depending on the implementation, useful headers may include:</p><ul><li>The configured request limit.</li><li>The remaining request allowance.</li><li>The time when the limit resets.</li><li>The suggested retry interval.</li></ul><p>RateForge provides rate-limit header functionality and automatic handling for exceeded limits.</p><p>For production APIs, these details should be documented so client developers know how to handle throttling responses.</p><h3>13. Health Checks and Production Readiness</h3><p>A library that works locally isn’t automatically ready for production.</p><p>Production systems need visibility into their dependencies and the ability to determine whether their components are functioning correctly.</p><p>RateForge includes health-check functionality intended to help monitor application and environment health.</p><p>Its documented checks include:</p><p><strong>Redis connectivity:</strong> Determines whether the rate-limiting backend is reachable and can report latency information.</p><p><strong>Filesystem:</strong> Checks relevant filesystem access and write permissions.</p><p><strong>Memory:</strong> Reports memory-related information when the optional monitoring dependency is available.</p><p><strong>Configuration:</strong> Validates relevant configuration.</p><p><strong>Database:</strong> Provides a database-related health-check entry, with the exact behavior depending on the implementation.</p><p>These checks help developers identify operational problems before they become difficult to diagnose.</p><h3>Health checks in containerized deployments</h3><p>Applications running in Docker or Kubernetes often need endpoints or mechanisms that indicate whether a process is healthy and ready to serve traffic.</p><p>Health checks can support those workflows.</p><p>However, liveness and readiness should not be treated as interchangeable.</p><ul><li><strong>Liveness</strong> determines whether a process should be restarted.</li><li><strong>Readiness</strong> determines whether a process should receive traffic.</li></ul><p>For example, a temporary dependency failure might make an application unready without necessarily requiring the process to restart.</p><p>Health-check design should reflect these distinctions.</p><p>RateForge’s health-check capabilities provide building blocks for operational monitoring, while the final deployment configuration depends on the application and its infrastructure.</p><h3>14. Testing a Rate Limiter Properly</h3><p>Rate limiting looks simple until edge cases appear.</p><p>A reliable implementation should be tested beyond the basic scenario of allowing a few requests and rejecting the next one.</p><p>Here are several important test cases.</p><h3>Test 1: Requests below the limit</h3><p>Given a policy allowing five requests within a window, the first five requests should be accepted when the window starts with no prior usage.</p><h3>Test 2: Requests above the limit</h3><p>The sixth request should be rejected if no earlier requests have expired from the applicable window.</p><h3>Test 3: Window expiration</h3><p>After enough time has passed, previously counted requests should stop contributing to the active window according to the selected algorithm.</p><h3>Test 4: Client isolation</h3><p>Requests associated with one identity should not accidentally consume another identity’s allowance when the policies are meant to be independent.</p><h3>Test 5: Endpoint isolation</h3><p>If policies are scoped by endpoint, requests to one endpoint should not unintentionally consume another endpoint’s quota.</p><h3>Test 6: Concurrent requests</h3><p>Simultaneous requests should not bypass the configured limit because of race conditions.</p><p>This is especially important when the library is intended for applications with multiple workers.</p><h3>Test 7: Redis unavailability</h3><p>The library should behave according to its configured failure strategy when Redis is unreachable.</p><p>Tests should verify both fail-open and fail-closed behavior where applicable.</p><h3>Test 8: Framework integration</h3><p>Django and FastAPI integrations should be tested independently to verify that decorators, middleware, dependencies, and error responses behave correctly.</p><h3>Test 9: Identity extraction</h3><p>Tests should cover IP-based identities, authenticated users, API keys, and custom extractors.</p><h3>Test 10: Cleanup and expiration</h3><p>Temporary rate-limiting state should be managed correctly so storage doesn’t accumulate unnecessary data indefinitely.</p><p>A strong test suite is particularly important for rate limiters because subtle concurrency or timing errors can undermine the entire protection mechanism.</p><h3>15. Running RateForge in a Containerized Environment</h3><p>Redis-backed rate limiting becomes particularly useful when an application runs across multiple containers or server instances.</p><p>A typical deployment might include:</p><pre>Load Balancer<br>                         |<br>             +-----------+-----------+<br>             |           |           |<br>             v           v           v<br>         API App 1   API App 2   API App 3<br>             |           |           |<br>             +-----------+-----------+<br>                         |<br>                         v<br>                       Redis</pre><p>Each application instance uses the shared Redis backend to evaluate rate limits.</p><p>This allows the deployment to scale application instances without maintaining a separate, independent rate-limit counter for each one.</p><h3>Important deployment considerations</h3><p><strong>Redis availability:</strong> Redis becomes part of the request-processing path, so its availability and latency matter.</p><p><strong>Connection management:</strong> Applications should use appropriate connection handling rather than creating unnecessary connections for individual requests.</p><p><strong>Network security:</strong> Redis should not be exposed publicly without appropriate security controls.</p><p><strong>Timeouts:</strong> Backend timeouts should be configured to avoid allowing stalled rate-limit checks to consume excessive request-processing time.</p><p><strong>Monitoring:</strong> Redis errors, request rejection rates, latency, and application health should be monitored.</p><p><strong>Scaling:</strong> A single Redis deployment may eventually become a bottleneck depending on the workload. Capacity planning and architecture should reflect actual traffic.</p><p><strong>Failure behavior:</strong> The application’s response to Redis failures should be intentional and documented.</p><p>RateForge provides components for this architecture, but overall deployment reliability still depends on how the application and infrastructure are configured.</p><h3>16. RateForge vs. Building Your Own Rate Limiter</h3><p>Should developers build rate limiting themselves or use a reusable library?</p><p>The answer depends on the complexity of the application and its requirements.</p><p>ConsiderationCustom implementationRateForgeInitial flexibilityComplete controlUses the library’s supported interfacesFramework integrationMust be implementedDjango and FastAPI integrations providedRedis coordinationMust be implementedRedis-backed functionality providedIdentity strategiesMust be implementedSupports common and custom identitiesFailure handlingMust be designedConfigurable behavior providedMaintenanceOwned by the application teamShared library code can be maintained centrallySpecialized requirementsUnlimited design freedomMay require customization or another solution</p><p>A custom implementation can be appropriate when an application has unusual requirements or needs complete control over its enforcement logic.</p><p>A reusable library can be preferable when developers want common functionality without maintaining a separate implementation for every project.</p><p>RateForge is designed for the latter use case: making Redis-backed rate limiting accessible through familiar Python framework interfaces.</p><p>It isn’t intended to replace every API gateway or enterprise traffic-management platform.</p><p>Organizations with complex routing policies, centralized governance requirements, or advanced traffic-shaping needs may still benefit from dedicated gateway infrastructure.</p><h3>17. Who Should Use RateForge?</h3><p>RateForge may be useful for several categories of Python projects.</p><h3>Backend developers</h3><p>Developers building REST APIs can use rate limiting to control request frequency without writing all the underlying infrastructure themselves.</p><h3>SaaS founders</h3><p>Multi-tenant applications often need to establish usage limits for customers and protect shared resources.</p><h3>Django developers</h3><p>Teams building Django applications can use the provided integration to apply policies at the view or middleware level.</p><h3>FastAPI developers</h3><p>Teams building modern Python APIs can integrate rate limiting through decorators or dependency injection.</p><h3>Developers building public APIs</h3><p>Public endpoints may need protection against excessive requests, accidental traffic spikes, and abusive clients.</p><h3>Teams running distributed applications</h3><p>Applications with multiple workers or instances can benefit from shared Redis-backed enforcement instead of relying exclusively on local counters.</p><p>The best fit is a Python application that needs reusable rate limiting but doesn’t require the full complexity of a dedicated API management platform.</p><h3>18. What Makes a Rate Limiter Production-Ready?</h3><p>A rate limiter should do more than reject the occasional request.</p><p>It needs to behave predictably under normal traffic, concurrent requests, backend failures, and changing workloads.</p><p>Several engineering considerations are especially important.</p><h3>Correctness</h3><p>The configured policy should be enforced consistently, including when multiple requests arrive simultaneously.</p><h3>Predictable failure behavior</h3><p>Developers should understand what happens when Redis becomes unavailable.</p><h3>Identity security</h3><p>Rate limits must be associated with trustworthy client identities. Incorrect proxy configuration or spoofable identity information can undermine enforcement.</p><h3>Resource management</h3><p>Temporary state should be cleaned up appropriately, and the backend should be sized for the expected workload.</p><h3>Observability</h3><p>Developers should be able to identify unusual rejection rates, backend errors, and latency problems.</p><h3>Clear integration</h3><p>The library should be easy to integrate without forcing application developers to rewrite their business logic.</p><h3>Comprehensive testing</h3><p>Time boundaries, concurrency, identity isolation, framework behavior, and backend failures all require appropriate coverage.</p><p>RateForge brings several of these concerns into one reusable library, including Redis-backed enforcement, framework integrations, configurable failure behavior, and health checks.</p><p>As with any production dependency, teams should validate the implementation against their specific traffic patterns, reliability requirements, and security model before relying on it for critical workloads.</p><h3>19. The Engineering Lessons Behind RateForge</h3><p>Building a rate limiter is a useful exercise in backend engineering because it connects several important concepts.</p><p><strong>Distributed state management</strong></p><p>A rate limiter must coordinate decisions across application instances rather than relying exclusively on process-local memory.</p><p><strong>Concurrency and atomicity</strong></p><p>The difference between a correct and incorrect rate limiter may depend on whether a check-and-update sequence is executed atomically.</p><p><strong>Algorithm selection</strong></p><p>Fixed windows, sliding windows, and token buckets offer different trade-offs in accuracy, memory consumption, and burst handling.</p><p><strong>Framework integration</strong></p><p>A reusable backend component becomes more valuable when it fits naturally into the frameworks developers already use.</p><p><strong>Failure-mode design</strong></p><p>A dependency can fail independently of the application. Designing appropriate behavior for those failures is part of building reliable systems.</p><p><strong>Testing beyond the happy path</strong></p><p>Concurrency, timing, backend failures, and identity isolation often reveal bugs that basic unit tests miss.</p><p>These concepts extend beyond rate limiting. They are relevant to caching, distributed locks, job queues, authentication systems, quotas, and other backend infrastructure.</p><p>RateForge is therefore not just a request-throttling utility. It is also an example of how a focused backend component can bring together algorithms, distributed storage, framework integration, and operational considerations.</p><h3>20. What’s Next for RateForge?</h3><p>Rate limiting is only one part of building reliable APIs.</p><p>There are several directions in which a library like RateForge could evolve.</p><h3>More flexible policies</h3><p>Applications may need to combine user-level limits, endpoint-specific rules, subscription tiers, and organization-wide quotas.</p><p>A policy system that supports these requirements can make the library more useful for complex SaaS applications.</p><h3>Improved observability</h3><p>Metrics for allowed requests, rejected requests, Redis latency, and backend failures could help teams understand how their rate limits behave under real traffic.</p><h3>Better operational tooling</h3><p>More detailed health information, deployment examples, and troubleshooting guidance can make production adoption easier.</p><h3>Expanded testing and compatibility</h3><p>Testing across supported Python versions, framework releases, Redis configurations, and deployment environments can help reduce integration surprises.</p><h3>Performance benchmarking</h3><p>Benchmarks under realistic concurrency and traffic patterns would help developers understand the performance characteristics of the implementation.</p><p>These are potential areas for future development, not claims that every capability is already implemented.</p><p>The right priorities should be determined by real usage, user feedback, and measurable engineering needs.</p><h3>Conclusion: Making API Rate Limiting Easier for Python Developers</h3><p>Rate limiting is a fundamental part of protecting modern APIs.</p><p>It helps control excessive traffic, establish usage boundaries, reduce the impact of abusive clients, and protect shared application resources.</p><p>However, implementing it reliably requires more than a simple counter.</p><p>Distributed applications need shared state, correct concurrency handling, appropriate algorithms, clear failure policies, and integrations that fit their existing architecture.</p><p><strong>RateForge brings these concerns together in a Redis-backed Python library with Django and FastAPI support.</strong></p><p>By providing reusable interfaces, multiple identity strategies, configurable failure behavior, rate-limit responses, and health-check functionality, it aims to reduce the amount of infrastructure code developers need to maintain themselves.</p><p>For developers building Python APIs, the broader lesson is straightforward:</p><p>Don’t treat rate limiting as an afterthought. Design it as part of your application’s resource-management strategy.</p><p>And when the underlying engineering is available as a reusable component, you can spend less time rebuilding common infrastructure and more time developing the features that make your application valuable.</p><p><strong>RateForge: Forge better limits. Build more resilient APIs.</strong></p><h3>Project Resources</h3><ul><li><strong>PyPI:</strong> Search for rateforge on the Python Package Index.</li><li><strong>Frameworks:</strong> Django and FastAPI.</li><li><strong>Storage backend:</strong> Redis.</li><li><strong>Core algorithm:</strong> Sliding-window rate limiting.</li><li><strong>Use cases:</strong> Public APIs, SaaS applications, multi-tenant systems, and distributed Python services.</li><li><strong>Open Source Github: </strong><a href="https://github.com/TencerDe/rateforge">https://github.com/TencerDe/rateforge</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35fd118bb276" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Consistency Changed Everything for Me]]></title>
            <link>https://tsharma2907.medium.com/consistency-changed-everything-for-me-0783971290ee?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/0783971290ee</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[motivation]]></category>
            <category><![CDATA[consistency]]></category>
            <category><![CDATA[self-help]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Sat, 20 Dec 2025 17:27:07 GMT</pubDate>
            <atom:updated>2025-12-20T17:27:07.947Z</atom:updated>
            <content:encoded><![CDATA[<p>Since childhood, I was a chronic procrastinator.<br>Not just with studies even playing outside in the evening felt like a task I’d postpone. Back then, social media wasn’t a thing, but TV was more than enough to distract me.</p><p>That habit followed me everywhere.</p><p>In school, I skipped studying.<br> In college, I skipped building skills.<br> And slowly, regret started piling up.</p><p>I watched my classmates improve academically, professionally, personally while I kept starting new things, getting decent at them, and then quitting. Over time, I became <em>okay</em> at many things: graphic designing, video editing, article writing, content creation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fBhGUPG0GKlTOvs9_yyTFg.png" /></figure><p>But the one skill I had always dreamed of mastering <strong>coding </strong>was missing.</p><p>Why?<br> Because coding demands patience. Discipline. Long periods of doing boring, confusing work with no instant reward. And I always saw it as a “big task,” something I’d <em>start tomorrow</em>.</p><p>Even during my higher studies, the environment didn’t help. Most people around me had no clarity about why they were even there. That made skipping effort feel normal again.</p><p>Then one day, I checked an old classmate’s LinkedIn profile.<br> He was doing <em>significantly</em> better.</p><p>When I asked him how, he gave me a one-word answer:</p><p><strong>Consistency.</strong></p><p>That word stayed with me.</p><p>I started digging deeper and realized something important:<br> Consistency isn’t about motivation.<br> It’s not about feeling excited every day.</p><p><strong>Consistency is about showing up even when you don’t feel like it.</strong></p><p>It’s about fighting your brain when it wants comfort.<br> Fighting your heart when it wants to quit.<br> Doing the same boring, repetitive tasks daily for weeks and months.</p><p>That’s when things changed.</p><p>At the beginning of 2025, I made a decision:<br> No shortcuts. No waiting for motivation.</p><p>I showed up for the gym.<br> I showed up for coding.<br> I showed up for learning every single day.</p><p>Seven months later:</p><ul><li>I gained over <strong>8 kg</strong> of body weight (I was underweight).</li><li>I went from being a complete novice to understanding core tech concepts.</li><li>I became consistent with writing and publishing again — after almost a year of inconsistency.</li></ul><p>The results didn’t come overnight.<br> Most days felt ordinary. Some days felt pointless.</p><p>But consistency compounds.</p><p>Slowly, quietly, it changes who you are.</p><p>So yes <strong>consistency really matters</strong>.<br> You may not see results immediately, but if you stay focused long enough, you’ll discover your real potential — the version of you that discipline unlocks.</p><p>And if someone like me once stuck, distracted, and inconsistent — can do this…</p><p><strong>Trust me, anyone can.</strong></p><p><strong>Regards,</strong><br> <strong>Tanuj Sharma</strong><br> <em>Once a failure, now a learner</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0783971290ee" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to add Google sign-in to your Django app?]]></title>
            <link>https://tsharma2907.medium.com/how-to-add-google-sign-in-to-your-django-app-3c3ad1113446?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c3ad1113446</guid>
            <category><![CDATA[pytho]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[login]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Thu, 02 Jan 2025 07:38:19 GMT</pubDate>
            <atom:updated>2025-01-02T07:38:19.260Z</atom:updated>
            <content:encoded><![CDATA[<p>All the guides I’ve seen about adding Google Sign to Django make it overly complicated (e.g., Django-allauth or Django-social-auth).</p><p>We’ll add Google sign in the simplest way by:</p><ol><li>Rendering an HTML page with a Google script tag that adds a sign-in button. When clicked, the user will see a Google sign-in pop up.</li><li>After sign in, Google will redirect the user (with a POST) to a specified page on our site.</li><li>We’ll get the user’s Google information (e.g., email) from the POST request.</li></ol><p>Let’s get started 🚀</p><h3>0. Setup our Django app</h3><ul><li>Install packages and create our Django app</li></ul><pre>pip install django python-dotenv google-api-python-client<br>django-admin startproject core .<br>python manage.py startapp sim</pre><ul><li>Add our app sim to the INSTALLED_APPS in settings.py:</li></ul><pre># settings.py<br>INSTALLED_APPS = [<br>    &#39;sim&#39;,<br>    ...<br>]</pre><h3>1. Create our Google sign in consent screen and OAuth client ID</h3><p>This might be foreign to you, but it’s quick to do (despite Google Cloud Platform’s confusing documentation).</p><h3>a. Create a project</h3><ul><li>Open the Credentials page of the <a href="https://console.developers.google.com/apis">Google APIs console</a></li><li>Create a Google APIs project.</li><li>Select your project. This is a gotcha: you need to select your project after you create it.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*NNNI_svEwtLZuyIbKkyR3g.png" /></figure><h3>b. Configure the OAuth consent screen</h3><ul><li>Click Credentials &gt; Create credentials &gt; OAuth client ID.</li><li>Click Configure the consent screen &gt; External &gt; Create. Complete the form (I added example.com as the Authorized domain).(<strong>Note on deploying to production</strong>: for this to work in production, you will need to add your production URL to the Authorized domains in the future).</li><li>Add scopes. This determines what information users may give your (I clicked userinfo.email) &gt; Update &gt; Save and Continue.</li><li>Add Test users (I added my email. These need to be Google users) &gt; Add &gt; Save and Continue.</li><li>Click Back to Dashboard</li></ul><h3>c. Create an OAuth client ID</h3><ul><li>Click Credentials &gt; Create credentials &gt; OAuth client ID &gt; Web application (Don’t click create yet).</li></ul><h4>Add your authorized Javascript origins</h4><p>For our local development, we add both http://localhost and http://localhost:8000 to Authorized JavaScript origins.</p><p>Substitute the port number with the port number you use for your local development server.</p><p><strong>Note on deploying to production</strong>: When deploying to production, you’ll need to add the URI of your website to Authorized JavaScript origins. The URI includes the scheme and fully qualified hostname only. For example, <a href="https://www.example.com.)/">https://www.example.com.)</a> If you don’t do this, Google will return an error when you try to sign in.</p><h4>Add your Authorized redirect URIs</h4><ul><li>Add http://localhost:8000/auth-receiver to Authorized redirect URIs.</li></ul><p>This is the URL to which Google will send credentials and redirect the user after they have authenticated. Substitute the port number with the port number you use for your local development server.Substitute the port number with the port number you use for your local development server.</p><ul><li>Click create</li><li>Copy the Client ID and Client Secret.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/492/1*Z6fO9gJNccC_OsidwLOd8A.jpeg" /></figure><h3>d. Add the Client ID to our Django app</h3><ul><li>Create a file called .env at core/.env and add the below to it. We&#39;ll use this to store our environment variables, which we won&#39;t commit to version control.</li></ul><pre>GOOGLE_OAUTH_CLIENT_ID=&lt;your_client_id&gt;</pre><ul><li>Update the top of your core/settings.py to look like the below. This loads the environment variables from the .env file when the server restarts. We also add a check to ensure that the GOOGLE_OAUTH_CLIENT_ID environment variable is set, and add settings to allow the Google sign in popup.</li></ul><pre>import os<br>from dotenv import load_dotenv<br>from pathlib import Path<br></pre><pre>load_dotenv()<br></pre><pre>GOOGLE_OAUTH_CLIENT_ID = os.environ.get(&#39;GOOGLE_OAUTH_CLIENT_ID&#39;)<br>if not GOOGLE_OAUTH_CLIENT_ID:<br>    raise ValueError(<br>        &#39;GOOGLE_OAUTH_CLIENT_ID is missing.&#39; <br>        &#39;Have you put it in a file at core/.env ?&#39;<br>    )</pre><pre># We need these lines below to allow the Google sign in popup to work.<br>SECURE_REFERRER_POLICY = &#39;no-referrer-when-downgrade&#39;<br>SECURE_CROSS_ORIGIN_OPENER_POLICY = &quot;same-origin-allow-popups&quot;</pre><h3>3. Create your Google sign in flow</h3><h3>How your Google sign in flow will work</h3><p>Our sign in flow is simple and effective. We’ll:</p><ol><li>render an HTML page, containing a script tag from Google that runs when the user visits the page and adds the Google sign in button</li><li>after the user signs in on Google, Google will then redirect the user to a url on our site (‘auth-reciever’) with a POST request containing a token.</li><li>we’ll check that the token is valid and get the user’s information from it</li></ol><p>So, let’s create this.</p><h3>a. Create a sign in page</h3><ul><li>Create a folder at sim/templates and create a file called sign_in.html in it.</li><li>Add the below to sign_in.html:</li></ul><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;Login Page&lt;/title&gt;<br>    &lt;script src=&quot;https://accounts.google.com/gsi/client&quot; async&gt;&lt;/script&gt;<br>    &lt;style&gt;<br>        body {<br>            font-family: Arial, sans-serif;<br>            background-color: #f4f4f4;<br>            display: flex;<br>            justify-content: center;<br>            align-items: center;<br>            height: 100vh;<br>            margin: 0;<br>        }</pre><pre>        .container {<br>            background-color: white;<br>            padding: 20px;<br>            border-radius: 10px;<br>            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);<br>            text-align: center;<br>        }</pre><pre>        img {<br>            border-radius: 50%;<br>            width: 100px;<br>            height: 100px;<br>            object-fit: cover;<br>            margin-top: 10px;<br>        }</pre><pre>        p {<br>            color: #333;<br>            margin: 10px 0;<br>        }</pre><pre>        a {<br>            color: #007bff;<br>            text-decoration: none;<br>            font-weight: bold;<br>        }</pre><pre>        a:hover {<br>            text-decoration: underline;<br>        }</pre><pre>        .g_id_signin {<br>            margin-top: 20px;<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;</pre><pre>&lt;div class=&quot;container&quot;&gt;<br>    {% if request.session.user_data %}<br>    &lt;div&gt;<br>        &lt;p&gt;Hi {{ request.session.user_data.given_name }} 🙂&lt;/p&gt;<br>        &lt;p&gt;Your email is {{ request.session.user_data.email }}&lt;/p&gt;<br>        &lt;img src=&quot;{{ request.session.user_data.picture }}&quot; alt=&quot;User picture&quot;&gt;<br>        &lt;p&gt;Click here to &lt;a href=&quot;/sign-out&quot;&gt;Sign out&lt;/a&gt;&lt;/p&gt;<br>    &lt;/div&gt;<br>    {% else %}<br>    &lt;div&gt;<br>        &lt;p&gt;Hi there 🙂 &lt;/p&gt;<br>        &lt;p&gt;Click below to sign in with Google&lt;/p&gt;<br>        &lt;!--            Paste the generated HTML code for Google sign in button goes here--&gt;<br>    &lt;/div&gt;<br>    {% endif %}<br>&lt;/div&gt;</pre><pre>&lt;/body&gt;<br>&lt;/html&gt;</pre><p>This includes the script tag to load the Google sign-in API and the button to trigger the sign-in flow.</p><h4>b. Generate Google sign in button HTML</h4><p>Now we’ll generate the specific HTML to add the button for your app.</p><p>To do this, visit the Google HTML generator <a href="https://developers.google.com/identity/gsi/web/tools/configurator">here</a>.</p><p>It should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*7u9wDMV6ZSbnsCgTb3GCXw.jpeg" /></figure><ul><li>For Google client ID, enter your OAuth client ID.</li><li>For Login URL, enter: http://localhost:8000/auth-receiver (<strong>Production note</strong>: you&#39;ll need to change this to your production URL when deploying to production).</li><li>Click “Enable Sign in with Google button”</li><li>In the behaviour option, select ‘popup’. (Note that we choose the ‘popup’ option. This is because the ‘redirect’ option doesn’t work in local development (e.g., localhost), despite working in production (I’ve just spent 90 mins exhausting the options). In contrast, ‘popup’ works in development)</li><li>Select the sign in methods you want (I selected both ‘Enable Sign in with Google button’ and ‘Enable Google One Tap’).</li><li>Click ‘Get code’ and copy the HTML code.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*0ncyZK1t-ZVOYbDxyJ5J4g.jpeg" /></figure><h4>c. Add the HTML code to your sign in page</h4><ul><li>Paste the HTML code that you’ve just generated into your sign_in.html file where you want the button to appear.</li></ul><h3>Create your views</h3><ul><li>Add the below views to sim/views.py:</li></ul><pre>import os</pre><pre>from django.http import HttpResponse<br>from django.shortcuts import render, redirect<br>from django.views.decorators.csrf import csrf_exempt<br>from google.oauth2 import id_token<br>from google.auth.transport import requests<br></pre><pre>@csrf_exempt<br>def sign_in(request):<br>    return render(request, &#39;sign_in.html&#39;)<br></pre><pre>@csrf_exempt<br>def auth_receiver(request):<br>    &quot;&quot;&quot;<br>    Google calls this URL after the user has signed in with their Google account.<br>    &quot;&quot;&quot;<br>    print(&#39;Inside&#39;)<br>    token = request.POST[&#39;credential&#39;]</pre><pre>    try:<br>        user_data = id_token.verify_oauth2_token(<br>            token, requests.Request(), os.environ[&#39;GOOGLE_OAUTH_CLIENT_ID&#39;]<br>        )<br>    except ValueError:<br>        return HttpResponse(status=403)</pre><pre>    # In a real app, I&#39;d also save any new user here to the database.<br>    # You could also authenticate the user here using the details from Google (https://docs.djangoproject.com/en/4.2/topics/auth/default/#how-to-log-a-user-in)<br>    request.session[&#39;user_data&#39;] = user_data</pre><pre>    return redirect(&#39;sign_in&#39;)<br></pre><pre>def sign_out(request):<br>    del request.session[&#39;user_data&#39;]<br>    return redirect(&#39;sign_in&#39;)</pre><h3>Connect your urls</h3><ul><li>Include the app’s URLs in the core/urls.py file:</li></ul><pre>from django.contrib import admin<br>from django.urls import include, path</pre><pre>urlpatterns = [<br>    path(&#39;admin/&#39;, admin.site.urls),<br>    path(&#39;&#39;, include(&#39;sim.urls&#39;)),<br>]</pre><ul><li>Create a urls.py file in the sim directory with the below code:</li></ul><pre>from django.urls import path<br>from . import views</pre><pre>urlpatterns = [<br>    path(&#39;&#39;, views.sign_in, name=&#39;sign_in&#39;),<br>    path(&#39;sign-out&#39;, views.sign_out, name=&#39;sign_out&#39;),<br>    path(&#39;auth-receiver&#39;, views.auth_receiver, name=&#39;auth_receiver&#39;),<br>]</pre><ul><li>Run your migrations to create the database tables for our app (So that we can store the user’s information):</li></ul><pre>python manage.py migrate</pre><h3>4 .Run your app and test your Google sign in</h3><ul><li>Run your app, making sure that the address and port number matches the port number you added to your Authorized Javascript origins and Authorized redirect URIs.</li></ul><pre>python manage.py runserver 8000</pre><p>You should see your Google sign in on the page like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*QLVZaqrOumAT-BsTiG76ow.jpeg" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c3ad1113446" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Django is an MVT-Based Framework]]></title>
            <link>https://tsharma2907.medium.com/why-django-is-an-mvt-based-framework-9c1fd2f48ecb?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c1fd2f48ecb</guid>
            <category><![CDATA[django-framework]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[rest]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Fri, 13 Dec 2024 12:05:51 GMT</pubDate>
            <atom:updated>2024-12-13T12:05:51.754Z</atom:updated>
            <content:encoded><![CDATA[<p>Django is one of the most popular web frameworks for Python developers, widely recognized for its efficiency, scalability, and robust features. At its core, Django follows the <strong>Model-View-Template (MVT)</strong> design pattern. To understand why Django adopts MVT instead of the more commonly known <strong>Model-View-Controller (MVC)</strong>, let’s dive deep into its architecture, the principles behind it, and its advantages.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_1QkIEWG4n4icHhsovEXA.jpeg" /></figure><h3>1. Understanding MVT in Django</h3><p>The MVT pattern is a software design architecture similar to MVC but with slight variations. Each component in MVT has a specific role:</p><ul><li><strong>Model:</strong><br>The Model represents the data structure and business logic of the application. It interacts with the database and provides an abstraction layer to perform CRUD (Create, Read, Update, Delete) operations. In Django, the Model is a Python class that defines the schema of your database table.</li><li><strong>View:</strong><br>The View is responsible for processing user requests and returning the appropriate response. In Django, the View is not tied to a visual component but rather acts as a bridge between the Model and the Template. It handles the application’s logic and fetches the required data from the Model to render a Template.</li><li><strong>Template:</strong><br>The Template is the front-end representation of the data. It determines how the data fetched by the View is displayed to the user. Django templates use a lightweight templating engine with simple syntax to dynamically generate HTML.</li></ul><h3>2. Differences Between MVT and MVC</h3><p>At a glance, MVT might seem very similar to MVC. However, the key difference lies in how Django handles the Controller:</p><ul><li>In MVC, the <strong>Controller</strong> is a separate component that manages user input and updates the Model and View accordingly.</li><li>In MVT, Django takes care of the “Controller” part implicitly through its framework. The developer only needs to define the Views and Models, while Django’s internal mechanisms handle the rest.</li></ul><p>Thus, the MVT pattern simplifies development by abstracting the responsibilities of the Controller.</p><h3>3. Why Django Follows the MVT Pattern</h3><h4>a) Ease of Use and Development</h4><p>Django’s philosophy is to make web development <strong>fast, clean, and scalable</strong>. The MVT pattern aligns perfectly with this philosophy by reducing the developer’s workload. By abstracting the Controller, Django allows developers to focus solely on the business logic (Model) and presentation (Template), leaving the framework to handle routing and HTTP responses.</p><h4>b) Separation of Concerns</h4><p>MVT provides a clear separation of concerns:</p><ul><li>Models handle data storage and manipulation.</li><li>Views manage application logic and request processing.</li><li>Templates handle the presentation layer.</li></ul><p>This separation makes the codebase more organized and easier to maintain, especially in large applications.</p><h4>c) Django’s Automatic URL Routing</h4><p>In MVC, the Controller is explicitly defined and handles URL routing and request mapping. In Django, the framework uses a powerful URL dispatcher to map requests to Views automatically. This built-in feature eliminates the need for a separate Controller, making MVT more suitable for Django’s architecture.</p><h4>d) Flexibility in Front-End Design</h4><p>The MVT pattern allows developers to work independently on the front-end (Template) without interfering with the back-end logic (Model and View). Django’s template engine supports modular and reusable components, enabling front-end developers to focus on design while back-end developers work on business logic.</p><h4>e) Faster Development with Batteries-Included Philosophy</h4><p>Django’s “batteries-included” approach provides tools for ORM (Object-Relational Mapping), form handling, authentication, and more. These built-in components work seamlessly with the MVT structure, further streamlining development.</p><h3>4. How MVT Works in Django</h3><p>Here’s a step-by-step explanation of how Django handles a web request using the MVT pattern:</p><ol><li><strong>Request Handling:</strong> When a user sends a request to the server, Django’s URL dispatcher matches the URL pattern with the corresponding View.</li><li><strong>View Logic:</strong> The View processes the request by fetching or modifying data using the Model. It may also apply specific business logic.</li><li><strong>Data from the Model:</strong> The View interacts with the Model to retrieve or update data in the database. Django’s ORM simplifies this process, allowing developers to interact with the database using Python objects.</li><li><strong>Template Rendering:</strong> Once the data is processed, the View passes it to a Template for rendering. The Template dynamically generates the HTML based on the provided data.</li><li><strong>Response:</strong> The generated HTML is sent back to the user as an HTTP response.</li></ol><h3>5. Advantages of MVT in Django</h3><h4>a) Modularity</h4><p>Each component of MVT can be developed and tested independently. For example, you can change the database schema (Model) without affecting the front-end (Template) or modify the business logic (View) without touching the Model.</p><h4>b) Scalability</h4><p>Django’s MVT architecture supports scalability by enabling developers to build large, modular applications. The separation of concerns ensures that individual components can be optimized or replaced without disrupting the entire system.</p><h4>c) Ease of Debugging and Testing</h4><p>MVT makes debugging and testing more straightforward because each layer has a distinct role. Django also provides built-in testing tools to verify the functionality of Views, Models, and Templates.</p><h4>d) Reusable Components</h4><p>The MVT pattern encourages code reuse. Models, Views, and Templates can be reused across different projects or modules, reducing development time and effort.</p><h4>e) Customizability</h4><p>While Django provides default implementations for many features, developers can customize each component of the MVT pattern to suit their specific needs. For instance, the template engine can be replaced with a third-party engine like Jinja2 if desired.</p><h3>6. Real-World Examples of MVT in Action</h3><h4>Example 1: Blog Application</h4><ul><li><strong>Model:</strong> Represents blog posts with fields for title, content, author, and date.</li><li><strong>View:</strong> Fetches the list of posts from the database and passes it to a Template.</li><li><strong>Template:</strong> Displays the posts in a user-friendly format, including pagination and styling.</li></ul><h4>Example 2: E-Commerce Website</h4><ul><li><strong>Model:</strong> Represents products, categories, and orders.</li><li><strong>View:</strong> Processes user requests for adding items to the cart, placing orders, or searching for products.</li><li><strong>Template:</strong> Renders dynamic pages for product listings, cart details, and order confirmation.</li></ul><h3>7. Comparison with Other Frameworks</h3><ul><li><strong>Flask (Python):</strong> Flask is a micro-framework that doesn’t enforce a specific design pattern like MVT. Developers must manually structure their application, giving more flexibility but requiring more effort.</li><li><strong>Ruby on Rails (Ruby):</strong> Rails follows the MVC pattern, where the Controller explicitly handles routing and business logic. This approach can lead to more boilerplate code compared to Django’s implicit handling.</li></ul><p>Django’s MVT pattern strikes a balance between flexibility and simplicity, making it an ideal choice for developers looking for a structured yet powerful framework.</p><h3>Conclusion</h3><p>Django’s MVT architecture is a cornerstone of its success, enabling developers to build robust, maintainable, and scalable web applications. By abstracting the Controller and leveraging built-in tools, Django simplifies web development while adhering to the principle of separation of concerns.</p><p>The MVT pattern is not just a design choice — it’s an embodiment of Django’s philosophy to help developers take their ideas from concept to deployment as quickly as possible. For anyone looking to develop dynamic, content-driven websites, understanding and leveraging Django’s MVT pattern is essential.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c1fd2f48ecb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Session Token vs. Session Cookies: A Comprehensive Comparison]]></title>
            <link>https://tsharma2907.medium.com/session-token-vs-session-cookies-a-comprehensive-comparison-d4e402eb8507?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4e402eb8507</guid>
            <category><![CDATA[django]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[networking]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Mon, 30 Sep 2024 18:14:09 GMT</pubDate>
            <atom:updated>2024-09-30T18:14:09.399Z</atom:updated>
            <content:encoded><![CDATA[<p>In web applications, maintaining user authentication and session management is a critical aspect of ensuring a secure and smooth user experience. Two common methods for handling user sessions are session tokens and session cookies. Although both serve the purpose of maintaining a user’s session state, they work in distinct ways, each with its own advantages and disadvantages. This article delves into the key differences between session tokens and session cookies, exploring how they function, their use cases, and how to choose between them for web development projects.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*aWVg7z1eNVPfhFexdjn2wQ.jpeg" /></figure><h3>Understanding Sessions in Web Applications</h3><p>When a user logs into a web application, the system needs to remember who the user is for the duration of their interaction. Since HTTP is a stateless protocol, the server doesn’t inherently retain any memory of users between requests. To overcome this, session management mechanisms, such as session tokens and session cookies, are employed.</p><h3>What Are Session Tokens?</h3><p>Session tokens are unique identifiers issued by the server after a user successfully logs in. These tokens are often randomly generated and act as a key for retrieving user session data stored on the server or within a database. Once issued, the token is sent to the client (browser or mobile app) and is included in each subsequent request to identify the user.</p><h4>Characteristics of Session Tokens:</h4><ol><li><strong>Stateless Authentication</strong>: Session tokens enable stateless authentication. They don’t store user data directly but rather act as a reference to the user’s session state stored on the server.</li><li><strong>Bearer Tokens</strong>: Most session tokens are treated as “bearer tokens,” meaning that possessing the token provides access. Therefore, securing the token during transmission and storage is crucial.</li><li><strong>Token Format</strong>: Session tokens can be in various formats, such as JSON Web Tokens (JWTs), opaque tokens, or custom strings.</li></ol><h4>How Session Tokens Work:</h4><ol><li><strong>User Login</strong>: When a user logs in, the server verifies the credentials and generates a session token.</li><li><strong>Token Storage</strong>: The token is sent to the client and stored locally, typically in the browser’s localStorage or sessionStorage for web applications or in a secure location for mobile apps.</li><li><strong>Subsequent Requests</strong>: For each subsequent request, the client includes the session token in the HTTP headers, such as the Authorization header.</li><li><strong>Token Validation</strong>: The server verifies the token with every request to authenticate the user.</li></ol><h3>What Are Session Cookies?</h3><p>Session cookies are small data files stored on the client’s device by the browser. They are sent by the server during user authentication and automatically included in subsequent HTTP requests, allowing the server to identify the user’s session.</p><h4>Characteristics of Session Cookies:</h4><ol><li><strong>Stateful Authentication</strong>: Session cookies rely on the server maintaining session state. When a user logs in, session data is stored on the server, and the cookie acts as a reference to this data.</li><li><strong>Storage</strong>: Cookies are stored in the browser and are automatically managed by the browser itself. This means they don’t require manual handling, unlike session tokens.</li><li><strong>Expiration</strong>: Cookies can have expiration dates, allowing them to persist across browser sessions or be deleted once the browser is closed.</li></ol><h4>How Session Cookies Work:</h4><ol><li><strong>User Login</strong>: When a user logs in, the server creates a session and stores relevant data. It sends a session cookie back to the client.</li><li><strong>Cookie Storage</strong>: The client stores the session cookie, and it is automatically included in subsequent HTTP requests to the server.</li><li><strong>Session Identification</strong>: The server reads the cookie and maps it to the session data stored on the server, identifying the user.</li></ol><h3>Advantages and Disadvantages of Session Tokens</h3><h4>Advantages:</h4><ol><li><strong>Flexibility</strong>: Session tokens are ideal for Single Page Applications (SPAs) and mobile apps, as they offer more control over how they are managed and transmitted.</li><li><strong>Statelessness</strong>: Since session tokens don’t rely on server-side storage, they can be more scalable for large applications.</li><li><strong>Cross-Origin Support</strong>: They can be used across different domains without facing the limitations imposed by cookie policies.</li></ol><h4>Disadvantages:</h4><ol><li><strong>XSS Vulnerability</strong>: If stored in localStorage or sessionStorage, tokens are susceptible to Cross-Site Scripting (XSS) attacks.</li><li><strong>Manual Handling</strong>: Developers need to implement mechanisms to handle token storage, retrieval, and inclusion in HTTP requests.</li></ol><h3>Advantages and Disadvantages of Session Cookies</h3><h4>Advantages:</h4><ol><li><strong>Automatic Management</strong>: Browsers handle session cookie storage and transmission, reducing the burden on developers.</li><li><strong>Security Features</strong>: Cookies can be made secure with attributes such as HttpOnly (prevents JavaScript access), Secure (transmits only over HTTPS), and SameSite (mitigates CSRF attacks).</li><li><strong>Compatibility</strong>: Well-suited for traditional web applications that rely on browser-server interactions.</li></ol><h4>Disadvantages:</h4><ol><li><strong>Vulnerable to CSRF</strong>: Session cookies are susceptible to Cross-Site Request Forgery (CSRF) attacks.</li><li><strong>Limited to Browser Use</strong>: Cookies are limited to browser-based applications, making them less suitable for mobile apps or certain API interactions.</li></ol><h3>Security Concerns and Best Practices</h3><h4>Session Tokens:</h4><ul><li><strong>Prevent XSS</strong>: Ensure proper input sanitization and use Content Security Policy (CSP) headers to mitigate XSS risks.</li><li><strong>Secure Storage</strong>: Avoid storing session tokens in localStorage or sessionStorage if possible. Consider using secure HTTP-only cookies for token storage.</li><li><strong>Short Expiration</strong>: Use short-lived tokens and refresh them periodically to reduce the impact of token theft.</li></ul><h4>Session Cookies:</h4><ul><li><strong>Use Secure Attributes</strong>: Always set the HttpOnly, Secure, and SameSite attributes on cookies to enhance security.</li><li><strong>Mitigate CSRF</strong>: Implement anti-CSRF tokens to protect against forgery attacks.</li><li><strong>Proper Expiration</strong>: Set appropriate expiration times for cookies based on the session duration.</li></ul><h3>Use Cases: When to Choose Session Tokens vs. Session Cookies</h3><h4>Session Tokens Are Ideal For:</h4><ul><li><strong>Mobile Applications</strong>: Since mobile apps often interact with APIs, using session tokens provides flexibility in managing sessions.</li><li><strong>Single Page Applications (SPAs)</strong>: SPAs often interact with back-end APIs, making session tokens more suitable due to their stateless nature.</li><li><strong>Microservices Architecture</strong>: Tokens work well with distributed systems, allowing multiple services to authenticate requests.</li></ul><h4>Session Cookies Are Ideal For:</h4><ul><li><strong>Traditional Web Applications</strong>: Session cookies are perfect for applications with server-rendered pages and typical browser interactions.</li><li><strong>Browser-Based Sessions</strong>: If the application solely relies on browser-based sessions, cookies provide a more straightforward approach.</li></ul><h3>Conclusion</h3><p>Session tokens and session cookies are essential tools for managing user sessions in web applications. While session cookies offer a simple, browser-managed solution for stateful authentication, session tokens provide greater flexibility, scalability, and compatibility with modern application architectures. The choice between the two depends on your application’s requirements, security considerations, and the platforms you intend to support.</p><p>For web applications with a strong reliance on APIs, SPAs, or mobile apps, session tokens are often the preferred choice. In contrast, for traditional, server-rendered applications that rely on browser interactions, session cookies offer a more straightforward and secure approach. Understanding their differences and implementing the best practices outlined in this article will help you build secure, efficient, and scalable session management for your web applications.</p><p>Thnaks for giving out your precious time for this article, see you soon with another one.</p><p>Tanuj Sharma</p><p>Certified AWS Cloud Architect</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4e402eb8507" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a Domain? A full guide to know everything about a domain]]></title>
            <link>https://tsharma2907.medium.com/what-is-a-domain-a-full-guide-to-know-everything-about-a-domain-c372c13f8afb?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/c372c13f8afb</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[networking]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[domain-names]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Thu, 09 May 2024 17:22:01 GMT</pubDate>
            <atom:updated>2024-05-09T17:22:01.529Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KBohXcnMy4rAMnEjA817ww.png" /></figure><p>An essential component of the digital landscape, domains serve as the virtual addresses of websites, enabling users to navigate the vast realms of the internet. This comprehensive guide delves into the intricate world of domains, covering everything from the fundamental concepts of domain names to the nuances of subdomains and wildcard domains. By unraveling the complexities of domain management, registration, and hosting options, this article aims to equip readers with a thorough understanding of domains and their pivotal role in shaping online identities.</p><p><strong>Introduction to Domains</strong></p><p>So, you wanna know about domains, huh? Well, buckle up because we’re about to dive into the world of website addresses. Let’s start with the basics.</p><p>A domain is like your digital address on the internet. It’s what people type into their browsers to find your website. Think of it as your online real estate — without a domain, your site would be like a house with no address.</p><p>Having a solid domain name is crucial for your online presence. It’s the first thing people see and remember about your website. Plus, a good domain can boost your credibility and help with SEO. So, choose wisely!</p><p><strong>Understanding Subdomains</strong></p><p>Subdomains, huh? Sounds fancy, but they’re not as complicated as they sound. Let’s break it down.</p><p><strong>What are Subdomains?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*HuCspzR5NpfxLYKz_yy4Eg.png" /></figure><p>Subdomains are like mini-websites that live under your main domain. They’re used to organize different sections of your site or create separate webpages. It’s like having a secret room in your digital house.</p><p><strong>Setting up Subdomains</strong></p><p>Setting up subdomains is like adding extensions to your main domain. It’s a way to categorize your content and make your site more user-friendly. Plus, it can help with SEO by targeting specific keywords.</p><p><strong>Exploring Wildcard Domains</strong></p><p>Whoa, wildcard domains? Sounds mysterious, right? Don’t worry, we’ll demystify this concept.</p><p><strong>Wildcard Domain Concept</strong></p><p>A wildcard domain is like a magic wand for your website. It lets you create unlimited subdomains on the fly without having to set them up individually. It’s like having a genie granting your subdomain wishes.</p><p><strong>Use Cases for Wildcard Domains</strong></p><p>Wildcard domains are handy for large websites with dynamic content or multiple users. They save time and effort by automating the process of creating subdomains. It’s like having a personal assistant for your website maintenance.</p><p><strong>Registering and Managing Domains</strong></p><p>Ready to stake your claim on the internet? Let’s talk about the nitty-gritty of registering and managing your domain.</p><p><strong>Choosing a Domain Registrar</strong></p><p>Picking a domain registrar is like choosing a guardian for your online property. Make sure to go with a reputable registrar that offers good security, customer support, and fair pricing. You wouldn’t want a shady landlord for your digital estate, right?</p><p><strong>Domain Registration Process</strong></p><p>Registering a domain is pretty straightforward. Just search for an available domain name, select your registrar, and complete the registration process. It’s like buying a plot of land in the digital world — once it’s yours, you can start building your dream website.</p><h3>Domain Name System (DNS) Basics</h3><h3>Overview of DNS</h3><p>So, you’re diving into the world of domains, huh? Think of the Domain Name System (DNS) like the internet’s phone book. It translates human-readable domain names (like example.com) into machine-readable IP addresses. No more memorizing long strings of numbers!</p><h3>How DNS Works</h3><p>When you type a domain name into your browser, your computer queries a DNS server to find the corresponding IP address. This process involves multiple servers working together to ensure you end up on the right website. It’s like a digital game of Hot Potato, but with data instead of spuds.</p><h3>Domain Hosting Options</h3><h3>Types of Domain Hosting</h3><p>There are different ways to host your domain, from shared hosting (think of it as roommates for your website) to dedicated servers (your website’s private penthouse). Understanding your hosting options can help you find the perfect home for your online presence.</p><h3>Selecting the Right Hosting Provider</h3><p>Choosing a hosting provider is like choosing a landlord for your website. You want someone reliable, secure, and responsive to your needs. Do your research, read reviews, and consider factors like uptime guarantees, customer support, and scalability.</p><h3>Domain Security and Best Practices</h3><h3>Securing Your Domain</h3><p>Just like you lock your front door, you need to secure your domain against cyber threats. Implementing measures like HTTPS encryption, strong passwords, and domain privacy protection can safeguard your online identity and data from prying eyes.</p><h3>Best Practices for Domain Management</h3><p>Managing your domain is like tending to a virtual garden — you need to prune, nurture, and protect it. Regularly update your domain registration details, renew your domain promptly, and monitor for any suspicious activities. A well-maintained domain is a happy domain!In conclusion, mastering the realm of domains empowers individuals and businesses to establish a strong online presence and navigate the digital sphere with confidence. By embracing the knowledge shared in this guide, readers can harness the potential of domains, subdomains, and wildcard domains to enhance their websites, optimize their online strategies, and ensure a secure and streamlined digital experience. Embracing best practices and staying informed about domain trends will enable readers to stay ahead in the ever-evolving online landscape.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c372c13f8afb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Basics for a Computer Science Career: A Comprehensive Guide]]></title>
            <link>https://tsharma2907.medium.com/linux-basics-for-a-computer-science-career-a-comprehensive-guide-e66f97e19afa?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/e66f97e19afa</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[operating-systems]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Sun, 07 Apr 2024 18:45:25 GMT</pubDate>
            <atom:updated>2024-04-07T18:45:25.553Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZEhgP0nZgn5C-Pgd1Fhmg.jpeg" /><figcaption>Open Source Operating System</figcaption></figure><p>As a computer science professional, understanding the Linux operating system is crucial to your success. Linux is widely used in the industry, and its open-source nature makes it an ideal platform for learning and experimentation. In this article, we’ll explore the fundamental Linux concepts and skills that will help you kickstart your career.</p><p><strong>1. Introduction to Linux</strong></p><p>Linux is an open-source, Unix-like operating system that is widely used in servers, cloud infrastructure, and embedded systems. It is known for its stability, security, and flexibility. Linux is also popular among the cybersecurity community due to its extensive use in various security tools, distributions, and platforms.</p><p><strong>2. Linux Distributions</strong></p><p>A Linux distribution, or “distro,” is a specific version of the Linux operating system, often customized for specific use cases. Popular Linux distributions for cybersecurity include:</p><p>- Kali Linux: A Debian-based distribution primarily used for penetration testing and digital forensics.<br>- Parrot Security OS: A lightweight, Debian-based distribution designed for ethical hacking, penetration testing, and digital forensics.<br>- BlackArch Linux: An Arch Linux-based distribution with over 2300 tools for penetration testing and ethical hacking.<br>- Ubuntu: A user-friendly, Debian-based distribution suitable for beginners and professionals alike.</p><p><strong>3. Linux File System</strong></p><p>The Linux file system is a hierarchical structure that organizes files and directories. Key directories include:</p><p>- / (root): The top-level directory of the Linux file system.<br>- /bin: Contains essential user commands and applications.<br>- /sbin: Contains system administration commands and applications.<br>- /usr: Contains user-related applications and libraries.<br>- /var: Contains variable files, such as logs, databases, and caches.<br>- /tmp: Contains temporary files created by applications.</p><p><strong>4. Basic Linux Commands</strong></p><p>Familiarize yourself with the following essential Linux commands:</p><p>- ls: Lists files and directories.<br>- cd: Changes the current directory.<br>- pwd: Displays the current working directory.<br>- cat: Concatenates and displays files.<br>- echo: Displays a message or variable.<br>- man: Displays the manual page for a command.<br>- sudo: Executes a command with administrative privileges.<br>- find: Searches for files and directories.<br>- grep: Searches for a specific pattern in files.<br>- tar: Archives and compresses files.<br>- chmod: Changes file permissions.<br>- chown: Changes file ownership.<br>- nano: A simple text editor.<br>- vi: A more advanced text editor.</p><p><strong>5. Linux Processes and Services</strong></p><p>Understanding processes and services is essential for managing and monitoring a Linux system. Key concepts include:</p><p>- ps: Lists running processes.<br>- top: Displays system resource usage and running processes.<br>- kill: Sends a signal to terminate a process.<br>- systemctl: Controls system services and the state of the system.<br>- journalctl: Views and analyzes system logs.</p><p><strong>6. Linux Networking</strong></p><p>Networking is a crucial aspect of cybersecurity, and understanding Linux networking commands and tools is essential. Key concepts include:</p><p>- ifconfig: Displays and configures network interfaces.<br>- netstat: Displays network connections, routing tables, and interface statistics.<br>- nmap: Scans and maps networks and hosts.<br>- tcpdump: Captures and analyzes network traffic.<br>- Wireshark: A graphical network protocol analyzer.</p><p><strong>7. Linux Security</strong></p><p>Security is a primary concern in cybersecurity, and Linux offers several tools and techniques to enhance system security. Key concepts include:</p><p>- firewalld: A dynamic firewall management tool.<br>- SELinux: A mandatory access control system.<br>- AppArmor: A Linux security module that enforces security policies for applications.<br>- iptables: A user-space utility for configuring the Linux kernel firewall.<br>- OpenSSH: A secure remote administration tool.</p><p>8. <strong>Linux Virtualization</strong></p><p>Virtualization is a powerful technique for creating isolated environments for testing and training. Key concepts include:</p><p>- VirtualBox: A popular, open-source virtualization platform for creating and managing virtual machines.<br>- KVM: A full virtualization solution built into the Linux kernel.<br>- Docker: A containerization platform for creating, deploying, and managing applications in isolated environments.<br>- LXC: A lightweight containerization solution built into the Linux kernel.</p><p><strong>9. Linux Security Best Practices</strong></p><p>Following security best practices is essential for maintaining a secure Linux system. Key concepts include:</p><p>- Regularly updating and patching the system.<br>- Configuring and monitoring firewalls and access control policies.<br>- Implementing strong user authentication and access controls.<br>- Enforcing the principle of least privilege (PoLP).<br>- Regularly reviewing and analyzing system logs.<br>- Disabling unnecessary services and applications.<br>- Encrypting sensitive data and communications.<br>- Implementing a robust backup and recovery plan.</p><p><strong>10. Conclusion</strong></p><p>Linux is a powerful and versatile operating system that is essential for a cybersecurity career. By understanding the fundamental concepts and skills outlined in this article, you will be well-equipped to tackle various cybersecurity challenges and opportunities. Continuously learning and staying up-to-date with the latest Linux tools, techniques, and best practices will help you succeed in your cybersecurity career.</p><p>In summary, mastering Linux basics involves understanding its file system, commands, processes, networking, security, and virtualization. By practicing and applying these concepts, you will become a more proficient and valuable cybersecurity professional.</p><p><strong>Additional Resources</strong></p><p>- [Linux Essentials for Cybersecurity Professionals](<a href="https://www.cybrary.it/course/linux-essentials-for-cybersecurity-professionals/">https://www.cybrary.it/course/linux-essentials-for-cybersecurity-professionals/</a>)<br>- [Linux Academy](<a href="https://linuxacademy.com/">https://linuxacademy.com/</a>)<br>- [Linux Journey](<a href="https://linuxjourney.com/">https://linuxjourney.com/</a>)<br>- [Linux Survival](<a href="https://linuxsurvival.com/">https://linuxsurvival.com/</a>)<br>- [Linux Command](<a href="https://linuxcommand.org/">https://linuxcommand.org/</a>)</p><p>Good luck on your cybersecurity journey, and remember to have fun while learning!</p><p>Tanuj Sharma</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e66f97e19afa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Navigating the Pathway to a Successful Start in the IT Field: A Comprehensive Roadmap]]></title>
            <link>https://tsharma2907.medium.com/navigating-the-pathway-to-a-successful-start-in-the-it-field-a-comprehensive-roadmap-ad95cd5d84ce?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad95cd5d84ce</guid>
            <category><![CDATA[students]]></category>
            <category><![CDATA[bachelors-degree]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[college]]></category>
            <category><![CDATA[information-technology]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Fri, 15 Mar 2024 18:04:52 GMT</pubDate>
            <atom:updated>2024-03-15T18:04:52.778Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Introduction</strong>:</p><p>Embarking on a career journey in the dynamic and rapidly evolving field of Information Technology (IT) can be both exhilarating and daunting. With numerous specializations, technologies, and career paths to choose from, aspiring IT professionals often find themselves overwhelmed by the sheer breadth of opportunities. However, by following a well-structured roadmap, individuals can navigate their way through the complexities of the IT landscape and chart a course towards a fulfilling and rewarding career.</p><p>1. <strong>Self-Assessment and Goal Setting</strong>:</p><p>Before diving headfirst into the world of IT, it’s crucial to conduct a thorough self-assessment to identify your interests, strengths, and career aspirations. Consider the various domains within IT, such as cybersecurity, software development, network engineering, data science, and cloud computing, and determine which aligns most closely with your skills and passions. Establish clear, achievable goals that serve as the foundation for your career roadmap.</p><p>2. <strong>Acquiring Fundamental Knowledge</strong>:</p><p>Building a solid foundation in IT fundamentals is essential for success in the field. Begin by familiarizing yourself with core concepts such as programming languages (e.g., Python, Java, JavaScript), operating systems, databases, networking principles, and cybersecurity fundamentals. Online resources, including tutorials, courses, and forums, offer invaluable learning opportunities for acquiring foundational knowledge at your own pace.</p><p>3. <strong>Formal Education and Certification</strong>:</p><p>Pursuing formal education, such as a degree in computer science, information technology, or a related field, can provide structured learning and academic credentials that enhance your credibility as an IT professional. Additionally, consider obtaining industry-recognized certifications relevant to your chosen specialization, such as CompTIA A+, Network+, Security+, Cisco CCNA, or Certified Ethical Hacker (CEH), to validate your skills and expertise.</p><p>4. <strong>Hands-On Experience</strong>:</p><p>Theory only takes you so far in IT; practical experience is paramount. Seek opportunities to gain hands-on experience through internships, part-time jobs, freelance projects, or volunteer work. Building real-world projects, participating in hackathons, or contributing to open-source software can further hone your technical skills, problem-solving abilities, and collaborative mindset.</p><p>5. <strong>Specialization and Advanced Learning</strong>:</p><p>As you progress in your IT career, consider specializing in a specific area that aligns with your interests and career goals. Whether it’s cybersecurity, cloud computing, artificial intelligence, DevOps, or data analytics, deepening your expertise in a niche field can open doors to exciting career opportunities and higher earning potential. Pursue advanced certifications, master’s degrees, or specialized training programs to further refine your skills and stay abreast of emerging technologies and industry trends.</p><p>6. <strong>Professional Networking and Mentorship</strong>:</p><p>Cultivating a strong professional network can significantly accelerate your career growth in the IT industry. Attend industry events, conferences, meetups, and networking sessions to connect with like-minded professionals, potential employers, and mentors who can offer valuable insights, guidance, and career advice. Actively engage with online communities, forums, and social media platforms to expand your network and stay connected with industry peers.</p><p>7. <strong>Continuous Learning and Adaptation</strong>:</p><p>The IT landscape is characterized by constant innovation and evolution, requiring IT professionals to embrace a mindset of lifelong learning and adaptation. Stay curious, proactive, and adaptable to new technologies, methodologies, and industry developments. Invest time in ongoing learning through online courses, workshops, webinars, and professional development opportunities to remain competitive and future-proof your career.</p><p>8. <strong>Building a Strong Portfolio and Personal Brand</strong>:</p><p>A compelling portfolio showcasing your projects, accomplishments, and technical skills can serve as a powerful tool for demonstrating your expertise to potential employers or clients. Develop a professional online presence through a well-crafted LinkedIn profile, personal website, or GitHub repository that highlights your achievements, contributions, and thought leadership within the IT community. Cultivate a strong personal brand that reflects your unique value proposition and professional identity.</p><p><strong>Conclusion</strong>:</p><p>Embarking on a career journey in the IT field requires careful planning, continuous learning, and strategic execution. By following the roadmap outlined above and remaining committed to personal and professional development, aspiring IT professionals can navigate the complexities of the IT landscape and achieve success in their chosen careers. Remember, the journey may be challenging at times, but with dedication, perseverance, and a passion for technology, the possibilities for growth and advancement in the IT field are endless.</p><p>This is all of my knowledge here since i started in information technology or computer science, hope you all will like this article.</p><p>That’s all for today’s article i’ll see you in the next time till then keep learning keep grinding — Tanuj Sharma</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad95cd5d84ce" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OWASP’s Pivotal Role in Shaping Web Application Security]]></title>
            <link>https://tsharma2907.medium.com/owasps-pivotal-role-in-shaping-web-application-security-44c4489b32d0?source=rss-f6e1363bca44------2</link>
            <guid isPermaLink="false">https://medium.com/p/44c4489b32d0</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[owasp]]></category>
            <category><![CDATA[hacking]]></category>
            <dc:creator><![CDATA[Tanuj Sharma]]></dc:creator>
            <pubDate>Tue, 20 Feb 2024 16:41:20 GMT</pubDate>
            <atom:updated>2024-02-20T16:41:20.183Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*xHp5qqoSvgHlw357r0ZNvg.png" /></figure><p>In an era dominated by digital landscapes, the safeguarding of web applications against cyber threats stands as an imperative challenge. As technology continues to advance, so do the sophisticated methods employed by malicious actors seeking to exploit vulnerabilities in software. Addressing this pressing concern, the <strong>Open Web Application Security Project (OWASP)</strong> emerges as a beacon of guidance and collaboration, uniting a global community to fortify the digital frontier.</p><p><strong>A Global Initiative</strong>:</p><p>OWASP, a nonprofit organization, spearheads a mission to render software security visible, empowering individuals and organizations to make informed decisions regarding the true risks associated with their digital assets. With a vibrant and diverse community of security experts, developers, and enthusiasts, OWASP stands as a testament to the power of collaborative efforts in the realm of cybersecurity.</p><p><strong>The Decisive OWASP Top Ten Project</strong>:</p><p>At the heart of OWASP’s initiatives lies the influential Top Ten Project. A dynamic and periodically updated list, this project delineates the ten most critical web application security risks, reflecting the evolving threat landscape. The Top Ten Project serves as a compass for developers, security professionals, and decision-makers, guiding them in navigating the intricate realm of application security.</p><p><strong>Comprehensive Projects and Tools</strong>:</p><p>OWASP’s commitment to excellence is underscored by an array of projects and tools that cover diverse facets of web application security. From secure coding practices to penetration testing methodologies, OWASP’s offerings empower developers and security practitioners to implement effective security measures. These resources not only enhance the resilience of applications but also contribute to the overall elevation of cybersecurity standards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/301/1*S0_KE1JFHy1_5Ozn3w9ryQ.png" /></figure><p><strong>Educational Initiatives and Awareness Campaigns</strong>:</p><p>Beyond technical resources, OWASP places a premium on education and awareness. Extensive documentation, guides, and best practices disseminate valuable insights, fostering a culture of security consciousness. OWASP’s conferences, events, and training sessions convene professionals globally, facilitating the exchange of knowledge and catalyzing advancements in application security.</p><p><strong>Global Reach and Local Impact</strong>:</p><p>OWASP’s influence extends far and wide through its local chapters, each fostering a regional community committed to grassroots efforts in enhancing application security. By bridging global expertise with local initiatives, OWASP creates a network capable of addressing the nuanced challenges faced by diverse communities.</p><p><strong>Promoting Standards and Best Practices</strong>:</p><p>Emphasizing the importance of adhering to security standards and best practices, OWASP champions a proactive approach to cybersecurity. Developers and organizations can align their security efforts with established guidelines, mitigating risks and reinforcing the resilience of digital ecosystems.</p><p>That’s all for today’s article regarding OWASP’s critical role in security field.</p><p>Will meet you in next on till then</p><p>Be safe on Internet and remember Security is just a myth on Internet.</p><p>TANUJ SHARMA</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44c4489b32d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>